super3 / IRC-Bot

A very little basic IRCBot that will get improved over the next time.
http://www.wildphp.com
102 stars 47 forks source link

The bot tries to PM itself if someone PMs it #45

Closed NanoSector closed 9 years ago

NanoSector commented 9 years ago

If you /msg the bot with a command, it tries to PM itself back.

I applied a dirty hack to work around this. I copied the getUserNickName function from Classes/Listener/Join.php into Classes/Library/IRC/Bot.php. Then I added this bit of code:

After

$command = substr( trim( \Library\FunctionCollection::removeLineBreaks( $args[3] ) ), 1 );

Add:

                // Someone PMed me? Oh noes.
                if ($source == $this->nickToUse && $args[1] == 'PRIVMSG')
            $source = $this->getUserNickName($args[0]);

That snippet detects if the bot is going to PM itself, then redirects it to PM the actual user back. This seems to work for me.