format
[PHP-P10.git] / Bots / IPv6.class.php
index 44c79d7fdf9c6100acd58e20add9fd3c1c8ad038..d5c4a1ef2b4ea5ab6270b12dd37721fa453b71bc 100644 (file)
@@ -1,12 +1,10 @@
 <?php
-/********************************* PHP-P10 ******************************
- *    P10 uplink class by pk910   (c)2011 pk910                         *
- ************************************************************************
- *                          Version 2 (OOP)                             *
+/******************************* PHP-P10 v2 *****************************
+ * Copyright (C) 2011-2012  Philipp Kreil (pk910)                       *
  *                                                                      *
- * PHP-P10 is free software; you can redistribute it and/or modify      *
+ * 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 2 of the License, or    *
+ * 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,      *
  * 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.       *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
  *                                                                      *
  ************************************************************************
- * 
- *  Bots/ModManager.class.php
  *
- * module manager bot...
+ *  Bots/IPv6.class.php
+ *
+ * IPv6 bot...
  *
  */
 
@@ -30,17 +27,17 @@ class {$_NAME} extends Bot {
        private $uplink;
        private $ipv6;
        private $cache = array(
-                                               0 => array(),
-                                               1 => array()
-                                       );
-       
+       0 => array(),
+       1 => array()
+       );
+
        public function load($uplink, $old = false) {
                $this->uplink = $uplink;
                if(!$old) {
                        $nick = "IPv6";
                        $ident = "ipv6";
-                       $ip = "0::0";
-                       $host = "fd00::C0CA:C01A:ADD5:11FE"; //coca cola adds life   maybe someone undestands it :D
+                       $ip = "fd00::c0ca:c01a:add5:11fe"; //coca cola adds life   maybe someone undestands it :D
+                       $host = $ip;
                        $realname = "IPv6";
                        $modes = "ioknISD";
                        $this->ipv6 = $this->uplink->addUser($nick,$ident,$host,$ip,$modes,$realname);
@@ -51,13 +48,13 @@ class {$_NAME} extends Bot {
                } else {
                        $this->ipv6 = $old;
                }
-               
+
                ModCMD::bind($this, BIND_JOIN, "recive_join");
                ModCMD::bind($this, BIND_CHANMODE, "recive_mode");
                ModCMD::bind($this, BIND_KICK, "recive_kick");
                ModCMD::bind($this, BIND_QUIT, "recive_quit");
        }
-       
+
        public function unload($rehash = false) {
                if($rehash) {
                        return $this->ipv6;
@@ -65,7 +62,7 @@ class {$_NAME} extends Bot {
                        $this->uplink->delUser($this->ipv6, "Bye.");
                }
        }
-       
+
        public function loop() {
                for($i = 0; $i < 2; $i++) {
                        foreach($this->cache[$i] as $id => $cache) {
@@ -73,12 +70,12 @@ class {$_NAME} extends Bot {
                        }
                }
        }
-       
+
        private function botOppedOnChannel($channel) {
                $privs = $channel->getUserPrivs($this->ipv6);
                return ($privs & P10_Channel::USERPRIV_OPED);
        }
-       
+
        public function recive_join($user, $channel, $isBurst) {
                if(!$this->botOppedOnChannel($channel)) return false;
                if($user->getIP()->isIPv6()) {
@@ -87,7 +84,7 @@ class {$_NAME} extends Bot {
                        $this->uplink->mode($this->ipv6, $channel, "+v ".$user->getNumeric());
                }
        }
-       
+
        public function recive_mode($user, $channel, $modes) {
                if($user->getModes()->hasMode('o') || !$this->botOppedOnChannel($channel)) return false;
                if(array_key_exists($user->getNumeric(), $this->cache[0]) && $this->cache[0][$user->getNumeric()]['time'] > time()) {
@@ -113,7 +110,7 @@ class {$_NAME} extends Bot {
                $modes = implode(" ",$mode);
                $this->uplink->mode($this->ipv6, $channel, $modes);
        }
-       
+
        public function recive_kick($user, $target, $channel, $modes) {
                if($user->getModes()->hasMode('o') || !$this->botOppedOnChannel($channel)) return false;
                if(array_key_exists($user->getNumeric(), $this->cache[1]) && $this->cache[1][$user->getNumeric()]['time'] > time()) {
@@ -123,7 +120,7 @@ class {$_NAME} extends Bot {
                        $this->cache[1][$user->getNumeric()] = time() + 600;
                }
        }
-       
+
        public function recive_quit($user, $reason) {
                if($user === $this->ipv6) {
                        $this->load($this->uplink);