From 0a07d2a8cbc9c79d954145aa12cde9647fb5b3c1 Mon Sep 17 00:00:00 2001 From: xrogaan Date: Mon, 26 Nov 2007 19:35:56 +0000 Subject: [PATCH] 5 "quelques petits trucs" --- sources/plug_base-class.inc.php | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/sources/plug_base-class.inc.php b/sources/plug_base-class.inc.php index 4b23c24..6a7b4a1 100644 --- a/sources/plug_base-class.inc.php +++ b/sources/plug_base-class.inc.php @@ -1,12 +1,9 @@ msg[] = '!help : cette aide'."\n"; - $this->msg[] = '!quit : déconection'; - $this->msg[] = '!restart : reconnection'; - $this->msg[] = '!nick : change le pseudo'; + $this->msg[] = '!help : cette aide'; + $this->msg[] = '!quit : déconection'; + $this->msg[] = '!restart : reconnection'; + $this->msg[] = '!nick : change le pseudo'; foreach ($this->msg as $m) { $this->main->MyConn->put('PRIVMSG '.$replyto.' :'.$m); } @@ -104,13 +101,13 @@ class plug_base implements plugin { $msg = $this->main->Plist[$key]->help(); - $this->main->MyConn->put('PRIVMSG '.$replyto.' :'."$key functions :\n"); + $this->main->MyConn->privmsg($replyto,"$key functions :"); if (is_array($msg)) { foreach($msg as $m) { - $this->main->MyConn->put('PRIVMSG '.$replyto.' :'.$m."\n"); + $this->main->MyConn->privmsg($replyto,' :'.$m); } } else { - $this->main->MyConn->put('PRIVMSG '.$replyto.' :'.$msg); + $this->main->MyConn->privmsg($replyto,' :'.$msg); } } } @@ -120,7 +117,8 @@ class plug_base implements plugin { if (preg_match("`^ERROR :(Closing Link: )?(.*)\r?$`i", $IRCtext)) { @fclose($this->main->MyConn->C); sleep(3); - die('Closing Link'."\n"); + echo 'Closing Link'."\n"; + die(1); } } @@ -145,7 +143,7 @@ class plug_base implements plugin { if($T[2] == IRCConn::$myBotName) { sleep(1); $this->main->MyConn->joinChannel(IRCConn::$channel); - $this->main->MyConn->put('PRIVMSG '.IRCConn::$channel.' :Merci '.$T[1].' !'); + $this->main->MyConn->privmsg(IRCConn::$channel,'Merci '.$T[1].' !'); } } } @@ -166,16 +164,20 @@ class plug_base implements plugin { } } - // CTCP + /** + * Gestion des CTCP + * + * @param string $IRCtext + */ private function CTCP($IRCtext) { - if(preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn::$myBotName, '`').'(.*?)(VERSION|USERINFO|CLIENTINFO)`', $IRCtext, $T)) { - $this->main->MyConn->put('NOTICE '.$T[1].' :RPGBot version '.IRCConn::$botVersion.' - PHP '.phpversion().' -- par Tornald'); + if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn::$myBotName, '`').'(.*?)(VERSION|USERINFO|CLIENTINFO)`', $IRCtext, $T)) { + $this->main->MyConn->notice($T[1],'RPGBot version '.IRCConn::$botVersion.' - PHP '.phpversion().' -- par Tornald'); } - if(preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn::$myBotName, '`').'(.*?)PING (.*?)\r?\n`', $IRCtext, $T)) { - $this->main->MyConn->put('NOTICE '.$T[1]." :PING\1".time()."\1"); + if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn::$myBotName, '`').'(.*?)PING (.*?)\r?\n`', $IRCtext, $T)) { + $this->main->MyConn->notice($T[1],"PING\1".time()."\1"); } - if(preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn::$myBotName,'`').'(.*?)(TIME)`', $IRCtext, $T)) { - $this->main->MyConn->put('NOTICE '.$T[1].' :'.date('Y-m-d H:i:s')); + if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn::$myBotName,'`').'(.*?)(TIME)`', $IRCtext, $T)) { + $this->main->MyConn->notice($T[1],date('Y-m-d H:i:s')); } } } -- 2.11.4.GIT