Changeset 205
- Timestamp:
- 04/04/08 10:28:52 (8 months ago)
- Files:
-
- trunk/Phergie/Driver/Abstract.php (modified) (2 diffs)
- trunk/Phergie/Driver/Streams.php (modified) (4 diffs)
- trunk/Phergie/Plugin/Abstract/Base.php (modified) (4 diffs)
- trunk/Phergie/Plugin/Dice.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Eval.php (modified) (2 diffs)
- trunk/Phergie/Plugin/JoinPart.php (modified) (1 diff)
- trunk/Phergie/Plugin/Karma.php (modified) (3 diffs)
- trunk/Phergie/Plugin/Lart.php (modified) (11 diffs)
- trunk/Phergie/Plugin/ModuleList.php (modified) (2 diffs)
- trunk/Phergie/Plugin/Sed.php (modified) (6 diffs)
- trunk/Phergie/Plugin/Seen.php (modified) (7 diffs)
- trunk/Phergie/Plugin/Set.php (modified) (4 diffs)
- trunk/Phergie/Plugin/Tld.php (modified) (1 diff)
- trunk/Phergie/Plugin/Toggle.php (modified) (1 diff)
- trunk/Phergie/Plugin/Url.php (modified) (9 diffs)
- trunk/Phergie/Plugin/Weather.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Driver/Abstract.php
r204 r205 159 159 public function getPluginList($dirList = false, $preserveExt = false) 160 160 { 161 if (!$dirList) {162 return array_keys($this->plugins);163 } else {164 $iterator = new DirectoryIterator(PHERGIE_PLUGIN_DIR);165 $plugins = array();166 167 foreach ($iterator as $filename) {168 if ($iterator->isFile() && pathinfo($filename, PATHINFO_EXTENSION) == 'php') {169 $plugins[] = ($preserveExt ? (string) $filename : basename($filename, '.php'));170 }171 }172 unset($iterator, $filename, $dirList);173 174 return $plugins;175 }161 if (!$dirList) { 162 return array_keys($this->plugins); 163 } else { 164 $iterator = new DirectoryIterator(PHERGIE_PLUGIN_DIR); 165 $plugins = array(); 166 167 foreach ($iterator as $filename) { 168 if ($iterator->isFile() && pathinfo($filename, PATHINFO_EXTENSION) == 'php') { 169 $plugins[] = ($preserveExt ? (string) $filename : basename($filename, '.php')); 170 } 171 } 172 unset($iterator, $filename, $dirList); 173 174 return $plugins; 175 } 176 176 } 177 177 … … 184 184 public function getPlugin($plugin) 185 185 { 186 $plugin = strtolower($plugin);187 if (isset($this->plugins[$plugin]))188 return $this->plugins[$plugin];189 return false;186 $plugin = strtolower($plugin); 187 if (isset($this->plugins[$plugin])) 188 return $this->plugins[$plugin]; 189 return false; 190 190 } 191 191 trunk/Phergie/Driver/Streams.php
r204 r205 116 116 } elseif ($this->getIni('keepalive')) { 117 117 $timeout = 600; 118 } else {119 $timeout = false;120 }121 $lastPacket = time();118 } else { 119 $timeout = false; 120 } 121 $lastPacket = time(); 122 122 123 123 unset($port); … … 167 167 $buffer = fgets($this->socket, 512); 168 168 169 // Check if we timed out170 if ($timeout !== false) {171 // Reset last packet timestamp if we received something172 if (!empty($buffer)) {173 $lastPacket = time();174 }175 // Timed out, exit176 if ($lastPacket < (time() - $timeout)) {177 $this->debug('Timed out');178 foreach ($this->plugins as $plugin) {179 $plugin->shutdown();180 }181 break 2;182 }183 }169 // Check if we timed out 170 if ($timeout !== false) { 171 // Reset last packet timestamp if we received something 172 if (!empty($buffer)) { 173 $lastPacket = time(); 174 } 175 // Timed out, exit 176 if ($lastPacket < (time() - $timeout)) { 177 $this->debug('Timed out'); 178 foreach ($this->plugins as $plugin) { 179 $plugin->shutdown(); 180 } 181 break 2; 182 } 183 } 184 184 } 185 185 if (!isset($buffer) || empty($buffer)) { … … 294 294 // Skip disabled plugins 295 295 if ($plugin->enabled === false) { 296 continue;296 continue; 297 297 } 298 298 $plugin->setEvent($event); … … 604 604 $version = trim($version); 605 605 if (empty($version)) { 606 $version = 'Phergie '.PHERGIE_VERSION.' - An IRC bot written in PHP (http://www.phergie.com)';606 $version = 'Phergie '.PHERGIE_VERSION.' - An IRC bot written in PHP (http://www.phergie.com)'; 607 607 } 608 608 $this->doCtcpReply($target, 'version', $version); trunk/Phergie/Plugin/Abstract/Base.php
r204 r205 285 285 return chr(0); 286 286 case ($code & 0x7F): 287 return chr($code);287 return chr($code); 288 288 289 289 // 2 bytes, 11 bits 290 290 case ($code & 0x7FF): 291 return chr(0xC0 | (($code >> 6) & 0x1F)) .291 return chr(0xC0 | (($code >> 6) & 0x1F)) . 292 292 chr(0x80 | ($code & 0x3F)); 293 293 294 294 // 3 bytes, 16 bits 295 295 case ($code & 0xFFFF): 296 return chr(0xE0 | (($code >> 12) & 0x0F)) .296 return chr(0xE0 | (($code >> 12) & 0x0F)) . 297 297 chr(0x80 | (($code >> 6) & 0x3F)) . 298 298 chr(0x80 | ($code & 0x3F)); … … 300 300 // 4 bytes, 21 bits 301 301 case ($code & 0x1FFFFF): 302 return chr(0xF0 | ($code >> 18)) .302 return chr(0xF0 | ($code >> 18)) . 303 303 chr(0x80 | (($code >> 12) & 0x3F)) . 304 304 chr(0x80 | (($code >> 6) & 0x3F)) . … … 358 358 // Loop through the results 359 359 foreach ($matches as $match) { 360 $match = trim($match);361 // Check to see if the current match an an --option362 if (substr($match, 0, 2 ) === '--') {363 $value = preg_split('/[=\s]/', $match, 2);364 $com = substr(array_shift($value), 2);365 $value = trim(join($value));366 // Strip quotes from the option's value367 $realValue = (substr($value, 0, 1) === '"' && substr($value, -1) === '"' || substr($match, -1) === '=');368 if(substr($value, 0, 1) === '"' && substr($value, -1) === '"') {369 $value = trim(substr($value, 1, -1));370 }371 if (!in_array($com, $data['all']['commands']))372 $data['all']['commands'][] = $com;373 $data['commands'][$com] = (!empty($value) || $realValue? str_replace('\"', '"', $value) : true);374 continue;375 }376 377 // Check to see if the current match is a -flag378 if (substr($match, 0, 1) === '-' || substr($match, 0, 1) === '+') {379 $flag = substr($match, 1);380 if (!in_array($flag, $data['all']['flags']))381 $data['all']['flags'][] = $flag;382 // Handle the flags using bitwise operations. 1=-flag, 2=+flag, 3=Both a plus and minus383 if (isset($data['flags'][$flag])) {384 $data['flags'][$flag] |= (substr($match, 0, 1) === '-' ? 0x1 : 0x2);385 } else {386 $data['flags'][$flag] = (substr($match, 0, 1) === '-' ? 0x1 : 0x2);387 }388 continue;389 }390 391 // Strip the quotes away from match392 if(substr($match, 0, 1) === '"' && substr($match, -1) === '"') {393 $match = trim(substr($match, 1, -1));394 }395 // The match value isn't a flag or an option so consider it a string396 if (!empty($match))397 $data['strings'][] = str_replace('\"', '"', $match);360 $match = trim($match); 361 // Check to see if the current match an an --option 362 if (substr($match, 0, 2 ) === '--') { 363 $value = preg_split('/[=\s]/', $match, 2); 364 $com = substr(array_shift($value), 2); 365 $value = trim(join($value)); 366 // Strip quotes from the option's value 367 $realValue = (substr($value, 0, 1) === '"' && substr($value, -1) === '"' || substr($match, -1) === '='); 368 if(substr($value, 0, 1) === '"' && substr($value, -1) === '"') { 369 $value = trim(substr($value, 1, -1)); 370 } 371 if (!in_array($com, $data['all']['commands'])) 372 $data['all']['commands'][] = $com; 373 $data['commands'][$com] = (!empty($value) || $realValue? str_replace('\"', '"', $value) : true); 374 continue; 375 } 376 377 // Check to see if the current match is a -flag 378 if (substr($match, 0, 1) === '-' || substr($match, 0, 1) === '+') { 379 $flag = substr($match, 1); 380 if (!in_array($flag, $data['all']['flags'])) 381 $data['all']['flags'][] = $flag; 382 // Handle the flags using bitwise operations. 1=-flag, 2=+flag, 3=Both a plus and minus 383 if (isset($data['flags'][$flag])) { 384 $data['flags'][$flag] |= (substr($match, 0, 1) === '-' ? 0x1 : 0x2); 385 } else { 386 $data['flags'][$flag] = (substr($match, 0, 1) === '-' ? 0x1 : 0x2); 387 } 388 continue; 389 } 390 391 // Strip the quotes away from match 392 if(substr($match, 0, 1) === '"' && substr($match, -1) === '"') { 393 $match = trim(substr($match, 1, -1)); 394 } 395 // The match value isn't a flag or an option so consider it a string 396 if (!empty($match)) 397 $data['strings'][] = str_replace('\"', '"', $match); 398 398 } 399 399 … … 431 431 432 432 if ($time > 0 || count($return) <= 0) { 433 $return[] = ($time > 0 ? $time : '0') . 's';433 $return[] = ($time > 0 ? $time : '0') . 's'; 434 434 } 435 435 trunk/Phergie/Plugin/Dice.php
r204 r205 104 104 if (preg_match('{^(?:([0-9]+)[\#|:|\s])?(?:([0-9]+)[\s|d])?(?:[\s|d]?([0-9]+))(?:([+-])(.*))?$}ix', $message, $m)) { 105 105 if (isset($m[1]) && (!isset($m[2]) or empty($m[2]))) { 106 $m[2] = $m[1]; $m[1] = null;106 $m[2] = $m[1]; $m[1] = null; 107 107 } 108 108 $numDice = ($m[1] < 1 ? 1 : ($m[1] > $this->max['total'] ? $this->max['total'] : $m[1])); … … 114 114 $bonus = 0; 115 115 if (!empty($expression) && $this->allowExpressions) { 116 $bonus = $this->processExpression($expression);117 if (is_null($bonus)) {118 return ' Error while processing the dice expression.';119 }116 $bonus = $this->processExpression($expression); 117 if (is_null($bonus)) { 118 return ' Error while processing the dice expression.'; 119 } 120 120 } 121 121 trunk/Phergie/Plugin/Eval.php
r203 r205 24 24 // Check to see if the admin is a hostmask admin only and not an op 25 25 if ($this->fromAdmin(false)) { 26 $code = trim($code);26 $code = trim($code); 27 27 if (empty($code)) { 28 28 return; 29 29 } 30 30 31 // Check to see if the -r arg is set, if so, run the code as is, else prepend return32 if (substr(strtolower($code), 0, 2) == '-r') {33 $code = trim(substr($code, 2));34 } else {35 $code = trim((strtolower(substr($code, 0, 6)) != 'return'?'return ':'') . $code);36 }31 // Check to see if the -r arg is set, if so, run the code as is, else prepend return 32 if (substr(strtolower($code), 0, 2) == '-r') { 33 $code = trim(substr($code, 2)); 34 } else { 35 $code = trim((strtolower(substr($code, 0, 6)) != 'return'?'return ':'') . $code); 36 } 37 37 38 if (!empty($code)) {39 if (substr($code, -1) != ';') {40 $code .= ';';41 }38 if (!empty($code)) { 39 if (substr($code, -1) != ';') { 40 $code .= ';'; 41 } 42 42 43 43 // Use output buffering to catch any output from eval 44 ob_start();45 $eval = eval($code);46 $contents = ob_get_contents();47 ob_end_clean();44 ob_start(); 45 $eval = eval($code); 46 $contents = ob_get_contents(); 47 ob_end_clean(); 48 48 49 49 // Dump the content of the output buffering to the console 50 if (!empty($contents)) {51 $this->debug('OUTPUT:' . PHP_EOL . trim($contents));52 unset($contents);53 }50 if (!empty($contents)) { 51 $this->debug('OUTPUT:' . PHP_EOL . trim($contents)); 52 unset($contents); 53 } 54 54 55 if (!empty($eval)) {56 $this->doPrivmsg($this->event->getSource(), trim($eval));57 unset($eval);58 }59 }55 if (!empty($eval)) { 56 $this->doPrivmsg($this->event->getSource(), trim($eval)); 57 unset($eval); 58 } 59 } 60 60 } else { 61 $this->doNotice($user, 'You do not have permission to use eval.');61 $this->doNotice($user, 'You do not have permission to use eval.'); 62 62 } 63 63 } … … 75 75 // Check to see if the admin is a hostmask admin only and not an op 76 76 if ($this->fromAdmin(false)) { 77 $code = trim($code);77 $code = trim($code); 78 78 if (empty($code)) { 79 79 return; 80 80 } 81 81 82 $console = false;83 // Check to see if the -c arg is set, if so, dump the entire exec result to console84 if (substr(strtolower($code), 0, 2) == '-c') {85 $code = trim(substr($code, 2));86 $console = true;87 }82 $console = false; 83 // Check to see if the -c arg is set, if so, dump the entire exec result to console 84 if (substr(strtolower($code), 0, 2) == '-c') { 85 $code = trim(substr($code, 2)); 86 $console = true; 87 } 88 88 89 if (!empty($code)) {90 $exec = exec($code, $output);91 if (!empty($exec)) {92 $this->doPrivmsg($this->event->getSource(), trim($exec));93 unset($exec);94 }95 if (!empty($output)) {96 if ($console) {97 $this->debug('OUTPUT:' . PHP_EOL . implode("\n", $output));98 }99 unset($output);100 }101 }89 if (!empty($code)) { 90 $exec = exec($code, $output); 91 if (!empty($exec)) { 92 $this->doPrivmsg($this->event->getSource(), trim($exec)); 93 unset($exec); 94 } 95 if (!empty($output)) { 96 if ($console) { 97 $this->debug('OUTPUT:' . PHP_EOL . implode("\n", $output)); 98 } 99 unset($output); 100 } 101 } 102 102 } else { 103 $this->doNotice($user, 'You do not have permission to use exec.');103 $this->doNotice($user, 'You do not have permission to use exec.'); 104 104 } 105 105 } trunk/Phergie/Plugin/JoinPart.php
r203 r205 61 61 } 62 62 if (!$this->usersEnabled) { 63 // A fallback, most IRC servers cause the user to part all channels if they try to join 064 $this->doJoin('0');63 // A fallback, most IRC servers cause the user to part all channels if they try to join 0 64 $this->doJoin('0'); 65 65 } else { 66 66 $channels = implode(',', Phergie_Plugin_Users::getChannels()); trunk/Phergie/Plugin/Karma.php
r204 r205 117 117 118 118 $this->positiveAnswers = array ( 119 'No kidding, %owner% totally kicks %owned%\'s ass !',120 'True that.',121 'I concur.',122 'Yay, %owner% ftw !',123 '%owner% is made of WIN!',124 'Nothing can beat %owner%!',119 'No kidding, %owner% totally kicks %owned%\'s ass !', 120 'True that.', 121 'I concur.', 122 'Yay, %owner% ftw !', 123 '%owner% is made of WIN!', 124 'Nothing can beat %owner%!', 125 125 ); 126 126 127 127 $this->negativeAnswers = array 128 128 ( 129 'No sir, not at all.',130 'You\'re wrong dude, %owner% wins.',131 'I\'d say %owner% is better than %owned%.',132 'You must be joking, %owner% ftw!',133 '%owned% is made of LOSE!',134 '%owned% = Epic Fail',129 'No sir, not at all.', 130 'You\'re wrong dude, %owner% wins.', 131 'I\'d say %owner% is better than %owned%.', 132 'You must be joking, %owner% ftw!', 133 '%owned% is made of LOSE!', 134 '%owned% = Epic Fail', 135 135 ); 136 136 … … 376 376 377 377 // Fetch first word 378 if ($word1 === '*' || $word1 === 'all' || $word1 === 'everything') {378 if ($word1 === '*' || $word1 === 'all' || $word1 === 'everything') { 379 379 $res = array('karma' => 0); 380 380 $word1 = 'everything'; 381 } else {381 } else { 382 382 $this->fetchKarma->execute(array(':word'=>$word1)); 383 383 $res = $this->fetchKarma->fetch(PDO::FETCH_ASSOC); 384 }384 } 385 385 // If it exists, fetch second word 386 386 if ($res) { 387 if ($word2 === '*' || $word2 === 'all' || $word2 === 'everything') {387 if ($word2 === '*' || $word2 === 'all' || $word2 === 'everything') { 388 388 $res2 = array('karma' => 0); 389 389 $word2 = 'everything'; 390 } else {390 } else { 391 391 $this->fetchKarma->execute(array(':word'=>$word2)); 392 392 $res2 = $this->fetchKarma->fetch(PDO::FETCH_ASSOC); 393 }393 } 394 394 // If it exists, compare and return value 395 395 if ($res2 && $res['karma'] != $res2['karma']) { … … 397 397 // Switch arguments if they are in the wrong order 398 398 if ($operator === '<') { 399 $tmp = $word2; $word2 = $word1; $word1 = $tmp;399 $tmp = $word2; $word2 = $word1; $word1 = $tmp; 400 400 } 401 401 $this->doPrivmsg($source, $assertion ? $this->fetchPositiveAnswer($word1, $word2) : $this->fetchNegativeAnswer($word1, $word2) ); trunk/Phergie/Plugin/Lart.php
r204 r205 81 81 { 82 82 try { 83 // Initialize the database connection84 $this->db = new PDO('sqlite:' . $this->dir . 'lart.db');83 // Initialize the database connection 84 $this->db = new PDO('sqlite:' . $this->dir . 'lart.db'); 85 85 if (!$this->db) { 86 86 return; 87 87 } 88 88 89 // Check to see if the table exists90 $table = $this->db91 ->query('SELECT COUNT(*) FROM sqlite_master WHERE name = ' . $this->db->quote('lart'))92 ->fetchColumn();93 94 // Create database tables if necessary95 if (!$table) {96 $this->debug('Creating the database schema');97 $this->db->exec('98 CREATE TABLE lart (name VARCHAR(255), definition TEXT, hostmask VARCHAR(50), tstamp VARCHAR(19));99 CREATE UNIQUE INDEX lart_name ON lart (name)100 ');101 }102 unset($table);103 104 // Get the list of columns from the table105 $table = $this->db106 ->query('PRAGMA table_info(' . $this->db->quote('lart') . ')')107 ->fetchAll();108 109 $columns = array();110 foreach($table as $key => $column) {111 $columns[] = $column['name'];112 }113 unset($table);114 115 // Update table as neccessary116 if (!in_array('hostmask', $columns)) {117 $this->debug('Updating the database schema');118 $this->db->exec('119 BEGIN TRANSACTION;120 CREATE TEMPORARY TABLE lart_backup (name VARCHAR(255), definition TEXT);121 INSERT INTO lart_backup SELECT name, definition FROM lart;122 DROP TABLE lart;123 CREATE TABLE lart (name VARCHAR(255), definition TEXT, hostmask VARCHAR(50), tstamp VARCHAR(19));124 INSERT INTO lart SELECT name, definition, NULL, NULL FROM lart_backup;125 DROP TABLE lart_backup;126 COMMIT;127 CREATE UNIQUE INDEX lart_name ON lart (name)128 ');129 }130 unset($table, $key, $column, $columns);131 132 // Initialize prepared statements for common operations133 $this->replace = $this->db->prepare('134 REPLACE INTO lart (name, definition, hostmask, tstamp) VALUES (:name, :definition, :hostmask, :tstamp)135 ');136 $this->defination = $this->db->prepare('137 SELECT definition FROM lart WHERE LOWER(name) = LOWER(:name)138 ');139 $this->alias = $this->db->prepare('140 SELECT name FROM lart WHERE LOWER(definition) = LOWER(:definition)141 ');142 $this->select = $this->db->prepare('143 SELECT * FROM lart WHERE LOWER(name) = LOWER(:name)144 ');145 $this->delete = $this->db->prepare('146 DELETE FROM lart WHERE LOWER(name) = LOWER(:name)147 ');89 // Check to see if the table exists 90 $table = $this->db 91 ->query('SELECT COUNT(*) FROM sqlite_master WHERE name = ' . $this->db->quote('lart')) 92 ->fetchColumn(); 93 94 // Create database tables if necessary 95 if (!$table) { 96 $this->debug('Creating the database schema'); 97 $this->db->exec(' 98 CREATE TABLE lart (name VARCHAR(255), definition TEXT, hostmask VARCHAR(50), tstamp VARCHAR(19)); 99 CREATE UNIQUE INDEX lart_name ON lart (name) 100 '); 101 } 102 unset($table); 103 104 // Get the list of columns from the table 105 $table = $this->db 106 ->query('PRAGMA table_info(' . $this->db->quote('lart') . ')') 107 ->fetchAll(); 108 109 $columns = array(); 110 foreach($table as $key => $column) { 111 $columns[] = $column['name']; 112 } 113 unset($table); 114 115 // Update table as neccessary 116 if (!in_array('hostmask', $columns)) { 117 $this->debug('Updating the database schema'); 118 $this->db->exec(' 119 BEGIN TRANSACTION; 120 CREATE TEMPORARY TABLE lart_backup (name VARCHAR(255), definition TEXT); 121 INSERT INTO lart_backup SELECT name, definition FROM lart; 122 DROP TABLE lart; 123 CREATE TABLE lart (name VARCHAR(255), definition TEXT, hostmask VARCHAR(50), tstamp VARCHAR(19)); 124 INSERT INTO lart SELECT name, definition, NULL, NULL FROM lart_backup; 125 DROP TABLE lart_backup; 126 COMMIT; 127 CREATE UNIQUE INDEX lart_name ON lart (name) 128 '); 129 } 130 unset($table, $key, $column, $columns); 131 132 // Initialize prepared statements for common operations 133 $this->replace = $this->db->prepare(' 134 REPLACE INTO lart (name, definition, hostmask, tstamp) VALUES (:name, :definition, :hostmask, :tstamp) 135 '); 136 $this->defination = $this->db->prepare(' 137 SELECT definition FROM lart WHERE LOWER(name) = LOWER(:name) 138 '); 139 $this->alias = $this->db->prepare(' 140 SELECT name FROM lart WHERE LOWER(definition) = LOWER(:definition) 141 '); 142 $this->select = $this->db->prepare(' 143 SELECT * FROM lart WHERE LOWER(name) = LOWER(:name) 144 '); 145 $this->delete = $this->db->prepare(' 146 DELETE FROM lart WHERE LOWER(name) = LOWER(:name) 147 '); 148 148 } catch (PDOException $e) { } 149 149 } … … 162 162 if (!extension_loaded('PDO') 163 163 || !extension_loaded('pdo_sqlite')) { 164 return false;164 return false; 165 165 } 166 166 … … 179 179 { 180 180 if (!isset($this->cache[$term])) { 181 $this->defination->execute(array(':name' => $term));182 $definition = $this->defination->fetchColumn();183 if ($definition) {184 $this->cache[$term] = $definition;185 } else {186 return false;187 }181 $this->defination->execute(array(':name' => $term)); 182 $definition = $this->defination->fetchColumn(); 183 if ($definition) { 184 $this->cache[$term] = $definition; 185 } else { 186 return false; 187 } 188 188 } 189 189 return $this->cache[$term]; … … 202 202 $names = $this->alias->fetchAll(); 203 203 if ($names && count($names) > 0) { 204 return $names;204 return $names; 205 205 } else { 206 return false;206 return false; 207 207 } 208 208 } … … 219 219 { 220 220 if (empty($message) || strlen($message) > 255) { 221 return;221 return; 222 222 } 223 223 … … 226 226 227 227 if (!empty($definition)) { 228 do {229 if (strtolower($message) == strtolower($definition)) {230 break;231 }232 $redirect = trim($this->getDefinition($definition));233 if (!empty($redirect)) {234 if (strtolower($definition) == strtolower($redirect)) {235 $definition = $redirect;236 break;237 }238 $seen[] = strtolower($definition);239 if (in_array($redirect, $seen)) {240 $this->debug('Alias redirection loop detected');241 $this->deleteLart($message);242 $mod = $this->getIni('gender') == 'F' ? 'her' : 'his';243 $this->doAction(244 $this->event->getArgument(0),245 'puts ' . $mod . ' hands over ' . $mod . ' ears and cries, "Stop confusing me!"'246 );247 return;248 }249 $definition = $redirect;250 }251 } while(!empty($redirect));252 253 if (substr($definition, 0, 3) == '/me') {254 $definition = trim(substr($definition, 3));255 $this->doAction($this->event->getSource(), $definition);256 } else {257 $this->doPrivmsg($this->event->getSource(), $definition);258 }228 do { 229 if (strtolower($message) == strtolower($definition)) { 230 break; 231 } 232 $redirect = trim($this->getDefinition($definition)); 233 if (!empty($redirect)) { 234 if (strtolower($definition) == strtolower($redirect)) { 235 $definition = $redirect; 236 break; 237 } 238 $seen[] = strtolower($definition); 239 if (in_array($redirect, $seen)) { 240 $this->debug('Alias redirection loop detected'); 241 $this->deleteLart($message); 242 $mod = $this->getIni('gender') == 'F' ? 'her' : 'his'; 243 $this->doAction( 244 $this->event->getArgument(0), 245 'puts ' . $mod . ' hands over ' . $mod . ' ears and cries, "Stop confusing me!"' 246 ); 247 return; 248 } 249 $definition = $redirect; 250 } 251 } while(!empty($redirect)); 252 253 if (substr($definition, 0, 3) == '/me') { 254 $definition = trim(substr($definition, 3)); 255 $this->doAction($this->event->getSource(), $definition); 256 } else { 257 $this->doPrivmsg($this->event->getSource(), $definition); 258 } 259 259 } 260 260 } … … 270 270 { 271 271 if (!is_array($this->aCache) || $firstRun) { 272 unset($this->aCache); $this->aCache = array();272 unset($this->aCache); $this->aCache = array(); 273 273 } 274 274 275 275 $alias = $this->getAlias(trim($term)); 276 276 if ($alias) { 277 foreach($alias as $key => $value) {278 $name = $value['name'];279 if (empty($name))280 continue;281 if (!in_array($name, $this->aCache)) {282 $this->aCache[] = strtolower($name);283 if ($recursive) {284 $this->getAliases($name, true, false);285 }286 }287 }277 foreach($alias as $key => $value) { 278 $name = $value['name']; 279 if (empty($name)) 280 continue; 281 if (!in_array($name, $this->aCache)) { 282 $this->aCache[] = strtolower($name); 283 if ($recursive) { 284 $this->getAliases($name, true, false); 285 } 286 } 287 } 288 288 }