6 public function __construct($main);
7 public function start($IRCtxt);
8 public function help();
12 class plug_base
implements plugin
{
16 public function __construct($main) {
20 public function start($IRCtext) {
21 $this->Deco($IRCtext);
23 $this->Pong($IRCtext);
24 $this->kick($IRCtext);
25 $this->NickUsed($IRCtext);
26 $this->IllegalChNick($IRCtext);
27 $this->CTCP($IRCtext);
28 $this->doHelp($IRCtext);
29 $this->nat_cmd($IRCtext);
30 /*$this->quit($IRCtext);
31 $this->restart($IRCtext);
32 $this->nick($IRCtext);*/
35 public function help() {
36 $msg[] = '!help : (cette aide)';
37 $msg[] = '!quit : déconection';
38 $msg[] = '!nick <nick>: change le pseudo';
41 private function nat_cmd($IRCtext) {
42 if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn
::$channel, '`').' :!([^\n]+)`',$IRCtext,$T)) {
45 echo 'Closing Link...'."\n";
46 $this->main
->MyConn
->disconnect();
50 echo 'Restart...'."\n";
51 $this->main
->MyConn
->disconnect();
55 if (strpos($T[2],' ')!==false) {
56 list ($command,$param) = explode(' ',$T[2]);
59 $this->main
->MyConn
->newNick($param);
72 private function quit($IRCtext) {
73 if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn
::$channel, '`').' :!quit$`',$IRCtext,$T)) {
74 echo 'Closing Link...'."\n";
75 $this->main
->MyConn
->disconnect();
80 private function restart($IRCtext) {
81 if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn
::$channel, '`').' :!restart`',$IRCtext,$T)) {
82 echo 'Closing Link...'."\n";
83 $this->main
->MyConn
->disconnect();
89 private function nick($IRCtext) {
90 if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn
::$channel, '`').' :!nick (.*)\n$`',$IRCtext,$T)) {
91 $this->main
->MyConn
->newNick($T1);
95 private function doHelp($IRCtxt) {
96 if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn
::$channel, '`').'(.*?)(!help)`', $IRCtxt, $T)) {
97 $msg = '!help : (cette aide1)'."\n";
98 $this->main
->MyConn
->put('NOTICE '.$T[1].' '.$msg);
99 foreach($this->main
->Plist
as $key => $val) {
100 $msg = $this->main
->Plist
[$key]->help();
101 if (is_array($msg)) {
102 echo "[DEBUG] \$msg is an array:\n";
104 foreach($msg as $m) {
105 $this->main
->MyConn
->put('NOTICE '.$T[1].' '.$m."\n");
108 echo "[DEBUG] \$msg is not an array\n";
109 $this->main
->MyConn
->put('NOTICE '.$T[1].' '.$msg);
116 private function Deco($IRCtext) {
117 if (preg_match("`^ERROR :(Closing Link: )?(.*)\r?$`i", $IRCtext)) {
118 @fclose
($this->main
->MyConn
->C
);
120 die('Closing Link'."\n");
125 private function Ok($IRCtext) {
126 if (preg_match("`^:[^ ]+ 001 .*?\r?\n`", $IRCtext)) {
127 $this->main
->MyConn
->joinChannel(IRCConn
::$channel);
132 private function Pong($IRCtext) {
133 if (preg_match("`^PING :(.*)\r?\n`", $IRCtext, $T)) {
134 $this->main
->MyConn
->put('PONG '.$T[1]);
135 echo "PING : {$T[1]}\nPONG {$T[1]}\n\n";
140 private function kick($IRCtext) {
141 if (preg_match('`^:(.*?)!.*?@.*? KICK '.IRCConn
::$channel.' ([^ ]+)`', $IRCtext, $T)) {
142 if($T[2] == IRCConn
::$myBotName) {
144 $this->main
->MyConn
->joinChannel(IRCConn
::$channel);
145 $this->main
->MyConn
->put('PRIVMSG '.IRCConn
::$channel.' :Merci '.$T[1].' !');
150 // Illegals characters in Nickname
151 private function IllegalChNick ($IRCtext) {
152 if (preg_match('`^:[^ ]+ 432 (.*?)\r?\n`', $IRCtext)){
153 IRCConn
::$myBotName = 'XboT';
154 $this->main
->MyConn
->put('NICK :'.IRCConn
::$myBotName);
158 // Nick already in use
159 private function NickUsed($IRCtext) {
160 if (preg_match('`^:[^ ]+ 433 (.*?)\r?\n`', $IRCtext)){
161 echo "Nick already in use\n\n";
162 self
::$myBotName .= '_';
163 $this->main
->MyConn
->newNick();
168 private function CTCP($IRCtext) {
169 if(preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn
::$myBotName, '`').'(.*?)(VERSION|USERINFO|CLIENTINFO)`', $IRCtext, $T)) {
170 $this->main
->MyConn
->put('NOTICE '.$T[1].' :RPGBot version '.IRCConn
::$botVersion.' - PHP '.phpversion().' -- par Tornald');
172 if(preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn
::$myBotName, '`').'(.*?)PING (.*?)\r?\n`', $IRCtext, $T)) {
173 $this->main
->MyConn
->put('NOTICE '.$T[1]." :PING\1".time()."\1");
175 if(preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn
::$myBotName,'`').'(.*?)(TIME)`', $IRCtext, $T)) {
176 $this->main
->MyConn
->put('NOTICE '.$T[1].' :'.date('Y-m-d H:i:s'));