X-Git-Url: http://git.pk910.de/?p=PHP-P10.git;a=blobdiff_plain;f=Bots%2FModManager.class.php;fp=Bots%2FModManager.class.php;h=4eac48c06bbd78ba379e40b624f3a0b773ff86f9;hp=0000000000000000000000000000000000000000;hb=74fcc85514c9bd0a4a8dfbd909d9555a9f1ee5b8;hpb=412e324075de1312fbc5f49b735180b46cdff82c diff --git a/Bots/ModManager.class.php b/Bots/ModManager.class.php new file mode 100644 index 0000000..4eac48c --- /dev/null +++ b/Bots/ModManager.class.php @@ -0,0 +1,117 @@ +uplink = $uplink; + if(!$old) { + $nick = "ModuleMan"; + $ident = "modman"; + $host = "Services.WebGamesNet.net"; + $ip = "0::0"; + $realname = "Module Manager"; + $modes = "ioknISD"; + $this->modman = $this->uplink->addUser($nick,$ident,$host,$ip,$modes,$realname); + if(is_a($this->modman, "P10_User")) { + $this->uplink->join($this->modman, "#opers", (P10_Channel::USERPRIV_OPED | P10_Channel::USERPRIV_VOICE)); + $this->uplink->join($this->modman, "#dev", P10_Channel::USERPRIV_VOICE); + } + } else { + $this->modman = $old; + } + + ModCMD::bind($this, BIND_PRIVMSG, "recive_privmsg"); + ModCMD::bind($this, BIND_QUIT, "recive_quit"); + } + + public function unload($rehash = false) { + if($rehash) { + return $this->modman; + } else { + $this->uplink->delUser($this->modman, "Bye."); + } + } + + function recive_privmsg($user, $channel, $message) { + if(!$user->getModes()->hasMode('o')) return 0; + $exp=explode(" ",$message); + switch (strtolower($exp[0])) { + case "~loadmod": + if(BotLoader::load($exp[1],$exp[2])) { + $this->uplink->privmsg($this->modman, $channel, "done."); + } else { + $this->uplink->privmsg($this->modman, $channel, "error."); + } + break; + case "~unloadmod": + if(BotLoader::unload($exp[1])) { + $this->uplink->privmsg($this->modman, $channel, "done."); + } else { + $this->uplink->privmsg($this->modman, $channel, "error."); + } + break; + case "~rehash": + if(BotLoader::rehash($exp[1])) { + $this->uplink->privmsg($this->modman, $channel, "done."); + } else { + $this->uplink->privmsg($this->modman, $channel, "error."); + } + break; + case "~debug": + $exp=explode(" ",$message,2); + ob_start(); + $ret = eval($exp[1]); + $out = ob_get_contents(); + ob_end_clean(); + $lines = explode("\n",$out); + for($i=0;$iuplink->privmsg($this->modman, $channel, $lines[$i]); + } + } + $lines = explode("\n",$ret); + for($i=0;$iuplink->privmsg($this->modman, $channel, $lines[$i]); + } + } + break; + } + } + + function recive_quit($user, $reason) { + if($user === $this->modman) { + $this->load($this->uplink); + } + } +} + +?> \ No newline at end of file