added default CTCP replies
authorpk910 <philipp@zoelle1.de>
Thu, 28 Jul 2011 11:35:07 +0000 (13:35 +0200)
committerpk910 <philipp@zoelle1.de>
Thu, 28 Jul 2011 11:35:07 +0000 (13:35 +0200)
Bots/ModManager.class.php
ModCMD/ModCMD.class.php
Uplink/Uplink.class.php

index 29f33027ce3911cf96feee66ce3114f133e0f2a2..318b11d8390acf10bc91d330fa17d76485574995 100644 (file)
@@ -47,6 +47,7 @@ class {$_NAME} extends Bot {
                
                ModCMD::bind($this, BIND_CHANMSG, "recive_privmsg");
                ModCMD::bind($this, BIND_QUIT, "recive_quit");
+               ModCMD::bind($this, BIND_CTCP, "recive_ctcp");
        }
        
        public function unload($rehash = false) {
@@ -57,7 +58,7 @@ class {$_NAME} extends Bot {
                }
        }
        
-       function recive_privmsg($user, $channel, $message) {
+       public function recive_privmsg($user, $channel, $message) {
                if(!$user->getModes()->hasMode('o')) return 0;
                $exp=explode(" ",$message);
                switch (strtolower($exp[0])) {
@@ -109,11 +110,30 @@ class {$_NAME} extends Bot {
                }
        }
        
-       function recive_quit($user, $reason) {
+       public function recive_quit($user, $reason) {
                if($user === $this->modman) {
                        $this->load($this->uplink);
                }
        }
+       
+       public function recive_ctcp($user, $target, $command, $text, $publicCtcp) {
+               if(!$publicCtcp) {
+                       switch($command) {
+                               case"PING":
+                                       $this->uplink->ctcp_reply($target, $user, "PONG", $text);
+                                       break;
+                               case"VERSION":
+                                       $this->uplink->ctcp_reply($target, $user, "VERSION", "PHP-P10 Pack by pk910. Source: http://devserv.pk910.de/git/?p=PHP-P10.git");
+                                       break;
+                               case"TIME":
+                                       $this->uplink->ctcp_reply($target, $user, "TIME", date('r'));
+                                       break;
+                               case"FINGER":
+                                       $this->uplink->ctcp_reply($target, $user, "FINGER", "PHP-P10 Pack (C) ".date('Y')." pk910. Visit us on irc://irc.webgamesnet.net/PHP");
+                                       break;
+                       }
+               }
+       }
 }
 
 ?>
\ No newline at end of file
index 82ee956c6637dce960e7e784540e357142973ba0..f07e7b044ca44f373873f500939b7db743b22152 100644 (file)
@@ -175,16 +175,16 @@ class ModCMD implements EventHandler {
                $this->event(BIND_CTCP, array($user, $channel, $command, $text, true));
        }
        
-       public function event_chanctcpreply($user, $target, $command, $text) {
+       public function event_chanctcpreply($user, $channel, $command, $text) {
                $this->event(BIND_CTCPREPLY, array($user, $channel, $command, $text, true));
        }
        
        public function event_privctcp($user, $target, $command, $text) {
-               $this->event(BIND_CTCP, array($user, $channel, $command, $text, false));
+               $this->event(BIND_CTCP, array($user, $target, $command, $text, false));
        }
        
        public function event_privctcpreply($user, $target, $command, $text) {
-               $this->event(BIND_CTCPREPLY, array($user, $channel, $command, $text, false));
+               $this->event(BIND_CTCPREPLY, array($user, $target, $command, $text, false));
        }
        
        public function event_away($user, $away) {
index 9d88ae523af513b05e5dd9b2223c2d1a0324767d..5e1e1ee827826973ff0db0f7fb8e2a5d5f11dce0 100644 (file)
@@ -984,7 +984,13 @@ class Uplink {
                }
        }
        
+       public function ctcp($user, $target, $command, $text) {
+               return $this->privmsg($user, $target, "\001".strtoupper($command)." ".$text."\001");
+       }
        
+       public function ctcp_reply($user, $target, $command, $text) {
+               return $this->notice($user, $target, "\001".strtoupper($command)." ".$text."\001");
+       }
        
 }