Viewing topic:PHP Bot sending private messages
Page: 1
Topic post 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.
Topic post 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.
Topic post 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
code

$username
. 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].
code

fputs($socket, "PRIVMSG ".$username." ".$ex[0]." :nanana:n");


I hope this will work
Topic post 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";
Topic post 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!
Topic post 25-03-2008 - 16:53
I forgot the : indeed

Thx

©Copyrights Combined Minds. All rights reserved 2006 - 2008 : Disclaimer
Realized by www.Minna-Media.com