Viewing topic:PHP Bot sending private messages
Page:
1
21-03-2008 - 17:54
Hi there,
First of all thanks for the superb tutorial. I had my bot running in no time!
I have fixed a lot of issues i had (quakenet is a pain!) but i can't seem to get private messages working.
I already split the user from the host part with this code:
preg_match('/^
.*?)!(.*?)$/i', $ex[0], $matches);
$hostname = "!".$matches[2];
$username = $matches[1];
But when i try a private message like this:
case ':!test':
fputs($socket, "PRIVMSG ".$username." Hi, this is a private messagen"
;
break;
It doesn't send a PM
Help is very much appreciated.
First of all thanks for the superb tutorial. I had my bot running in no time!
I have fixed a lot of issues i had (quakenet is a pain!) but i can't seem to get private messages working.
I already split the user from the host part with this code:
preg_match('/^
.*?)!(.*?)$/i', $ex[0], $matches);$hostname = "!".$matches[2];
$username = $matches[1];
But when i try a private message like this:
case ':!test':
fputs($socket, "PRIVMSG ".$username." Hi, this is a private messagen"
;break;
It doesn't send a PM

Help is very much appreciated.
21-03-2008 - 21:57
You forgot a ":" before the text you are sending. Try that, it might help. 
And also use an echo before the fputs(), so you are sure the function is called.

And also use an echo before the fputs(), so you are sure the function is called.
22-03-2008 - 10:41
Hi, I am not quite sure if this will work, because I cant test it (IRC server is down).
It looks like you want to send the message to yourself, in this case to the bot. But you are using only
. This is only from who it comes or to who it goes, I am not sure, but in either case you need to read the second part. You need to know from "who to who" it goes. So you just need to read the second part with $ex[0].
I hope this will work
It looks like you want to send the message to yourself, in this case to the bot. But you are using only
| code | |
|
|
$username |
| code | |
|
|
fputs($socket, "PRIVMSG ".$username." ".$ex[0]." :nanana:n"); |
I hope this will work
22-03-2008 - 10:44
lol, looks like something went wrong or I am too sleepy to think o_O.
the second code was
fputs($socket, "PRIVMSG ".$username." ".$ex[0]." :nanana:n"
;
the second code was
fputs($socket, "PRIVMSG ".$username." ".$ex[0]." :nanana:n"
;
22-03-2008 - 17:08
Why ex[0]?
Offtopic:
But erm.. I do hope that error is not my host again... Just sometimes out of the blue things stop working proberly!
Time to change to my dedicated server!
Offtopic:
But erm.. I do hope that error is not my host again... Just sometimes out of the blue things stop working proberly!
Time to change to my dedicated server!
25-03-2008 - 16:53
Page:
1
Reply to topic
Reply to topic

