Show
Ignore:
Timestamp:
02/25/08 01:38:31 (5 years ago)
Author:
tobias382
Message:

* Added support to the Acronym plugin for filtering responses to certain acronyms
* Modified the Acronym plugin to restrict lookups to instances where the acronym takes up the entire post
* Modified the Acronym and Url plugins to add a lookup timeout
* Modified the Nickserv plugin to extend AdminCommand? instead of Command
* Fixed an issue in the tinyUrl method of the base plugin class where lack of URL encoding of the passed URL resulted in truncation of the original URL when computing its TinyURL equivalent
* Modified getIni and setIni methods in and added getPluginIni and setPluginIni to the base plugin case to allow for easier access to both core and plugin-specific settings and modified existing plugins to use the new methods where appropriate

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/Phergie/Plugin/Acronym.php

    r68 r71  
    1414* The limit configuration setting should be set to the maximum number of 
    1515* potential meanings to return for any single given acronym. 
     16* 
     17* @todo Add a cache to avoid exceeding the acronymfinder.com daily lookup 
     18*       limit. Cache should be flushed daily. 
    1619*/ 
    1720class Phergie_Plugin_Acronym extends Phergie_Plugin_Abstract_Base 
     
    2326    */ 
    2427    protected $limit; 
     28 
     29    /** 
     30    * List of acronyms for which responses should not be sent 
     31    * 
     32    * @var array 
     33    */ 
     34    protected $filter; 
    2535 
    2636    /** 
     
    4555    public function init() 
    4656    { 
    47         $limit = $this->getIni('limit'); 
     57        $limit = $this->getPluginIni('limit'); 
    4858        if ($limit < 0 || $limit === null) { 
    4959            $this->limit = 5; 
     
    5161            $this->limit = (int) $limit; 
    5262        } 
     63 
     64        $this->filter = array_filter(preg_split('/[ ,]/', $this->getPluginIni('filter')), 'strlen'); 
    5365    } 
    5466 
     
    8799        $message = $this->event->getArgument(1); 
    88100 
    89         if (!preg_match('/((?:[A-Z]\.?){2,})\?/', $message, $acronym)) { 
     101        if (!preg_match('/((?:[A-Z]\.?){2,})\?/AD', $message, $acronym)) { 
    90102            return; 
    91103        } 
    92104 
    93105        $acronym = str_replace('.', '', $acronym[1]); 
     106 
     107        if (in_array($acronym, $this->filter)) { 
     108            return; 
     109        } 
    94110 
    95111        if (in_array($acronym, array('WHO', 'WHAT', 'WHERE', 'WHEN', 'WHY', 'HOW'))) { 
     
    100116        $opts = array('http' => 
    101117            array( 
     118                'timeout' => 5, 
    102119                'method' => 'GET', 
    103120                'header' => 'Content-type: application/x-www-form-urlencoded',