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

Source for file example5.php

Documentation is available at example5.php

  1. <?php
  2. /**
  3.  * $Id$
  4.  * $Revision$
  5.  * $Author$
  6.  * $Date$
  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.     private $irc;
  33.     private $handlerid;
  34.  
  35.     public function __construct($irc)
  36.     {
  37.         $this->irc $irc;
  38.         $this->handlerid $irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL'^!kick'array($this'kick'));
  39.     }
  40.  
  41.     public function __destruct()
  42.     {
  43.         $this->irc->unregisterActionId($this->handlerid);
  44.     }
  45.  
  46.     public function kick($irc$data)
  47.     {
  48.         // we need the nickname parameter
  49.         if(isset($data->messageex[1])) {
  50.             $nickname $data->messageex[1];
  51.             $channel $data->channel;
  52.             $irc->kick($channel$nickname);
  53.         else {
  54.             $irc->message($data->type$data->nick'wrong parameter count');
  55.             $irc->message($data->type$data->nick'usage: !kick $nickname');
  56.         }
  57.     }
  58. }
  59.  
  60. $irc = new Net_SmartIRC(array(
  61.     'DebugLevel' => SMARTIRC_DEBUG_ALL,
  62. ));
  63. $bot = new MyBot($irc);
  64. $irc->connect('chat.freenode.net'6667);
  65. $irc->login('Net_SmartIRC''Net_SmartIRC Client '.SMARTIRC_VERSION.' (example5.php)'8'Net_SmartIRC');
  66. $irc->join('#test');
  67. $irc->listen();
  68. $irc->disconnect();

Documentation generated on Thu, 25 Jul 2019 12:49:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.