Changeset 57
- Timestamp:
- 02/12/08 05:39:20 (10 months ago)
- Files:
-
- trunk/Phergie/Bot.php (modified) (4 diffs)
- trunk/Phergie/Client.php (deleted)
- trunk/Phergie/Connection.php (modified) (19 diffs)
- trunk/Phergie/Driver/Abstract.php (moved) (moved from trunk/Phergie/Driver/Driver.php) (17 diffs)
- trunk/Phergie/Driver/Streams.php (modified) (19 diffs)
- trunk/Phergie/Event/Handler.php (modified) (13 diffs)
- trunk/Phergie/Event/Request.php (modified) (18 diffs)
- trunk/Phergie/Event/Response.php (modified) (5 diffs)
- trunk/Phergie/Plugin (moved) (moved from trunk/Phergie/Event/Handler)
- trunk/Phergie/Plugin/Abstract (added)
- trunk/Phergie/Plugin/Acronym.php (modified) (4 diffs)
- trunk/Phergie/Plugin/AdminCommand.php (modified) (5 diffs)
- trunk/Phergie/Plugin/Autojoin.php (modified) (1 diff)
- trunk/Phergie/Plugin/Command.php (modified) (3 diffs)
- trunk/Phergie/Plugin/Cron.php (modified) (1 diff)
- trunk/Phergie/Plugin/DNSLookup.php (modified) (1 diff)
- trunk/Phergie/Plugin/Daddy.php (modified) (1 diff)
- trunk/Phergie/Plugin/Debug.php (modified) (1 diff)
- trunk/Phergie/Plugin/Drink.php (modified) (8 diffs)
- trunk/Phergie/Plugin/JoinPart.php (modified) (1 diff)
- trunk/Phergie/Plugin/Karma.php (modified) (9 diffs)
- trunk/Phergie/Plugin/Lart.php (modified) (10 diffs)
- trunk/Phergie/Plugin/Logging.php (modified) (15 diffs)
- trunk/Phergie/Plugin/Math.php (modified) (1 diff)
- trunk/Phergie/Plugin/Nickserv.php (modified) (1 diff)
- trunk/Phergie/Plugin/PHPLookup.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Pong.php (modified) (1 diff)
- trunk/Phergie/Plugin/Quit.php (modified) (1 diff)
- trunk/Phergie/Plugin/RSSParser.php (modified) (1 diff)
- trunk/Phergie/Plugin/Say.php (modified) (1 diff)
- trunk/Phergie/Plugin/TLDLookup.php (modified) (2 diffs)
- trunk/Phergie/Plugin/URLTitles.php (modified) (1 diff)
- trunk/Phergie/Plugin/UrbanDictionary.php (modified) (1 diff)
- trunk/Phergie/Plugin/Users.php (modified) (1 diff)
- trunk/Phergie/README (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Bot.php
r56 r57 28 28 * @const string 29 29 */ 30 define('PHERGIE_VERSION', '1.0. 1');30 define('PHERGIE_VERSION', '1.0.2'); 31 31 32 32 /** … … 37 37 */ 38 38 define('PHERGIE_INI', 'phergie.ini'); 39 40 /**41 * @see Phergie_Client42 */43 require_once 'Phergie/Client.php';44 39 45 40 /** … … 102 97 if (isset($config['driver'])) { 103 98 $driver = ucfirst(strtolower($config['driver'])); 104 require_once 'Phergie/Client/' . $driver . '.php';105 $class = 'Phergie_Client_' . $driver;106 $client = new Phergie_Client($conn, new $class());107 99 } else { 108 $ client = new Phergie_Client($conn);100 $driver = 'Streams'; 109 101 } 102 require_once 'Phergie/Driver/' . $driver . '.php'; 103 $client = new ${'Phergie_Driver_' . $driver}(); 110 104 111 105 foreach ($config as $setting => $value) { … … 135 129 /** 136 130 * Set up event handlers 137 *138 * @todo Move abstract classes to a separate directory so reflection does not139 * have to be used here?140 131 */ 141 $iterator = new DirectoryIterator('Phergie/ Event/Handler');132 $iterator = new DirectoryIterator('Phergie/Plugin'); 142 133 foreach ($iterator as $entry) { 143 134 if ($iterator->isFile() 144 135 && substr($entry, -4) == '.php' 145 136 && ($all xor in_array(substr($entry, 0, -4), $exclude))) { 146 require_once 'Phergie/Event/Handler/' . $entry; 147 $class = 'Phergie_Event_Handler_' . str_replace('.php', '', $entry); 148 $reflector = new ReflectionClass($class); 149 if ($reflector->isInstantiable()) { 150 $client->addEventHandler(new $class($client)); 151 } 137 require_once 'Phergie/Plugin/' . $entry; 138 $class = 'Phergie_Plugin_' . str_replace('.php', '', $entry); 152 139 } 153 140 } trunk/Phergie/Connection.php
r1 r57 17 17 * @var string 18 18 */ 19 protected $ _server;19 protected $server; 20 20 21 21 /** … … 24 24 * @var int 25 25 */ 26 protected $ _port;26 protected $port; 27 27 28 28 /** … … 31 31 * @var string 32 32 */ 33 protected $ _username;33 protected $username; 34 34 35 35 /** … … 38 38 * @var string 39 39 */ 40 protected $ _realName;40 protected $realName; 41 41 42 42 /** … … 45 45 * @var string 46 46 */ 47 protected $ _nick;47 protected $nick; 48 48 49 49 /** … … 52 52 * @var string 53 53 */ 54 protected $ _password;54 protected $password; 55 55 56 56 /** … … 59 59 public function __construct() 60 60 { 61 $this-> _port = 6667;61 $this->port = 6667; 62 62 } 63 63 … … 69 69 public function setServer($server) 70 70 { 71 $this-> _server = $server;71 $this->server = $server; 72 72 } 73 73 … … 79 79 public function getServer() 80 80 { 81 return $this-> _server;81 return $this->server; 82 82 } 83 83 … … 93 93 } 94 94 95 $this-> _port = $port;95 $this->port = $port; 96 96 } 97 97 … … 103 103 public function getPort() 104 104 { 105 return $this-> _port;105 return $this->port; 106 106 } 107 107 … … 113 113 public function setUsername($username) 114 114 { 115 $this-> _username = $username;115 $this->username = $username; 116 116 } 117 117 … … 123 123 public function getUsername() 124 124 { 125 return $this-> _username;125 return $this->username; 126 126 } 127 127 … … 133 133 public function setRealName($realName) 134 134 { 135 $this-> _realName = $realName;135 $this->realName = $realName; 136 136 } 137 137 … … 143 143 public function getRealName() 144 144 { 145 return $this-> _realName;145 return $this->realName; 146 146 } 147 147 … … 153 153 public function setNick($nick) 154 154 { 155 $this-> _nick = $nick;155 $this->nick = $nick; 156 156 } 157 157 … … 163 163 public function getNick() 164 164 { 165 return $this-> _nick;165 return $this->nick; 166 166 } 167 167 … … 173 173 public function setPassword($password) 174 174 { 175 $this-> _password = $password;175 $this->password = $password; 176 176 } 177 177 … … 183 183 public function getPassword() 184 184 { 185 return $this-> _password;185 return $this->password; 186 186 } 187 187 } trunk/Phergie/Driver/Abstract.php
r31 r57 20 20 * from IRC server. 21 21 */ 22 interface Phergie_Client_Driver 22 abstract class Phergie_Driver_Abstract 23 23 { 24 24 /** 25 * Associative array mapping configuration setting names to their 26 * respective values 27 * 28 * @var array 29 */ 30 protected $config; 31 32 /** 33 * Returns the value associated with a specified configuration setting. 34 * 35 * @param string $name Name of the setting 36 * @return string Value of the setting, or NULL if the setting is not set 37 */ 38 public final function getIni($name) 39 { 40 if (!isset($this->config[strtolower($name)])) { 41 return null; 42 } 43 return $this->config[strtolower($name)]; 44 } 45 46 /** 47 * Sets the value of a specified configuration setting, overwriting any 48 * existing value for that setting. 49 * 50 * @param string $name Name of the setting 51 * @param string $value New value for the setting 52 * @return void 53 */ 54 public final function setIni($name, $value) 55 { 56 $this->config[strtolower($name)] = $value; 57 } 58 59 /** 60 * Parses a IRC hostmask and sets nick, user and host bits 61 * 62 * @param string $hostmask Hostmask to parse 63 * @param string $nick Container for the nick 64 * @param string $user Container for the username 65 * @param string $host Container for the hostname 66 */ 67 public function parseHostmask($hostmask, &$nick, &$user, &$host) 68 { 69 if (preg_match('/^([^!@]+)!([^@]+)@(.*)$/', $hostmask, $match) > 0) { 70 list (, $nick, $user, $host) = $match; 71 } else { 72 $host = $hostmask; 73 } 74 } 75 76 /** 25 77 * Adds a set of callbacks for events received from the server. 26 78 * 27 79 * @param Phergie_Event_Handler $handler 28 */ 29 public function addEventHandler(Phergie_Event_Handler $handler); 30 31 /** 32 * Establishes a connection to the server. 33 * 34 * @param Phergie_Connection $connection Connection information 35 * @throws Phergie_Exception A connectivity issue occurred 36 */ 37 public function connect(Phergie_Connection $connection); 38 39 /** 40 * Terminates any existing connection to the server. Note that this 41 * should never be used by an event handler; doQuit should be called 42 * instead. 43 */ 44 public function disconnect(); 45 46 /** 47 * Returns whether or not the client is currently connected to the server. 48 * 49 * @return TRUE if the client is connected, FALSE otherwise 50 */ 51 public function isConnected(); 80 * @return void 81 */ 82 public abstract function addEventHandler(Phergie_Event_Handler $handler); 52 83 53 84 /** … … 55 86 * the server and processes them until the connection is terminated. 56 87 * 88 * @param Phergie_Connection $conn Client connection information 57 89 * @throws Phergie_Exception A runtime issue occurred 58 */ 59 public function run(); 60 61 /** 62 * Controls debugging output. 63 * 64 * @param string $message Debugging message 65 */ 66 public function debug($message); 90 * @return void 91 */ 92 public abstract function run(Phergie_Connection $conn); 93 94 /** 95 * Sends a debugging message to stdout or a log file depending on 96 * debugging settings. 97 * 98 * @param string $message Message to log 99 * @return void 100 */ 101 public abstract function debug($message); 102 103 /** 104 * Enables sending debugging output to stdout. 105 * 106 * @return void 107 */ 108 public abstract function enableDebugging(); 109 110 /** 111 * Enables sending debugging output to a specified file. 112 * 113 * @param string $path Path to the file 114 * @return void 115 */ 116 public abstract function enableLogging($path); 67 117 68 118 /** … … 70 120 * 71 121 * @param string $reason Reason for connection termination (optional) 72 */ 73 public function doQuit($reason = null); 122 * @return void 123 */ 124 public abstract function doQuit($reason = null); 74 125 75 126 /** … … 78 129 * @param string $channel Name of the channel to join 79 130 * @param string $keys Channel key if needed (optional) 80 */ 81 public function doJoin($channel, $key = null); 131 * @return void 132 */ 133 public abstract function doJoin($channel, $key = null); 82 134 83 135 /** … … 85 137 * 86 138 * @param string $channel Name of the channel to leave 87 */ 88 public function doPart($channel); 139 * @return void 140 */ 141 public abstract function doPart($channel); 89 142 90 143 /** … … 93 146 * @param string $nick Nick of the user to invite 94 147 * @param string $channel Name of the channel 95 */ 96 public function doInvite($nick, $channel); 148 * @return void 149 */ 150 public abstract function doInvite($nick, $channel); 97 151 98 152 /** … … 100 154 * 101 155 * @param string $channels Comma-delimited list of one or more channels 102 */ 103 public function doNames($channels); 156 * @return void 157 */ 158 public abstract function doNames($channels); 104 159 105 160 /** … … 109 164 * to which the response should be restricted 110 165 * (optional) 111 */ 112 public function doList($channels = null); 166 * @return void 167 */ 168 public abstract function doList($channels = null); 113 169 114 170 /** … … 117 173 * @param string $channel Name of the channel 118 174 * @param string $topic New topic to assign (optional) 119 */ 120 public function doTopic($channel, $topic = null); 175 * @return void 176 */ 177 public abstract function doTopic($channel, $topic = null); 121 178 122 179 /** … … 125 182 * @param string $target Channel name or user nick 126 183 * @param string $mode New mode to assign (optional) 127 */ 128 public function doMode($target, $mode = null); 184 * @return void 185 */ 186 public abstract function doMode($target, $mode = null); 129 187 130 188 /** … … 132 190 * 133 191 * @param string $nick New nick to assign 134 */ 135 public function doNick($nick); 192 * @return void 193 */ 194 public abstract function doNick($nick); 136 195 137 196 /** … … 139 198 * 140 199 * @param string $nick 141 */ 142 public function doWhois($nick); 200 * @return void 201 */ 202 public abstract function doWhois($nick); 143 203 144 204 /** … … 147 207 * @param string $target Channel name or user nick 148 208 * @param string $text Text of the message to send 149 */ 150 public function doPrivmsg($target, $text); 209 * @return void 210 */ 211 public abstract function doPrivmsg($target, $text); 151 212 152 213 /** … … 155 216 * @param string $target Channel name or user nick 156 217 * @param string $text Text of the notice to send 157 */ 158 public function doNotice($target, $text); 218 * @return void 219 */ 220 public abstract function doNotice($target, $text); 159 221 160 222 /** … … 164 226 * @param string $channel Channel name 165 227 * @param string $reason Reason for the kick (optional) 166 */ 167 public function doKick($nick, $channel, $reason = null); 228 * @return void 229 */ 230 public abstract function doKick($nick, $channel, $reason = null); 168 231 169 232 /** … … 171 234 * 172 235 * @param string $daemon Daemon from which the original request originates 173 */ 174 public function doPong($daemon); 236 * @return void 237 */ 238 public abstract function doPong($daemon); 175 239 176 240 /** … … 179 243 * @param string $target Channel name or user nick 180 244 * @param string $text Text of the action to perform 181 */ 182 public function doCtcpAction($target, $text); 245 * @return void 246 */ 247 public abstract function doCtcpAction($target, $text); 183 248 } trunk/Phergie/Driver/Streams.php
r42 r57 2 2 3 3 /** 4 * @see Phergie_ Client_Driver4 * @see Phergie_Driver_Abstract 5 5 */ 6 require_once 'Phergie/ Client/Driver.php';6 require_once 'Phergie/Driver/Abstract.php'; 7 7 8 8 /** 9 9 * Provides a socket-based client driver. 10 10 */ 11 class Phergie_ Client_Streams implements Phergie_Client_Driver11 class Phergie_Driver_Streams extends Phergie_Driver_Abstract 12 12 { 13 /**14 * Flag to enable debugging mode15 *16 * @var bool17 */18 protected static $_debug = true;19 20 /**21 * Define the logfile, nothing will be logged if set to null22 *23 * @var null|string24 */25 protected static $_log = null;26 27 13 /** 28 14 * Names of commands that can be issued by callbacks ordered by … … 31 17 * @var array 32 18 */ 33 protected static $_priority = array(19 protected $priority = array( 34 20 'pass', 35 21 'nick', … … 59 45 60 46 /** 47 * Flag to enable debugging mode 48 * 49 * @var bool 50 */ 51 protected $debug; 52 53 /** 54 * Define the logfile, nothing will be logged if set to null 55 * 56 * @var null|string 57 */ 58 protected $log; 59 60 /** 61 61 * Flag indicating whether or not the client is currently connected to 62 62 * the server … … 64 64 * @var bool 65 65 */ 66 protected $ _connected;66 protected $connected; 67 67 68 68 /** … … 71 71 * @var resource 72 72 */ 73 protected $ _socket;73 protected $socket; 74 74 75 75 /** … … 78 78 * @var array 79 79 */ 80 protected $ _handlers;80 protected $handlers; 81 81 82 82 /** … … 86 86 * @var bool 87 87 */ 88 protected $ _queueing;88 protected $queueing; 89 89 90 90 /** … … 94 94 * @var array 95 95 */ 96 protected $ _queue;96 protected $queue; 97 97 98 98 /** … … 101 101 public function __construct() 102 102 { 103 $this->_connected = false; 104 $this->_handlers = array(); 105 $this->_queueing = false; 106 $this->_queue = array(); 107 } 108 109 /** 110 * Controls debugging output. 111 * 112 * @param string $message Debugging message 103 $this->debug = false; 104 $this->log = null; 105 $this->connected = false; 106 $this->handlers = array(); 107 $this->queueing = false; 108 $this->queue = array(); 109 } 110 111 /** 112 * Sends a debugging message to stdout or a log file depending on 113 * debugging settings. 114 * 115 * @param string $message Message to log 116 * @return void 113 117 */ 114 118 public function debug($message) 115 119 { 116 if ( self::$_debug) {120 if ($this->debug) { 117 121 echo $message . "\n"; 118 122 } 119 if ( self::$_log) {120 file_put_contents( self::$_log, $message."\n", FILE_APPEND);123 if ($this->log) { 124 file_put_contents($this->log, $message."\n", FILE_APPEND); 121 125 } 122 126 } 123 127 124 128 /** 129 * Enables sending debugging output to stdout. 130 * 131 * @return void 132 */ 133 public function enableDebugging() 134 { 135 $this->debug = true; 136 } 137 138 /** 139 * Enables sending debugging output to a specified file. 140 * 141 * @param string $path Path to the file 142 * @return void 143 */ 144 public function enableLogging($path) 145 { 146 $this->log = $path; 147 } 148 149 /** 125 150 * Adds a set of callbacks for events received from the server. 126 151 * … … 131 156 $handler->init(); 132 157 133 $this->_handlers[] = $handler; 134 } 135 136 /** 137 * Establishes a connection to the server. 138 * 139 * @param Phergie_Connection $connection 140 */ 141 public function connect(Phergie_Connection $connection) 142 { 143 $server = $connection->getServer(); 144 $port = $connection->getPort(); 145 $username = $connection->getUsername(); 146 $realName = $connection->getRealName(); 147 $password = $connection->getPassword(); 148 149 $this->_socket = stream_socket_client('tcp://' . $server . ':' . $port, $errno, $errstr); 150 151 if ($this->_socket === false) { 152 throw new Phergie_Exception('Socket error occurred: ' . $errno . ' ' . $errstr); 153 } 154 155 if ($password !== null) { 156 $this->send('PASS', array($password)); 157 } 158 $this->send('USER', array($username, $server, $server, $realName)); 159 $this->doNick($connection->getNick()); 160 161 $this->_connected = true; 162 } 163 164 /** 165 * Terminates any existing connection to the server. 166 */ 167 public function disconnect() 168 { 169 if ($this->_connected) { 170 fclose($this->_socket); 171 $this->_connected = false; 172 } 173 } 174 175 /** 176 * Returns whether or not the client is currently connected to the server. 177 * 178 * @return TRUE if the client is connected, FALSE otherwise 179 */ 180 public function isConnected() 181 { 182 return $this->_connected; 158 $this->handlers[] = $handler; 183 159 } 184 160 … … 186 162 * Executes a continuous loop in which the client listens for events from 187 163 * the server and processes them until the connection is terminated. 188 */ 189 public function run() 190 { 191 while($this->isConnected()) { 192 $this->_queue = array(); 193 $this->_queueing = true; 164 * 165 * @param Phergie_Connection $conn Client connection information 166 * @throws Phergie_Exception A runtime issue occurred 167 * @return void 168 */ 169 public function run(Phergie_Connection $conn) 170 { 171 $server = $conn->getServer(); 172 173 $this->socket = stream_socket_client('tcp://' . $server . ':' . $conn->getPort(), $errno, $errstr); 174 if ($this->socket === false) { 175 throw new Phergie_Exception('Socket error occurred: ' . $errno . ' ' . $errstr); 176 } 177 178 if ($password !== null) { 179 $this->send('PASS', array($conn->getPassword())); 180 } 181 182 $this->send('USER', array($conn->getUsername(), $server, $server, $conn->getRealName())); 183 $this->doNick($conn->getNick()); 184 185 $this->connected = true; 186 unset($server); 187 188 while($this->connected) { 189 $this->queue = array(); 190 $this->queueing = true; 194 191 $event = $this->receive(); 195 if ($event instanceof Phergie_Event_Response) { 196 foreach ($this->_handlers as $handler) { 197 $handler->onResponse($event); 192 foreach ($this->handlers as $handler) { 193 $handler->setEvent($event); 194 if ($event instanceof Phergie_Event_Response) { 195 $handler->onResponse(); 196 } else { 197 $handler->${'on' . ucfirst($event->getType())}(); 198 198 } 199 } else { 200 foreach ($this->_handlers as $handler) { 201 $method = 'on' . ucfirst($event->getType()); 202 $handler->$method($event); 203 } 204 } 205 $this->_queueing = false; 206 foreach (self::$_priority as $command) { 207 if (isset($this->_queue[$command])) { 208 foreach ($this->_queue[$command] as $arguments) { 199 } 200 $this->queueing = false; 201 foreach ($this->priority as $command) { 202 if (isset($this->queue[$command])) { 203 foreach ($this->queue[$command] as $arguments) { 209 204 $this->send($command, $arguments); 210 205 } 211 206 } 212 207 } 213 if (isset($this-> _queue['quit'])) {214 if (count($this-> _queue['quit'][0]) > 0) {215 $reason = $this-> _queue['quit'][0][0];208 if (isset($this->queue['quit'])) { 209 if (count($this->queue['quit'][0]) > 0) { 210 $reason = $this->queue['quit'][0][0]; 216 211 } else { 217 212 $reason = null; 218 213 } 219 foreach ($this-> _handlers as $handler) {214 foreach ($this->handlers as $handler) { 220 215 $handler->shutdown(); 221 216 } 222 217 $this->doQuit($reason); 223 $this->disconnect(); 224 } 225 unset($this->_queue, $event, $command, $arguments); 218 fclose($this->socket); 219 $this->connected = false; 220 } 221 unset($this->queue, $event, $command, $arguments); 226 222 } 227 223 } … … 250 246 $buffer = ''; 251 247 while (empty ($buffer)) { 252 $buffer = rtrim(fgets($this-> _socket));248 $buffer = rtrim(fgets($this->socket)); 253 249 } 254 250 $this->debug('server -> ' . $buffer); … … 310 306 public function send($command, array $arguments = array()) 311 307 { 312 if ($this-> _queueing) {313 if (!isset($this-> _queue[$command])) {314 $this-> _queue[$command] = array();315 } 316 $this-> _queue[$command][] = $arguments;308 if ($this->queueing) { 309 if (!isset($this->queue[$command])) { 310 $this->queue[$command] = array(); 311 } 312 $this->queue[$command][] = $arguments; 317 313 } else { 318 314 $buffer = strtoupper($command); … … 322 318 $buffer .= ' ' . implode(' ', $arguments); 323 319 } 324 fwrite($this-> _socket, $buffer . "\r\n");320 fwrite($this->socket, $buffer . "\r\n"); 325 321 $this->debug('client -> ' . $buffer); 326 322 } 327 323 } 328 329 /**330 * Parses a IRC host mask and sets nick, user and host bits331 *332 * @param string $hostmask Hostmask to parse333 * @param string $nick This variable will be filled with the nick part334 * @param string $user This variable will be filled with the user part335 * @param string $host This variable will be filled with the host part336 */337 public function parseHostmask($hostmask, &$nick, &$user, &$host)338 {339 if (preg_match('/^([^!@]+)!([^@]+)@(.*)$/', $hostmask, $match) > 0) {340 list (, $nick, $user, $host) = $match;341 } else {342 $host = $hostmask;343 }344 }345 324 346 325 /** … … 369 348 370 349 $this->send(Phergie_Event_Request::TYPE_JOIN, $arguments); 371 372 unset($arguments);373 350 } 374 351 … … 420 397 421 398 $this->send(Phergie_Event_Request::TYPE_LIST, $arguments); 422 423 unset($arguments);424 399 } 425 400 … … 439 414 440 415 $this->send(Phergie_Event_Request::TYPE_TOPIC, $arguments); 441 442 unset($arguments);443 416 } 444 417 … … 458 431 459 432 $this->send(Phergie_Event_Request::TYPE_MODE, $arguments); 460 461 unset($arguments);462 433 } 463 434 … … 520 491 521 492 $this->send(Phergie_Event_Request::TYPE_KICK, $arguments); 522 523 unset($arguments);524 493 } 525 494 trunk/Phergie/Event/Handler.php
r43 r57 2 2 3 3 /** 4 * @see Phergie_ Client5 */ 6 require_once 'Phergie/ Client.php';4 * @see Phergie_Driver_Abstract 5 */ 6 require_once 'Phergie/Driver/Abstract.php'; 7 7 8 8 /** … … 25 25 * Reference back to the client used to initiate commands 26 26 * 27 * @var Phergie_Client 28 */ 29 protected $_client; 27 * @var Phergie_Driver_Abstract 28 */ 29 protected $client; 30 31 /** 32 * Short class name 33 * 34 * @var string 35 */ 36 protected $name; 37 38 /** 39 * Last intercepted event 40 * 41 * @var Phergie_Event_Request|Phergie_Event_Response 42 */ 43 protected $event; 30 44 31 45 /** 32 46 * Sets a reference to the client used to initiate commands. 33 47 * 34 * @param Phergie_Client $client 35 */ 36 final public function __construct(Phergie_Client $client) 37 { 38 $this->_client = $client; 48 * @param Phergie_Driver_Abstract $client 49 * @return void 50 */ 51 final public function __construct(Phergie_Driver_Abstract $client) 52 { 53 $this->client = $client; 54 55 $name = get_class($this); 56 $this->name = substr($name, strrpos($name, '_') + 1); 39 57 } 40 58 … … 46 64 public function getName() 47 65 { 48 return substr(get_class($this), 22);66 return $this->name; 49 67 } 50 68 … … 55 73 * @param string $plugin Name of the plugin, defaults to the current 56 74 * plugin (optional) 57 * @return string Value of the setting75 * @return string 58 76 */ 59 77 public function getIni($setting, $plugin = null) … … 62 80 $plugin = $this->getName(); 63 81 } 64 $value = $this-> _client->getIni($plugin . '.' . $setting);82 $value = $this->client->getIni($plugin . '.' . $setting); 65 83 if (!$value) { 66 $value = $this-> _client->getIni($setting);84 $value = $this->client->getIni($setting); 67 85 } 68 86 return $value; … … 76 94 * @param string $plugin Name of the plugin, defaults to the current 77 95 * plugin (optional) 96 * @return void 78 97 */ 79 98 public function setIni($setting, $value, $plugin = null) … … 82 101 $plugin = $this->getName(); 83 102 } 84 $this->_client->setIni($plugin . '.' . $setting, $value); 103 $this->client->setIni($plugin . '.' . $setting, $value); 104 } 105 106 /** 107 * Stores the last intercepted event. Should only be called by drivers. 108 * 109 * @param Phergie_Event_Request|Phergie_Event_Response $event 110 * @return void 111 */ 112 public function setEvent($event) 113 { 114 $this->event = $event; 115 } 116 117 /** 118 * Returns the channel name or user nick representing the source of the 119 * last intercepted event. 120 * 121 &nb