Changeset 194 for trunk/Phergie/Plugin/UrbanDictionary.php
- Timestamp:
- 03/29/08 13:28:33 (5 years ago)
- Files:
-
- 1 modified
-
trunk/Phergie/Plugin/UrbanDictionary.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Phergie/Plugin/UrbanDictionary.php
r60 r194 4 4 * @see Phergie_Plugin_Abstract_Command 5 5 */ 6 require_once 'Phergie/Plugin/Abstract/Command.php';6 require_once PHERGIE_PLUGIN_DIR.'Abstract'.DS.'Command.php'; 7 7 8 8 /** … … 20 20 public function onDoUd($term) 21 21 { 22 $target = $this->event->getNick(); 23 $source = $this->event->getSource(); 24 22 25 $url = 'http://www.urbandictionary.com/define.php?term=' . urlencode($term); 23 26 $contents = file_get_contents($url); … … 25 28 if (strpos($contents, '<i>' . $term . '</i> isn\'t defined') !== false) { 26 29 $url = $this->tinyUrl('http://urbandictionary.com/insert.php?word=' . $term); 27 $this->doPrivmsg( 28 $this->getSource(), 29 $term . ' is not defined yet [ ' . $url . ' ]' 30 ); 30 $this->doPrivmsg($source, $target. ': ' . $term . ' is not defined yet [ ' . $url . ' ]'); 31 31 } else { 32 32 $start = strpos($contents, '<div class="def_p">'); … … 47 47 * length should be 510 characters according to the IRC RFC. 48 48 */ 49 $target = $this->event->getSource(); 50 $max = 445 - strlen($target) - strlen($url); 49 $max = 445 - strlen($source) - strlen($url); 51 50 if (strlen($contents) > $max) { 52 51 $contents = substr($contents, 0, $max); … … 59 58 $contents .= $url; 60 59 61 $this->doPrivmsg($ target, $contents);60 $this->doPrivmsg($source, $contents); 62 61 } 63 62 }