added small stupid MCBot
authorpk910 <philipp@zoelle1.de>
Thu, 4 Aug 2011 05:19:16 +0000 (07:19 +0200)
committerpk910 <philipp@zoelle1.de>
Thu, 4 Aug 2011 05:19:16 +0000 (07:19 +0200)
Bots/MCBot.class.php [new file with mode: 0644]

diff --git a/Bots/MCBot.class.php b/Bots/MCBot.class.php
new file mode 100644 (file)
index 0000000..1370d97
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+/******************************* PHP-P10 v2 *****************************
+ * Copyright (C) 2011  Philipp Kreil (pk910)                            *
+ *                                                                      *
+ * This program 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 3 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 this program. If not, see <http://www.gnu.org/licenses/>. *
+ *                                                                      *
+ ************************************************************************
+ * 
+ *  Bots/MCBot.class.php
+ *
+ * MCBot bot...
+ *
+ */
+
+class {$_NAME} extends Bot {
+       private $uplink;
+       private $mcbot;
+       
+       public function load($uplink, $old = false) {
+               $this->uplink = $uplink;
+               if(!$old) {
+                       $nick = "MCBot";
+                       $ident = "mcbot";
+                       $ip = "::0"; //coca cola adds life   maybe someone undestands it :D
+                       $host = $ip;
+                       $realname = "MineCraft Bot";
+                       $modes = "ioknISD";
+                       $this->mcbot = $this->uplink->addUser($nick,$ident,$host,$ip,$modes,$realname);
+                       if(is_a($this->mcbot, "P10_User")) {
+                               $this->uplink->join($this->mcbot, "#MineCraft", (P10_Channel::USERPRIV_OPED | P10_Channel::USERPRIV_VOICE));
+                               $this->uplink->join($this->mcbot, "#dev", P10_Channel::USERPRIV_VOICE);
+                       }
+               } else {
+                       $this->mcbot = $old;
+               }
+               
+               ModCMD::bind($this, BIND_JOIN, "recive_join");
+               ModCMD::bind($this, BIND_QUIT, "recive_quit");
+       }
+       
+       public function unload($rehash = false) {
+               if($rehash) {
+                       return $this->mcbot;
+               } else {
+                       $this->uplink->delUser($this->mcbot, "Bye.");
+               }
+       }
+       
+       private function botOppedOnChannel($channel) {
+               $privs = $channel->getUserPrivs($this->mcbot);
+               return ($privs & P10_Channel::USERPRIV_OPED);
+       }
+       
+       public function recive_join($user, $channel, $isBurst) {
+               if(!$this->botOppedOnChannel($channel)) return false;
+               if(preg_match("#(.*).spoof.minecraft.WebGamesNet#i",$user->getHost())) {
+                       $this->uplink->mode($this->mcbot, $channel, "+v ".$user->getNumeric());
+               }
+       }
+       
+       public function recive_quit($user, $reason) {
+               if($user === $this->mcbot) {
+                       $this->load($this->uplink);
+               }
+       }
+}
+
+?>
\ No newline at end of file