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 echo debug() ?
"IRC:: -> ".$msg."\n" : '';
35 if (preg_match("`^ERROR :(Closing Link: )?(.*)$`i", $this->msg
))
37 $this->ircmain
->disconnect('ERROR: Closing Link');
39 throw new Exception('Closing Link.',1);
42 elseif (ereg("^PING ", $this->msg
)) {
43 $pong = split(':',$this->msg
);
44 $this->ircmain
->put('PONG '.$pong[1]);
45 echo "PING :{$pong[1]}\nPONG {$pong[1]}\n\n";
47 // Bot kicked, thanks kicker !
48 elseif (preg_match('`^:(.*?)!.*?@.*? KICK '.bot
::$channel.' '.preg_quote(bot
::$myBotName, '`').' :`', $this->msg
, $T))
51 $this->ircmain
->joinChannel(bot
::$channel);
52 $this->ircmain
->privmsg(bot
::$channel,'Merci '.$T[1].' !');
55 // Illegals characters in Nickname : 432
56 // Nick already in use : 433
57 elseif (preg_match('`^:[^ ]+ (001|432|433) (.*?)`', $this->msg
,$T))
61 $this->ircmain
->joinChannel(bot
::$channel);
65 $this->ircmain
->newNick('NoNameBot'.rand(0,9).rand(0,9));
68 echo "Nick already in use\n\n";
69 $this->ircmain
->newNick(false);
71 echo "Geeeh, I do not known what this mean ...\n";
72 echo "DEBUG :>".$this->msg
;
77 // :<Owner:T1> PRIVMSG <recever:T2> :<msg:T3>
78 if (preg_match('`^:(.*?)!.*?@.*? PRIVMSG ('.bot
::$myBotName.'|'.bot
::$channel.") :(.*)`",$this->msg
,$T)) {
79 $this->msg_info
= array (
81 'from' => $T[1], // owner
82 'to' => $T[2], // message for bot or channel
85 } elseif (preg_match('`^:(.*?)!.*?@.*? NOTICE '.bot
::$myBotName." :(.*)`",$this->msg
,$T)) {
86 $this->msg_info
= array (
89 'to' => bot
::$myBotName,
96 * return last privmsg / notice
100 public function get_msg_info() {
101 $temp = $this->msg_info
;
102 $this->msg_info
= array('type'=>false);
107 * Return the current incoming line
111 public function get_msg() {