home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / example7.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  2.4 KB  |  69 lines

  1. <?php
  2. /**
  3.  * $Id: example7.php,v 1.2 2003/01/16 22:27:19 meebey Exp $
  4.  * $Revision: 1.2 $
  5.  * $Author: meebey $
  6.  * $Date: 2003/01/16 22:27:19 $
  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.  
  27. // ---EXAMPLE OF HOW TO USE Net_SmartIRC---
  28. // this code shows how a mini php bot could be written
  29. include_once('../SmartIRC.php');
  30.  
  31. class mybot
  32. {
  33.     function saytime_once(&$irc)
  34.     {
  35.         global $saytime_once_id;
  36.         $irc->message(SMARTIRC_TYPE_CHANNEL, '#smartirc-test', '(once) the time is: '.date('H:i:s'));
  37.         $irc->unregisterTimeid($saytime_once_id);
  38.     }
  39.     
  40.     function saytime(&$irc)
  41.     {
  42.         $irc->message(SMARTIRC_TYPE_CHANNEL, '#smartirc-test', 'the time is: '.date('H:i:s'));
  43.     }
  44.     
  45.     function quit(&$irc, &$ircdata)
  46.     {
  47.         $irc->quit("time to say goodbye...");
  48.     }
  49. }
  50.  
  51. $bot = &new mybot();
  52. $irc = &new Net_SmartIRC();
  53. $irc->setDebug(SMARTIRC_DEBUG_ALL);
  54. $irc->setUseSockets(TRUE);
  55.  
  56. // register saytime() to be called every 30 sec. (30,000 milliseconds)
  57. $irc->registerTimehandler(30000, $bot, 'saytime');
  58.  
  59. // register saytime_once() to be called in 10 sec. (10,000 milliseconds) and save the assigned id
  60. // which is needed for unregistering the timehandler.
  61. $saytime_once_id = $irc->registerTimehandler(10000, $bot, 'saytime_once');
  62.  
  63. $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!quit', $bot, 'quit');
  64. $irc->connect('irc.freenet.de', 6667);
  65. $irc->login('Net_SmartIRC', 'Net_SmartIRC Client '.SMARTIRC_VERSION.' (example7.php)', 8, 'Net_SmartIRC');
  66. $irc->join(array('#smartirc-test','#test'));
  67. $irc->listen();
  68. $irc->disconnect();
  69. ?>