X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ModCMD%2FModCMD.class.php;fp=ModCMD%2FModCMD.class.php;h=6c735a6bb28fcd90063559897bfcdf2f5d95c669;hb=cacbfd68b7a6d983e55742ea16cd7be101ab05f0;hp=cbd65111e94435b233c5428e6e738a1bbf9b819c;hpb=a53ed534c0e521ae169634f38f391b5bf7ca21b3;p=PHP-P10.git diff --git a/ModCMD/ModCMD.class.php b/ModCMD/ModCMD.class.php index cbd6511..6c735a6 100644 --- a/ModCMD/ModCMD.class.php +++ b/ModCMD/ModCMD.class.php @@ -60,6 +60,44 @@ class ModCMD implements EventHandler { return self::$eventHandler; } + public static function bind($bot, $type, $method) { + if(is_a($bot, "Bot") && method_exists($bot, $method)) { + if(array_key_exists($type, self::$bindings)) { + foreach(self::$bindings[$type] as $binding) { + if($binding->match($bot, $method)) + return; + } + } else + self::$bindings[$type] = array(); + self::$bindings[$type][] = new Binding($bot, $method); + } + } + + public static function unbind($bot, $type, $method) { + if(is_a($bot, "Bot")) { + if(array_key_exists($type, self::$bindings)) { + foreach(self::$bindings[$type] as $id => $binding) { + if($binding->match($bot, $method)) { + unset(self::$bindings[$type][$id]); + break; + } + } + } + } + } + + public static function unbindBot($bot) { + if(is_a($bot, "Bot")) { + foreach(self::$bindings as $type => $bindings) { + foreach($bindings as $id => $binding) { + if($binding->match($bot, null)) { + unset(self::$bindings[$type][$id]); + } + } + } + } + } + /******************************************************************************************** * EVENT HANDLER * ********************************************************************************************/ @@ -85,7 +123,7 @@ class ModCMD implements EventHandler { private function event($type, $parameters) { if(array_key_exists($type, self::$bindings)) { foreach(self::$bindings as $binding) { - $binding->trigger(); + $binding->trigger($parameters); } } }