From e678ff3f57cd7fa1f38a1d6002e7f80090ff52c5 Mon Sep 17 00:00:00 2001 From: xrogaan Date: Tue, 27 Nov 2007 13:12:57 +0000 Subject: [PATCH] 10 "resolution d'un bug des commandes privees resolution d'un bug avec jet::string2dice " --- plugins/jet-plugin.inc.php | 19 ++++++++++++++----- plugins/sample-plugin.inc.php | 9 ++++++++- sources/IRCMain-class.inc.php | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/plugins/jet-plugin.inc.php b/plugins/jet-plugin.inc.php index e615d70..1658371 100644 --- a/plugins/jet-plugin.inc.php +++ b/plugins/jet-plugin.inc.php @@ -42,12 +42,13 @@ class jet implements plugin { public function string2dice ($str) { $str = strtolower($str); - if ($str == '1d1') - return 1; $numbers = array(0,1,2,3,4,5,6,7,8,9); $modifiers = array('+','-','*','/'); + if ($str == '1d1') + return 1; + $copy = $str; $i = 0; $len_copy = strlen($copy); @@ -101,11 +102,19 @@ class jet implements plugin { } $de = self::dice($number_of_dice,$value_of_dice); + if ($modifier_nature == '') { + $r = $de; + } else { + $r = eval('return abs(ceil($de'.$modifier_nature.'$modifier));'); + } - echo 'return (int) abs(ceil('.$de.$modifier_nature.$modifier.'));'."\n"; - $r = eval('return (int) abs(ceil($de'.$modifier_nature.'$modifier));'); + if (IRCConn::$myBotName == $this->message['to']) { + $replyto = $this->message['from']; + } else { + $replyto = $this->message['to']; + } - $this->IRCConn->privmsg($this->message['from'],$r); + $this->IRCConn->privmsg($replyto,$r); } /** diff --git a/plugins/sample-plugin.inc.php b/plugins/sample-plugin.inc.php index c3d4968..3ff73dc 100644 --- a/plugins/sample-plugin.inc.php +++ b/plugins/sample-plugin.inc.php @@ -50,7 +50,14 @@ class sample implements plugin { $this->IRCConn->privmsg(IRCConn::$channel,'This is the method2 : '.$query); } - function method3 ($query,$replyto) { + function method3 ($query) { + + if (IRCConn::$myBotName == $this->message['to']) { + $replyto = $this->message['from']; + } else { + $replyto = $this->message['to']; + } + $this->IRCConn->privmsg($replyto,'This is the method3 : '.$query); } } diff --git a/sources/IRCMain-class.inc.php b/sources/IRCMain-class.inc.php index c63f06f..8f8e570 100644 --- a/sources/IRCMain-class.inc.php +++ b/sources/IRCMain-class.inc.php @@ -212,7 +212,7 @@ class IRCMain { if ($command_info['type'] == 'public') { $get_plugin_method = '!'.$plugin; } else { - $get_plugin_method = '/msg ' . IRCConn::$myBotName . ' ' . $plugin; + $get_plugin_method = '/msg ' . IRCConn::$myBotName . ' !' . $plugin; } $this->IRCConn->privmsg($this->current_msg_info ['from'],$this->formater->bold('Command :')." $get_plugin_method {$command_info['method']}".(($command_info['accepted_args']>0)?' [some args...]':'')); -- 2.11.4.GIT