public function handle(Bot $bot) { if (substr($bot->message['text'], 0, 7) != 'apt-get') return; $text = explode(' ', substr($bot->message['text'], 8), 2); switch ($text[0]) { case 'moo': $bot->queue('...."Have you mooed today?"...'); break; case 'install': if (!Core::compareLevel($bot->lookUpUserID(), 'op.load')) return $bot->denied(); if (stripos($text[1], '--reinstall') !== -1) { $text[1] = str_replace('--reinstall', '', $text[1]); Core::log()->info = $bot->message['usernameraw'].' reloaded a module'; $result = Core::reloadModule(trim($text[1])); } else { Core::log()->info = $bot->message['usernameraw'].' loaded a module'; $result = Core::loadModule(trim($text[1])); } if (!is_int($result)) { $bot->success(); } else { $name = 'module_error_'.$result; $bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->$name); } break; case 'remove': case 'purge': $text[1] = str_replace('--purge', '', $text[1]); if (!Core::compareLevel($bot->lookUpUserID(), 'op.load')) return $bot->denied(); Core::log()->info = $bot->message['usernameraw'].' unloaded a module'; $result = Core::unloadModule(trim($text[1])); if (!is_int($result)) { $bot->success(); } else { $name = 'module_error_'.$result; $bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->$name); } break; case 'upgrade': if (!Core::compareLevel($bot->lookUpUserID(), 'op.load')) return $bot->denied(); $modules = Core::getModules(); foreach ($modules as $module => $tmp) Core::reloadModule($module); break; } }
public function handle(Bot $bot) { if (substr(Module::removeWhisper($bot->message['text']), 0, 5) == '!php ') { if (!Core::compareLevel($bot->lookUpUserID(), 'php.eval')) return $bot->denied(); Core::log()->php = $bot->message['usernameraw'].' used '.Module::removeWhisper($bot->message['text']); eval(substr(Module::removeWhisper($bot->message['text']), 5)); } }
public function handle(Bot $bot) { if ($bot->message['id'] % 500 == 0) $this->config->write(); if (substr($bot->message['text'], 0, 1) == '-') { if (isset($this->config->config[substr($bot->message['text'], 1)])) { $bot->queue($this->config->config[substr($bot->message['text'], 1)]); } } else if (substr(Module::removeWhisper($bot->message['text']), 0, 5) == '!dic ') { if (Core::compareLevel($bot->lookUpUserID(), 'dic.add')) { $data = explode(' ', substr(Module::removeWhisper($bot->message['text']), 5), 2); if (substr($data[1], 0, 1) == '!') return $bot->denied(); $this->config->config[$data[0]] = $data[1]; Core::log()->info = $bot->message['usernameraw'].' added '.$data[0].' to dictionary'; $bot->success(); } else { $bot->denied(); } } else if (substr(Module::removeWhisper($bot->message['text']), 0, 8) == '!deldic ') { if (Core::compareLevel($bot->lookUpUserID(), 'dic.add')) { $data = substr(Module::removeWhisper($bot->message['text']), 8); unset($this->config->config[$data]); $bot->success(); } else { $bot->denied(); } } else if (Module::removeWhisper($bot->message['text']) == '!listdic') { if (Core::compareLevel($bot->lookUpUserID(), 'dic.list')) { $entries = array_keys($this->config->config); sort($entries); $bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->dic_listdic.': '.implode(', ', $entries)); } else { $bot->denied(); } } }
public function handle(Bot $bot) { if ($bot->message['id'] % 500 == 0) $this->config->write(); if ($bot->message['type'] == Bot::JOIN) { $userID = $bot->lookUpUserID(); if (isset($this->config->config[$userID]) && (!isset($this->coolDown[$userID]) || ($this->coolDown[$userID] + 5 * 60) < time())) { $bot->queue('['.$bot->message['usernameraw'].'] '.substr($this->config->config[$userID], 0, 250)); $this->coolDown[$userID] = time(); } } else if (substr(Module::removeWhisper($bot->message['text']), 0, 7) == '!quote ') { $username = substr(Module::removeWhisper($bot->message['text']), 7); $userID = $bot->lookUpUserID($username); if ($userID) { if (isset($this->config->config[$userID])) { $bot->queue('/whisper "'.$bot->message['usernameraw'].'" ['.$username.'] '.$this->config->config[$userID]); } else { $bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->quotes_noquote); } } else { $bot->queue('/whisper "'.$this->message['usernameraw'].'" '.Core::language()->get('user_not_found', array('{user}' => $username))); } } else if (substr(Module::removeWhisper($bot->message['text']), 0, 10) == '!setquote ') { $this->config->config[$bot->lookUpUserID()] = substr(Module::removeWhisper($bot->message['text']), 10); $bot->success(); } else if (Module::removeWhisper($bot->message['text']) == '!delquote') { unset($this->config->config[$bot->lookUpUserID()]); $bot->success(); } else if (substr(Module::removeWhisper($bot->message['text']), 0, 11) == '!wipequote ') { if (Core::compareLevel($bot->lookUpUserID(), 'quote.wipe')) { $username = substr(Module::removeWhisper($bot->message['text']), 11); $userID = $bot->lookUpUserID($username); if ($userID > 0) { unset($this->config->config[$userID]); $bot->success(); } else { $bot->queue('/whisper "'.$this->message['usernameraw'].'" '.Core::language()->get('user_not_found', array('{user}' => $username))); } } else { $bot->denied(); } } }
public function handle(Bot $bot) { if (Module::removeWhisper($bot->message['text']) == '!mycolor') { preg_match_all('/color: #[0-9a-fA-F]{6}/', $bot->message['username'], $matches); $bot->queue('/whisper "'.$bot->message['usernameraw'].'" /color '.substr($matches[0][0], 7).' '.substr($matches[0][count($matches[0])-1], 7)); } else if ($bot->message['text'] == '!info') { if (Core::compareLevel($bot->lookUpUserID(), 'util.info')) { $bot->queue(Core::language()->util_information.':'); $bot->queue(Core::language()->util_since.": ".date('d.m.Y H:i:s', TIME)); $bot->queue(Core::language()->util_got.": ".$bot->messageCount.' ('.round($bot->messageCount / (time() - TIME) * 60, 4).'/m)'); $bot->queue(Core::language()->util_sent.": ".$bot->sendCount.' ('.round($bot->sendCount / (time() - TIME) * 60, 4).'/m)'); } else { $bot->denied(); } } }
public function handle(Bot $bot) { if (Module::removeWhisper($bot->message['text']) == '!shutdown') { if (!Core::compareLevel($bot->lookUpUserID(), 'op.shutdown')) return $bot->denied(); Core::log()->info = $bot->message['usernameraw'].' shutted the bot down'; $bot->shutdown(); } else if (Module::removeWhisper($bot->message['text']) == '!restart') { if (!Core::compareLevel($bot->lookUpUserID(), 'op.shutdown')) return $bot->denied(); Core::log()->info = $bot->message['usernameraw'].' restarted the bot'; $bot->shutdown(SIGUSR1); } else if (substr(Module::removeWhisper($bot->message['text']), 0, 5) == '!say ') { if (!Core::compareLevel($bot->lookUpUserID(), 500)) return $bot->denied(); $bot->queue(substr(Module::removeWhisper($bot->message['text']), 5)); } else if (Module::removeWhisper($bot->message['text']) == '!loaded') { if (!Core::compareLevel($bot->lookUpUserID(), 'op.load')) return $bot->denied(); $bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->op_loaded.': '.implode(', ', array_keys(Core::getModules()))); } else if (substr(Module::removeWhisper($bot->message['text']), 0, 6) == '!join ') { if (!Core::compareLevel($bot->lookUpUserID(), 'op.join')) return $bot->denied(); $bot->getConnection()->join(substr(Module::removeWhisper($bot->message['text']), 6)); $bot->success(); } else if (Module::removeWhisper($bot->message['text']) == '!perms') { if (!Core::compareLevel($bot->lookUpUserID(), 500)) return $bot->denied(); $perms = Core::permission()->getNodes(); ksort($perms); $permString = array(); foreach ($perms as $name => $level) { $permString[] = $name.': '.$level; } $bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->op_perms.': '.implode(', ', $permString)); } else if (Module::removeWhisper($bot->message['text']) == '!rooms') { if (!Core::compareLevel($bot->lookUpUserID(), 'op.join')) return $bot->denied(); $rooms = $bot->getConnection()->getRooms(); $roomString = array(); foreach ($rooms as $id => $name) { $roomString[] = $name.': '.$id; } $bot->queue('/whisper "'.$bot->message['usernameraw'].'" '.Core::language()->op_rooms.': '.implode(', ', $roomString)); } }