Changeset 71 for trunk/Phergie/Plugin/Acronym.php
- Timestamp:
- 02/25/08 01:38:31 (5 years ago)
- Files:
-
- 1 modified
-
trunk/Phergie/Plugin/Acronym.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Phergie/Plugin/Acronym.php
r68 r71 14 14 * The limit configuration setting should be set to the maximum number of 15 15 * 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. 16 19 */ 17 20 class Phergie_Plugin_Acronym extends Phergie_Plugin_Abstract_Base … … 23 26 */ 24 27 protected $limit; 28 29 /** 30 * List of acronyms for which responses should not be sent 31 * 32 * @var array 33 */ 34 protected $filter; 25 35 26 36 /** … … 45 55 public function init() 46 56 { 47 $limit = $this->get Ini('limit');57 $limit = $this->getPluginIni('limit'); 48 58 if ($limit < 0 || $limit === null) { 49 59 $this->limit = 5; … … 51 61 $this->limit = (int) $limit; 52 62 } 63 64 $this->filter = array_filter(preg_split('/[ ,]/', $this->getPluginIni('filter')), 'strlen'); 53 65 } 54 66 … … 87 99 $message = $this->event->getArgument(1); 88 100 89 if (!preg_match('/((?:[A-Z]\.?){2,})\?/ ', $message, $acronym)) {101 if (!preg_match('/((?:[A-Z]\.?){2,})\?/AD', $message, $acronym)) { 90 102 return; 91 103 } 92 104 93 105 $acronym = str_replace('.', '', $acronym[1]); 106 107 if (in_array($acronym, $this->filter)) { 108 return; 109 } 94 110 95 111 if (in_array($acronym, array('WHO', 'WHAT', 'WHERE', 'WHEN', 'WHY', 'HOW'))) { … … 100 116 $opts = array('http' => 101 117 array( 118 'timeout' => 5, 102 119 'method' => 'GET', 103 120 'header' => 'Content-type: application/x-www-form-urlencoded',