[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Watches for "where is <symbol>?" 5 */ 6 final class PhabricatorBotSymbolHandler extends PhabricatorBotHandler { 7 8 public function receiveMessage(PhabricatorBotMessage $message) { 9 switch ($message->getCommand()) { 10 case 'MESSAGE': 11 $text = $message->getBody(); 12 13 $matches = null; 14 if (!preg_match('/where(?: in the world)? is (\S+?)\?/i', 15 $text, $matches)) { 16 break; 17 } 18 19 $symbol = $matches[1]; 20 $results = $this->getConduit()->callMethodSynchronous( 21 'diffusion.findsymbols', 22 array( 23 'name' => $symbol, 24 )); 25 26 $default_uri = $this->getURI('/diffusion/symbol/'.$symbol.'/'); 27 28 if (count($results) > 1) { 29 $response = "Multiple symbols named '{$symbol}': {$default_uri}"; 30 } else if (count($results) == 1) { 31 $result = head($results); 32 $response = 33 $result['type'].' '. 34 $result['name'].' '. 35 '('.$result['language'].'): '. 36 nonempty($result['uri'], $default_uri); 37 } else { 38 $response = "No symbol '{$symbol}' found anywhere."; 39 } 40 41 $this->replyTo($message, $response); 42 43 break; 44 } 45 } 46 47 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |