4 public function __construct($main);
5 public function start($IRCtxt);
6 public function help();
9 class plug_base
implements plugin
{
15 public function __construct($main) {
19 public function start($IRCtext) {
20 if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.IRCConn
::$myBotName." :connect ([^ ]+) ([^ ]+)\r\n`",$IRCtext,$T)) {
21 if ($T[2] == 'admin' && $T[3] == 'mypass') {
23 $this->main
->MyConn
->put('PRIVMSG '.$T[1].' :Vous etes bien connecte.');
24 echo "Connection de {$T[1]} en tant qu'administrateur.";
26 $this->main
->MyConn
->put('PRIVMSG '.$T[1].' :Erreur.');
29 $this->Deco($IRCtext);
31 $this->Pong($IRCtext);
32 $this->kick($IRCtext);
33 $this->NickUsed($IRCtext);
34 $this->IllegalChNick($IRCtext);
35 $this->CTCP($IRCtext);
36 $this->native_cmd($IRCtext);
40 public function help() {
43 private function native_cmd($IRCtext) {
44 if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn
::$channel, '`')." :!([^\r\n]+)\r\n`",$IRCtext,$T)) {
48 $this->main
->MyConn
->disconnect();
51 $this->main
->MyConn
->put('PRIVMSG '.$T[1]." :Vous n'êtes pas authentifié.");
56 echo 'Restart...'."\n";
57 $this->main
->MyConn
->disconnect();
61 $this->main
->MyConn
->put('PRIVMSG '.$T[1]." :Vous n'êtes pas authentifié.");
68 $this->main
->MyConn
->put('PRIVMSG '.IRCConn
::$channel.' :'.IRCConn
::$myBotName."\n");
71 if (strpos($T[2],' ')!==false) {
72 list ($command,$param) = explode(' ',$T[2]);
75 $this->main
->MyConn
->newNick($param);
82 echo 'Command '.$T[2].' not found.'."\n";
89 private function doHelp($replyto) {
90 $this->msg
[] = '!help : cette aide';
91 $this->msg
[] = '!quit : déconection';
92 $this->msg
[] = '!restart : reconnection';
93 $this->msg
[] = '!nick <nick> : change le pseudo';
94 foreach ($this->msg
as $m) {
95 $this->main
->MyConn
->put('PRIVMSG '.$replyto.' :'.$m);
98 foreach($this->main
->Plist
as $key => $val) {
99 if ($key == 'plug_base')
102 $msg = $this->main
->Plist
[$key]->help();
104 $this->main
->MyConn
->privmsg($replyto,"$key functions :");
105 if (is_array($msg)) {
106 foreach($msg as $m) {
107 $this->main
->MyConn
->privmsg($replyto,' :'.$m);
110 $this->main
->MyConn
->privmsg($replyto,' :'.$msg);
116 private function Deco($IRCtext) {
117 if (preg_match("`^ERROR :(Closing Link: )?(.*)\r?$`i", $IRCtext)) {
118 @fclose
($this->main
->MyConn
->C
);
120 echo 'Closing Link'."\n";
126 private function Ok($IRCtext) {
127 if (preg_match("`^:[^ ]+ 001 .*?\r?\n`", $IRCtext)) {
128 $this->main
->MyConn
->joinChannel(IRCConn
::$channel);
133 private function Pong($IRCtext) {
134 if (preg_match("`^PING :(.*)\r?\n`", $IRCtext, $T)) {
135 $this->main
->MyConn
->put('PONG '.$T[1]);
136 echo "PING : {$T[1]}\nPONG {$T[1]}\n\n";
141 private function kick($IRCtext) {
142 if (preg_match('`^:(.*?)!.*?@.*? KICK '.IRCConn
::$channel.' ([^ ]+)`', $IRCtext, $T)) {
143 if($T[2] == IRCConn
::$myBotName) {
145 $this->main
->MyConn
->joinChannel(IRCConn
::$channel);
146 $this->main
->MyConn
->privmsg(IRCConn
::$channel,'Merci '.$T[1].' !');
151 // Illegals characters in Nickname
152 private function IllegalChNick ($IRCtext) {
153 if (preg_match('`^:[^ ]+ 432 (.*?)\r?\n`', $IRCtext)){
154 IRCConn
::$myBotName = 'XboT';
155 $this->main
->MyConn
->put('NICK :'.IRCConn
::$myBotName);
159 // Nick already in use
160 private function NickUsed($IRCtext) {
161 if (preg_match('`^:[^ ]+ 433 (.*?)\r?\n`', $IRCtext)){
162 echo "Nick already in use\n\n";
163 $this->main
->MyConn
->newNick(false);
170 * @param string $IRCtext
172 private function CTCP($IRCtext) {
173 if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn
::$myBotName, '`').'(.*?)(VERSION|USERINFO|CLIENTINFO)`', $IRCtext, $T)) {
174 $this->main
->MyConn
->notice($T[1],'RPGBot version '.IRCConn
::$botVersion.' - PHP '.phpversion().' -- par Tornald');
176 if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn
::$myBotName, '`').'(.*?)PING (.*?)\r?\n`', $IRCtext, $T)) {
177 $this->main
->MyConn
->notice($T[1],"PING\1".time()."\1");
179 if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG '.preg_quote(IRCConn
::$myBotName,'`').'(.*?)(TIME)`', $IRCtext, $T)) {
180 $this->main
->MyConn
->notice($T[1],date('Y-m-d H:i:s'));