3 * This file is part of IrBot, irc robot.
4 * Copyright (C) 2007-2008 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/>.
23 const CTCP_CLIENTINFO
= 'CLIENTINFO';
24 const CTCP_VERSION
= 'VERSION';
25 const CTCP_USERINFO
= 'USERINFO';
26 const CTCP_TIME
= 'TIME';
27 const CTCP_PING
= 'PING';
37 * IRCMain object for config data
47 public function __construct(Event
$event, IRCMain
$ircmain) {
48 $this->_event
= $event;
49 $this->_ircmain
= $ircmain;
52 function _stripMessage() {
53 $this->ctcpNotice
= str_replace(chr(001), "", $this->_event
->getDataMessage());
56 function _setRequest() {
58 self
::_stripMessage();
60 if (strstr($this->ctcpNotice
,' ') === true) {
61 list($this->ctcpRequest
,$this->ctcpQuery
) = explode(" ",$this->ctcpNotice
);
62 $this->ctcpRequest
= trim($this->ctcpRequest
);
64 $this->ctcpRequest
= trim($this->ctcpNotice
);
70 * Return the ctcp responce
74 function getResponce() {
75 switch ($this->ctcpRequest
) {
76 case self
::CTCP_CLIENTINFO
:
77 return 'PING VERSION TIME USERINFO CLIENTINFO';
80 case self
::CTCP_VERSION
:
81 return 'IrBot version '.$this->_ircmain
->getConfig('version').' - PHP '.phpversion().' -- on http://irbot.irstat.org';
84 case self
::CTCP_USERINFO
:
89 return date('Y-m-d H:i:s');
93 return "PING " . $query;
96 return "UNKNOWN CTCP REQUEST : '$this->ctcpRequest'";