cvs: pear(BRANCH_0_5_X) /Net_SmartIRC SmartIRC.php

From: Date: Fri, 12 Mar 2004 23:19:51 +0000
Subject: cvs: pear(BRANCH_0_5_X) /Net_SmartIRC SmartIRC.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-17357@lists.php.net to get a copy of this message
meebey Fri Mar 12 18:19:51 2004 EDT Modified files: (Branch: BRANCH_0_5_X) /pear/Net_SmartIRC SmartIRC.php Log: - MFH: php5 fixes (closes: PEAR bug #891) - added objListenFor() method. - added Net_SmartIRC_objListenFor class. http://cvs.php.net/diff.php/pear/Net_SmartIRC/SmartIRC.php?r1=1.54.2.7&r2=1.54.2.8&ty=u Index: pear/Net_SmartIRC/SmartIRC.php diff -u pear/Net_SmartIRC/SmartIRC.php:1.54.2.7 pear/Net_SmartIRC/SmartIRC.php:1.54.2.8 --- pear/Net_SmartIRC/SmartIRC.php:1.54.2.7 Thu Oct 30 03:31:08 2003 +++ pear/Net_SmartIRC/SmartIRC.php Fri Mar 12 18:19:51 2004 @@ -1,9 +1,9 @@ <?php /** - * $Id: SmartIRC.php,v 1.54.2.7 2003/10/30 08:31:08 meebey Exp $ - * $Revision: 1.54.2.7 $ + * $Id: SmartIRC.php,v 1.54.2.8 2004/03/12 23:19:51 meebey Exp $ + * $Revision: 1.54.2.8 $ * $Author: meebey $ - * $Date: 2003/10/30 08:31:08 $ + * $Date: 2004/03/12 23:19:51 $ * * Net_SmartIRC * This is a PHP class for communication with IRC networks, @@ -46,7 +46,7 @@ include_once('SmartIRC/defines.php'); include_once('SmartIRC/irccommands.php'); include_once('SmartIRC/messagehandler.php'); -define('SMARTIRC_VERSION', '0.5.5 ($Revision: 1.54.2.7 $)'); +define('SMARTIRC_VERSION', '0.5.5 ($Revision: 1.54.2.8 $)'); define('SMARTIRC_VERSIONSTRING', 'Net_SmartIRC '.SMARTIRC_VERSION); /** @@ -1162,6 +1162,32 @@ } /** + * waits for a special message type and puts the answer in $result + * + * Creates a special actionhandler for that given TYPE and returns the answer. + * This will only receive the requested type, immediately quit and disconnect from the IRC server. + * Made for showing IRC statistics on your homepage, or other IRC related information. + * This special version of listenFor() stores the whole ircdata object, not just the message! + * + * @param integer $messagetype see in the documentation 'Message Types' + * @return array answer from the IRC server for this $messagetype + * @access public + */ + function objListenFor($messagetype) + { + $objlistenfor = &new Net_SmartIRC_objListenFor(); + $this->registerActionhandler($messagetype, '.*', $objlistenfor, 'handler'); + $this->listen(); + $result = $objlistenfor->result; + + if (isset($objlistenfor)) { + unset($objlistenfor); + } + + return $result; + } + + /** * registers a new actionhandler and returns the assigned id * * Registers an actionhandler in Net_SmartIRC for calling it later. @@ -2182,7 +2208,7 @@ // </private methods> function isError($object) { - return (bool)(is_object($object) && (get_class($object) == 'net_smartirc_error')); + return (bool)(is_object($object) && (strtolower(get_class($object)) == 'net_smartirc_error')); } function &throwError($message) { @@ -2497,6 +2523,33 @@ } } +// so we don't break BC! +/** + * @access public + */ +class Net_SmartIRC_objListenFor +{ + /** + * @var array + * @access public + */ + var $result = array(); + + /** + * stores the received answer into the result array + * + * @param object $irc + * @param object $ircdata + * @return void + */ + function handler(&$irc, &$ircdata) + { + $irc->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER: objListenFor handler called', __FILE__, __LINE__); + $this->result[] = $ircdata; + $irc->disconnect(true); + } +} + class Net_SmartIRC_Error { var $error_msg;

« previous php.pear.cvs (#17357) next »