Net_SmartIRC
[ class tree: Net_SmartIRC ] [ index: Net_SmartIRC ] [ all elements ]

Source for file example6.php

Documentation is available at example6.php

  1. <?php
  2. /**
  3.  * $Id: example6.php 175138 2004-12-20 15:44:35Z meebey $
  4.  * $Revision: 175138 $
  5.  * $Author: meebey $
  6.  * $Date: 2004-12-21 02:14:35 +1030 (Tue, 21 Dec 2004) $
  7.  *
  8.  * Copyright (C) 2002-2003 Mirco "MEEBEY" Bauer <mail@meebey.net> <http://www.meebey.net>
  9.  * 
  10.  * Full LGPL License: <http://www.meebey.net/lgpl.txt>
  11.  * 
  12.  * This library is free software; you can redistribute it and/or
  13.  * modify it under the terms of the GNU Lesser General Public
  14.  * License as published by the Free Software Foundation; either
  15.  * version 2.1 of the License, or (at your option) any later version.
  16.  *
  17.  * This library is distributed in the hope that it will be useful,
  18.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  20.  * Lesser General Public License for more details.
  21.  *
  22.  * You should have received a copy of the GNU Lesser General Public
  23.  * License along with this library; if not, write to the Free Software
  24.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  25.  */
  26. // ---EXAMPLE OF HOW TO USE Net_SmartIRC---
  27. // this code shows how a mini php bot could be written
  28. include_once('Net/SmartIRC.php');
  29.  
  30. class mybot
  31. {
  32.     function onjoin_greeting(&$irc&$data)
  33.     {
  34.         // if _we_ join, don't greet ourself, just jump out via return
  35.         if ($data->nick == $irc->_nick)
  36.             return;
  37.         
  38.         // now check if this is the right channel
  39.         if ($data->channel == '#test')
  40.             // it is, lets greet the joint user
  41.             $irc->message(SMARTIRC_TYPE_CHANNEL'#test''hi '.$data->nick);
  42.     }
  43. }
  44.  
  45. $bot &new mybot();
  46. $irc &new Net_SmartIRC();
  47. $irc->setDebug(SMARTIRC_DEBUG_ALL);
  48. $irc->setUseSockets(TRUE);
  49. $irc->registerActionhandler(SMARTIRC_TYPE_JOIN'.*'$bot'onjoin_greeting');
  50. $irc->connect('irc.freenet.de'6667);
  51. $irc->login('Net_SmartIRC''Net_SmartIRC Client '.SMARTIRC_VERSION.' (example6.php)'8'Net_SmartIRC');
  52. $irc->join(array('#smartirc-test','#test'));
  53. $irc->listen();
  54. $irc->disconnect();
  55. ?>

Documentation generated on Mon, 11 Mar 2019 15:32:23 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.