Exemple #1
0
 private function getResult(Message $message) : \Generator
 {
     $pattern = strtr(implode(' ', $message->getParameters()), '::', '.');
     $url = 'http://php.net/manual-lookup.php?scope=quickref&pattern=' . rawurlencode($pattern);
     $response = (yield from $this->chatClient->request($url));
     if ($response->getPreviousResponse() !== null) {
         yield from $this->chatClient->postMessage($this->getMessageFromMatch($response));
     } else {
         yield from $this->chatClient->postMessage(yield from $this->getMessageFromSearch($response));
     }
 }
Exemple #2
0
 private function getResponse(Message $message) : string
 {
     $text = $this->normalize($message->getText());
     foreach ($this->matches as $match) {
         if ($this->textDoesMatch($match['insult'], $text)) {
             return $match['response']['text'] . 'first';
         }
         if ($this->textDoesMatch($match['response'], $text)) {
             return $match['insult']['text'] . 'second';
         }
     }
 }
Exemple #3
0
 private function postNoResult(Message $message) : \Generator
 {
     yield from $this->chatClient->postMessage(sprintf(':%s %s', $message->getOrigin(), 'Sorry I couldn\'t find that page.'));
 }
Exemple #4
0
 private function getResult(Message $message) : \Generator
 {
     $response = (yield from $this->chatClient->request('http://www.imdb.com/xml/find?xml=1&nr=1&tt=on&q=' . rawurlencode(implode(' ', $message->getParameters()))));
     yield from $this->chatClient->postMessage($this->getMessage($response));
 }
Exemple #5
0
 private function getResult(Message $message) : \Generator
 {
     $response = (yield from $this->chatClient->request('http://api.urbandictionary.com/v0/define?term=' . rawurlencode(implode('%20', $message->getParameters()))));
     $result = json_decode($response->getBody(), true);
     yield from $this->chatClient->postMessage($this->getMessage($result));
 }