Changeset 82
- Timestamp:
- 02/27/08 05:40:00 (5 years ago)
- Location:
- trunk/Phergie
- Files:
-
- 1 added
- 5 modified
-
Bot.php (modified) (1 diff)
-
Driver/Abstract.php (modified) (1 diff)
-
Driver/Streams.php (modified) (2 diffs)
-
Plugin/Abstract/Base.php (modified) (5 diffs)
-
Plugin/Nickserv.php (modified) (2 diffs)
-
Plugin/Toggle.php (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Phergie/Bot.php
r78 r82 133 133 $name = substr($entry, 0, -4); 134 134 if ($all xor in_array(strtolower($name), $include)) { 135 $plugins[] = $name; 135 $plugins[$name] = true; 136 } else { 137 $plugins[$name] = false; 136 138 } 137 139 } 138 140 } 139 sort($plugins); 141 142 ksort($plugins); 140 143 141 144 unset ($iterator, $entry, $name, $all, $include); 142 145 143 foreach ($plugins as $plugin ) {146 foreach ($plugins as $plugin=>$enabled) { 144 147 require_once 'Phergie/Plugin/' . $plugin . '.php'; 145 $class = 'Phergie_Plugin_' . $plugin; 148 $class = 'Phergie_Plugin_' . $plugin; 146 149 if (call_user_func(array($class, 'checkDependencies'), $plugins)) { 147 150 $instance = new $class($client); 151 $instance->enabled = $enabled; 148 152 $client->addPlugin($instance); 149 $client->debug('Loaded ' . $plugin );153 $client->debug('Loaded ' . $plugin . ($enabled ? '':' [Disabled]')); 150 154 } else { 151 155 $client->debug('Unable to load ' . $plugin); -
trunk/Phergie/Driver/Abstract.php
r68 r82 88 88 public abstract function addPlugin(Phergie_Plugin_Abstract_Base $plugin); 89 89 90 /** 91 * Returns a plugin instance 92 * 93 * @param $plugin The plugin class name (without the Phergie_Plugin_ prefix) 94 * @return Phergie_Plugin_Abstract_Base 95 */ 96 public abstract function getInstance($plugin); 97 90 98 /** 91 99 * Executes a continuous loop in which the client listens for events from -
trunk/Phergie/Driver/Streams.php
r76 r82 93 93 $plugin->init(); 94 94 95 $this->plugins[] = $plugin; 96 } 95 $this->plugins[strtolower($plugin->getName())] = $plugin; 96 } 97 98 /** 99 * Returns a plugin instance 100 * 101 * @param $plugin The plugin class name (without the Phergie_Plugin_ prefix) 102 * @return Phergie_Plugin_Abstract_Base 103 */ 104 public function getInstance($plugin) 105 { 106 if (isset($this->plugins[strtolower($plugin)])) 107 return $this->plugins[strtolower($plugin)]; 108 return false; 109 } 97 110 98 111 /** … … 220 233 221 234 foreach ($this->plugins as $plugin) { 235 if ($plugin->enabled === false) { // Skip disabled plugins 236 continue; 237 } 222 238 $plugin->setEvent($event); 223 239 if ($event instanceof Phergie_Event_Response) { -
trunk/Phergie/Plugin/Abstract/Base.php
r79 r82 46 46 47 47 /** 48 * Reference to the current instance of the plugin, used to make its49 * non-static methods accessible to other plugins50 *51 * @var Phergie_Plugin_Abstract_Base52 */53 protected static $instance;54 55 /**56 48 * Short class name 57 49 * … … 68 60 69 61 /** 62 * Flag indicating whether or not the plugin is enabled and receives events 63 * 64 * @var bool 65 */ 66 public $enabled = true; 67 68 /** 69 * Flag indicating whether or not the plugin is muted and can output events 70 * 71 * @var bool 72 */ 73 public $muted = false; 74 75 /** 70 76 * Sets a reference to the client used to initiate commands. 71 77 * … … 75 81 final public function __construct(Phergie_Driver_Abstract $client) 76 82 { 77 self::$instance = $this;78 79 83 $this->client = $client; 80 84 … … 210 214 211 215 /** 212 * Returns a reference to the instance of the current plugin.213 *214 * @return Phergie_Plugin_Abstract_Base215 */216 public static function getInstance()217 {218 return self::$instance;219 }220 221 /**222 216 * Returns whether or not the current environment meets the requirements 223 217 * of the plugin in order for it to be run, including the PHP version, … … 354 348 public function __call($method, $arguments) 355 349 { 350 if ($this->muted && substr($method, 0, 2) === 'do') { // Silence output calls if the plugin is muted 351 return false; 352 } 356 353 return call_user_func_array(array($this->client, $method), $arguments); 357 354 } -
trunk/Phergie/Plugin/Nickserv.php
r78 r82 42 42 * Returns whether or not the plugin's dependencies are met. 43 43 * 44 * @param array $plugins List of short names for plugins that the 44 * @param array $plugins List of short names for plugins that the 45 45 * bootstrap file intends to instantiate 46 46 * @return bool TRUE if the plugins dependencies are met, FALSE otherwise … … 95 95 public function onDoGhostbust() 96 96 { 97 if ( Phergie_Plugin_Users::getInstance() === null) {97 if ($this->getInstance('Users') === null) { 98 98 $password = $this->getPluginIni('password'); 99 99 $this->debug('password = ' . $password);