Exemplo n.º 1
0
 public function questionify(CommandMessage $command)
 {
     $text = (yield $this->messageResolver->resolveMessageText($command->getRoom(), $command->getText()));
     if (preg_match('/\\?\\s*$/', $text)) {
         return $this->chatClient->postReply($command, 'That\'s already a question');
     }
     return $this->chatClient->postMessage($command->getRoom(), rtrim($text) . '?');
 }
Exemplo n.º 2
0
 public function lmgtfy(Command $command)
 {
     $text = $command->getText();
     if ((bool) preg_match('~^http://chat\\.stackoverflow\\.com/transcript/message/(\\d+)(#\\d+)?$~', $text)) {
         $text = (yield $this->messageResolver->resolveMessageText($command->getRoom(), $text));
     }
     return $this->chatClient->postReply($command, $this->getResponse($text));
 }
Exemplo n.º 3
0
 public function trenslete(CommandMessage $command)
 {
     $text = (yield $this->messageResolver->resolveMessageText($command->getRoom(), $command->getText()));
     return $this->chatClient->postReply($command, $this->ruinPrepositions($text));
 }
Exemplo n.º 4
0
 public function eval(Command $command) : Promise
 {
     if (!$command->hasParameters()) {
         return new Success();
     }
     $code = $this->normalizeCode($command->getText());
     $body = (new FormBody())->addField("title", "")->addField("code", $code);
     $request = (new HttpRequest())->setUri("https://3v4l.org/new")->setMethod("POST")->setHeader("Accept", "application/json")->setBody($body);
     $deferred = new Deferred();
     $this->queue->push([$request, $command->getRoom(), $deferred]);
     if (!$this->haveLoop) {
         resolve($this->executeActionsFromQueue());
     }
     return $deferred->promise();
 }