コード例 #1
0
ファイル: Questionify.php プロジェクト: Room-11/Jeeves
 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) . '?');
 }
コード例 #2
0
ファイル: Lmgtfy.php プロジェクト: Room-11/Jeeves
 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));
 }
コード例 #3
0
ファイル: Goochle.php プロジェクト: Room-11/Jeeves
 public function trenslete(CommandMessage $command)
 {
     $text = (yield $this->messageResolver->resolveMessageText($command->getRoom(), $command->getText()));
     return $this->chatClient->postReply($command, $this->ruinPrepositions($text));
 }
コード例 #4
0
ファイル: EvalCode.php プロジェクト: Room-11/Jeeves
 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();
 }