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

Source for file example3.php

Documentation is available at example3.php

  1. <?php
  2. /**
  3.  * $Id: example3.php 241083 2007-08-11 16:26:08Z amir $
  4.  * $Revision: 241083 $
  5.  * $Author: amir $
  6.  * $Date: 2007-08-12 01:56:08 +0930 (Sun, 12 Aug 2007) $
  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 op_list(&$irc&$data)
  33.     {
  34.         $irc->message(SMARTIRC_TYPE_CHANNEL'#smartirc-test''ops on this channel are:');
  35.         
  36.         $oplist '';
  37.         // Here we're going to get the Channel Operators, the voices and users
  38.         // Method is available too, e.g. $irc->channel['#test']->users will
  39.         // Return the channel's users.
  40.         foreach ($irc->channel['#test']->ops as $key => $value{
  41.             $oplist .= ' '.$key;
  42.         }
  43.         
  44.         // result is send to #smartirc-test (we don't want to spam #test)
  45.         $irc->message(SMARTIRC_TYPE_CHANNEL'#smartirc-test'$oplist);
  46.     }
  47. }
  48.  
  49. $bot &new mybot();
  50. $irc &new Net_SmartIRC();
  51. $irc->setDebug(SMARTIRC_DEBUG_ALL);
  52. $irc->setUseSockets(TRUE);
  53. // Using Channel Syncing we will track all users on all channels we are joined
  54. // (Note. Use setChannelSyncing instead of setChannelSynching)
  55. $irc->setChannelSyncing(TRUE);
  56. $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL'^!ops'$bot'op_list');
  57. $irc->connect('irc.freenet.de'6667);
  58. $irc->login('Net_SmartIRC''Net_SmartIRC Client '.SMARTIRC_VERSION.' (example3.php)'8'Net_SmartIRC');
  59. $irc->join(array('#smartirc-test','#test'));
  60. $irc->listen();
  61. $irc->disconnect();
  62. ?>

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