* * Full LGPL License: * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // ---EXAMPLE OF HOW TO USE Net_SmartIRC--- // this code shows how a mini php bot which could be written include_once('SmartIRC.php'); $irc = &new Net_SmartIRC(); class CBGBot { function parse(&$irc, &$data) { $identifier = $x = "."; if (strtolower($data->message) == $x.'test') { $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $data->nick . ': I\'m too sexy to be tested!'); // Theme97: Fixed. =) } if (strtolower($data->message) == $x.'hi') { $hireply = array("Hello!", "Hi...", "Hey."); $count = count($hireply); srand(time()); $random = (rand()%$count); $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $data->nick . ': '.$hireply[$random]); // Theme97: Also fixed. } if (strtolower($data->message) == $x.'time') { $irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $data->nick . ': It is '.date("F j, Y, h:i:s a (T)", time())); // Theme97: ALSO fixed. } } } $bot = new CBGBot(); registerHandles($irc, SMARTIRC_TYPE_CHANNEL, $bot, '.*'); $irc = &new Net_SmartIRC(); $irc->setUseSockets(TRUE); $irc->setDebug(SMARTIRC_DEBUG_IRCMESSAGES); $irc->connect('irc.freenode.net', 6667); $irc->login('CBGBot', 'CBGBot', 0, 'CBGBot'); $irc->join(array('#KAS','#bzmods')); $irc->listen(); $irc->disconnect(); ?>