WildPHP / irc-bot

A simple and modular PHP IRC bot
MIT License
84 stars 24 forks source link

crash on connect to gamesurge #97

Closed ghost closed 6 years ago

ghost commented 6 years ago

hi there,

i can connect with this bot to freenode perfectly fine, but when i try to connect to irc.gamesurge.net i get the following error:

`[2018-06-30 17:11:07] wildphp.DEBUG: Initialized module {"class":"WildPHP\Core\Connection\SASL"} [] [2018-06-30 17:11:07] wildphp.INFO: A connection has been set up successfully and will be started. This may take a while. {"server":"irc.gamesurge.net:6667","wantedNickname":"ronald"} [] [2018-06-30 17:11:07] wildphp.DEBUG: << NOTICE AUTH :*** Looking up your hostname [] [] PHP Fatal error: Uncaught TypeError: Argument 1 passed to WildPHP\Core\Connection\UserPrefix::fromString() must be of the type string, null given, called in /home/rj1/irc-bot/src/Connection/UserPrefix.php on line 121 and defined in /home/rj1/irc-bot/src/Connection/UserPrefix.php:102 Stack trace:

0 /home/rj1/irc-bot/src/Connection/UserPrefix.php(121): WildPHP\Core\Connection\UserPrefix::fromString(NULL)

1 /home/rj1/irc-bot/src/Connection/IRCMessages/NOTICE.php(56): WildPHP\Core\Connection\UserPrefix::fromIncomingIrcMessage(Object(WildPHP\Core\Connection\IncomingIrcMessage))

2 /home/rj1/irc-bot/src/Connection/Parser.php(120): WildPHP\Core\Connection\IRCMessages\NOTICE::fromIncomingIrcMessage(Object(WildPHP\Core\Connection\IncomingIrcMessage))

3 /home/rj1/irc-bot/src/Connection/Parser.php(92): WildPHP\Core\Connection\Parser->specializeIrcMessage(Object(WildPHP\Core\Connection\IncomingIrcMessage))

4 /home/rj1/irc-bot/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(123): WildPHP\Core\Connection\Parser->parseInc in /home/rj1/irc-bot/src/Connection/UserPrefix.php on line 102

`

running PHP 7.1.17 on Debian 9 stretch

NanoSector commented 6 years ago

It looks like NOTICE and PRIVMSG commands don't specifically require a user prefix to be set. In this case the message has none so it cannot be passed to UserPrefkx::fromString, hence it being passed Null while it expects a string. Solution would be to simply disable the parsing of a user prefix if there is none. Should be a quick fix.

On July 1, 2018 12:18:37 AM GMT+02:00, rj1 notifications@github.com wrote:

update:

i changed line 102 in UserPrefix.php to:

public static function fromString($prefix): self

but i think this is probably not a good solution

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/WildPHP/irc-bot/issues/97#issuecomment-401569641

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.