/** * Something unknown, weird, unexplored or otherwise not included has been * received by this bot, and this is a function in which we'll handle it. This * function will act as a connection-helper, if anything fails, we'll make * sure the bot can connect either way. * * @param Bot $pBot Bot which received this command. */ public function onUnhandledCommand(Bot $pBot) { switch ($pBot->In->Chunks[1]) { /** Sonium :Nickname is already in use. **/ case 433: switch ($pBot->In->Chunks[3]) { case $pBot['Nickname']: /** Try alternative nickname, if set up, else fall through. **/ if (isset($pBot['AltNickname'])) { $sNickname = $pBot['AltNickname']; break; } default: $sNickname = $pBot['Nickname'] . '_' . rand(1000, 9999); break; } $pBot->send('NICK ' . $sNickname); break; /** USER :Not enough parameters **/ /** USER :Not enough parameters **/ case 461: $sUsername = !empty($pBot['Username']) ? $pBot['Username'] : NUWANI_NAME; $sRealname = !empty($pBot['Realname']) ? $pBot['Realname'] : NUWANI_VERSION_STR; $pBot->send('USER ' . $sUsername . ' - - :' . $sRealname); break; /** Killed by the server for whatever reason. **/ /** Killed by the server for whatever reason. **/ case 'KILL': Timer::Create(function () use($pBot) { $pBot['Socket']->close(); $pBot->connect(); }, 1000, false); break; } }