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) . '?'); }
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)); }
public function trenslete(CommandMessage $command) { $text = (yield $this->messageResolver->resolveMessageText($command->getRoom(), $command->getText())); return $this->chatClient->postReply($command, $this->ruinPrepositions($text)); }
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(); }