3 * This file is part of IrBot, irc robot.
4 * Copyright (C) 2007 Bellière Ludovic
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 protected $current_msg_info = false;
24 private $msg, $msg_info;
26 function __construct() {
27 $this->ircmain
= bot
::GetInstance();
30 function parse_get($msg) {
33 if (preg_match("`^ERROR :(Closing Link: )?(.*)\r?$`i", $this->msg
))
35 @fclose
($this->ircmain
->C
);
37 throw new Exception('Closing Link.',1);
40 elseif (preg_match("`^PING :(.*)\r?\n`", $this->msg
, $T))
42 $this->ircmain
->put('PONG '.$T[1]);
43 echo "PING :{$T[1]}\nPONG {$T[1]}\n\n";
45 // Bot kicked, thanks kicker !
46 elseif (preg_match('`^:(.*?)!.*?@.*? KICK '.bot
::$channel.' '.preg_quote(bot
::$myBotName, '`').' :`', $this->msg
, $T))
49 $this->ircmain
->joinChannel(bot
::$channel);
50 $this->ircmain
->privmsg(bot
::$channel,'Merci '.$T[1].' !');
53 // Illegals characters in Nickname : 432
54 // Nick already in use : 433
55 elseif (preg_match('`^:[^ ]+ (001|432|433) (.*?)\r?\n`', $this->msg
,$T))
59 $this->ircmain
->joinChannel(bot
::$channel);
63 $this->ircmain
->newNick('NoNameBot'.rand(0,9).rand(0,9));
66 echo "Nick already in use\n\n";
67 $this->ircmain
->newNick(false);
69 echo "Geeeh, I do not known what this mean ...\n";
70 echo "DEBUG :>".$this->msg
;
75 // :<Owner:T1> PRIVMSG <recever:T2> :<msg:T3>
76 if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG ('.bot
::$myBotName.'|'.bot
::$channel.") :(.*)\r`",$this->msg
,$T)) {
77 $this->msg_info
= array (
79 'from' => $T[1], // owner
80 'to' => $T[2], // message for bot or channel
83 } elseif (preg_match('`^:(.*?)!.*?@.*? NOTICE '.bot
::$myBotName." :(.*)\r`",$this->msg
,$T)) {
84 $this->msg_info
= array (
87 'to' => bot
::$myBotName,
94 * return last privmsg / notice
98 public function get_msg_info() {
99 $temp = $this->msg_info
;
100 $this->msg_info
= array('type'=>false);
105 * Return the current incoming line
109 public function get_msg() {