From 5bdce43f3482360db99aea90b600ac8a1c9cf256 Mon Sep 17 00:00:00 2001 From: Pitchaya Boonsarngsuk Date: Fri, 21 Dec 2018 18:25:20 +0000 Subject: [PATCH] Add OwO handler functionality --- src/Handlers.php | 14 ++++++++++++-- src/entryPoint.php | 3 ++- src/repl.php | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Handlers.php b/src/Handlers.php index 6cfb253..a54dc5b 100644 --- a/src/Handlers.php +++ b/src/Handlers.php @@ -73,12 +73,22 @@ class BoopTextHandler extends MessageHandler class OwOHandler extends MessageHandler { + private $eyes = array('O', '0', '👁️'); + private $mouths = array('ω','👄'); + public function TryHandle($room_id, $msgid, $message, $room_lang): bool { - if(preg_match('/^\s+[o0][wω][o0]\s+$/i', $message) === false) + if(preg_match('/^\s*[ou0][wω][ou0]\s*$/i', $message) === 0) return false; - $this->sendSticker($room_id, "CAADBAADUwAD7Z8MDl38hfMCvM06Ag"); + if(randomorg(0,1) < 1) + $this->sendMessage($room_id, $room_lang === "th"? "อะไรนี่" : "What's this"); + else { + $eye = $this->eyes[randomorg(0, count($this->eyes)-1)]; + $mouth = $this->mouths[randomorg(0, count($this->mouths)-1)]; + $this->sendMessage($room_id, $eye.$mouth.$eye); + } + return true; } } \ No newline at end of file diff --git a/src/entryPoint.php b/src/entryPoint.php index f6540ac..d556679 100644 --- a/src/entryPoint.php +++ b/src/entryPoint.php @@ -22,7 +22,8 @@ require_once 'Handlers.php'; $handlers = array( new BeatHandler(), new BlueRoomYiffHandler(), - new BoopTextHandler() + new BoopTextHandler(), + new OwOHandler() ); function reply_user(int $room_id, int $msgid, string $message, $room_lang): bool diff --git a/src/repl.php b/src/repl.php index 57159bf..cd2d5d3 100644 --- a/src/repl.php +++ b/src/repl.php @@ -17,6 +17,6 @@ do { $input = fread(STDIN, 80); // Read up to 80 characters or a newline $trimmed = trim($input); - echo reply_user($room_id, $msg_id, $trimmed, "th") , "\n"; + echo reply_user($room_id, $msg_id, $trimmed, "en") , "\n"; $msg_id++; } while($trimmed !== "exit"); \ No newline at end of file