From 7e30c2dbf6582392fd4389adbac56a995ab86595 Mon Sep 17 00:00:00 2001 From: pk910 Date: Wed, 27 Jul 2011 13:21:52 +0200 Subject: [PATCH] added BotLoader basics --- BotLoader/Bot.class.php | 2 +- BotLoader/BotLoader.class.php | 43 +++++++++++++++++++++++++++++++++++ Bots/ExampleBot.class.php | 7 +++++- main.php | 4 ++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 BotLoader/BotLoader.class.php diff --git a/BotLoader/Bot.class.php b/BotLoader/Bot.class.php index 21641c7..0a3c506 100644 --- a/BotLoader/Bot.class.php +++ b/BotLoader/Bot.class.php @@ -32,7 +32,7 @@ class Bot { } - public function unload() { + public function unload($rehash = false) { } diff --git a/BotLoader/BotLoader.class.php b/BotLoader/BotLoader.class.php new file mode 100644 index 0000000..855d64c --- /dev/null +++ b/BotLoader/BotLoader.class.php @@ -0,0 +1,43 @@ +uplink = $uplink; + } + + public function loadBots() { + + } + +} + +?> \ No newline at end of file diff --git a/Bots/ExampleBot.class.php b/Bots/ExampleBot.class.php index b9f685d..53e248d 100644 --- a/Bots/ExampleBot.class.php +++ b/Bots/ExampleBot.class.php @@ -54,7 +54,8 @@ class {$_NAME} extends Bot { // {$_NAME} will be replaced by our script later ; $this->uplink->join($this->example_bot, "#test"); //now we want to say something... //but note: thats the startup procedure! the p10 server is not connected to an uplink, yet - so noone would recive our message (only the other bots on this server) - } + } + } else { $this->example_bot = $old; //We've saved out Bot reference in $old so we can simply use it again... } @@ -71,6 +72,10 @@ class {$_NAME} extends Bot { // {$_NAME} will be replaced by our script later ; //please don't trigger any blocking functions here... that would cause an extreme lagg! } + public function unload($rehash = false) { //this function is triggered, when the Bot is unloaded... If it's just a rehash the return value of this method is passed to $old in the load method. + return $this->example_bot; + } + public function recive_privmsg($user, $channel, $message) { //We've got a privmsg... $exp=explode(" ",$message); diff --git a/main.php b/main.php index 5dcf7d9..7cfe0fc 100644 --- a/main.php +++ b/main.php @@ -27,6 +27,7 @@ */ require_once("Uplink/Uplink.class.php"); require_once("ModCMD/ModCMD.class.php"); +require_once("BotLoader/BotLoader.class.php"); //basicly here is nothing, yet :D $uplink = new Uplink(); @@ -38,6 +39,9 @@ $uplink->setEventHandler(ModCMD::getEventHandler()); $uplink->initialize(); +$botloader = new BotLoader($uplink); +$botloader->loadBots(); + while(true) { $uplink->loop(); } -- 2.20.1