added BotLoader basics
authorpk910 <philipp@zoelle1.de>
Wed, 27 Jul 2011 11:21:52 +0000 (13:21 +0200)
committerpk910 <philipp@zoelle1.de>
Wed, 27 Jul 2011 11:21:52 +0000 (13:21 +0200)
BotLoader/Bot.class.php
BotLoader/BotLoader.class.php [new file with mode: 0644]
Bots/ExampleBot.class.php
main.php

index 21641c7897a322e9f4f3f91c8d2604fb50288b91..0a3c506b3634d2dcfb4758c8648fa3de24d5ae95 100644 (file)
@@ -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 (file)
index 0000000..855d64c
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+/********************************* PHP-P10 ******************************
+ *    P10 uplink class by pk910   (c)2011 pk910                         *
+ ************************************************************************
+ *                          Version 2 (OOP)                             *
+ *                                                                      *
+ * PHP-P10 is free software; you can redistribute it and/or modify      *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
+ *                                                                      *
+ * This program is distributed in the hope that it will be useful,      *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+ * GNU General Public License for more details.                         *
+ *                                                                      *
+ * You should have received a copy of the GNU General Public License    *
+ * along with PHP-P10; if not, write to the Free Software Foundation,   *
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.       *
+ *                                                                      *
+ ************************************************************************
+ * 
+ *  BotLoader/Bot.class.php
+ *
+ * bots' parent class.
+ *
+ */
+require_once("Bot.class.php");
+
+class BotLoader {
+       private $uplink;
+       
+       public function __construct($uplink) {
+               $this->uplink = $uplink;
+       }
+       
+       public function loadBots() {
+       
+       }
+       
+}
+
+?>
\ No newline at end of file
index b9f685d95354b25e195139c084841775e6ffdb88..53e248db617b60705aaac0174922df090b71c893 100644 (file)
@@ -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);
index 5dcf7d93b9dcd0843925f9ccfb6237bd7dcdda32..7cfe0fc1c2cadc79a0447359fe9113a0887ea1e1 100644 (file)
--- 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();
 }