From 022c54ca708c2422c001bbe01509acaa7539d9f5 Mon Sep 17 00:00:00 2001 From: Pitchaya Boonsarngsuk Date: Fri, 21 Dec 2018 17:46:29 +0000 Subject: [PATCH] Add beat handler --- src/Handlers.php | 19 ++++++++++++++----- src/entryPoint.php | 9 +++++++-- test/Test.php | 10 ++-------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/Handlers.php b/src/Handlers.php index f27e856..e5df87c 100644 --- a/src/Handlers.php +++ b/src/Handlers.php @@ -1,16 +1,25 @@ sendMessage($room_id, "uwu"); + if(randomorg(0,1) < 1) + return false; + + switch (randomorg(0,1)) { + case 0: + $this->sendSticker($room_id, "CAADBQADZAEAAvxwTgbC0dARe9U8kAI"); + break; + case 1: + $this->sendSticker($room_id, "CAADBQADZwEAAvxwTgbnO6oUQCtGpAI"); + break; + } + return true; } } \ No newline at end of file diff --git a/src/entryPoint.php b/src/entryPoint.php index 4aa16b2..d37e211 100644 --- a/src/entryPoint.php +++ b/src/entryPoint.php @@ -10,12 +10,17 @@ define("INTER_ROOM", 111213); // randomorg($start,$end); +// Placeholder +function randomorg(int $min, int $max) { + return random_int ($min, $max); +} + + require_once 'MessageHandler.php'; require_once 'Handlers.php'; $handlers = array( - new TestHandler(), - new TestHandler() + new BeatHandler() ); function reply_user(int $room_id, int $msgid, string $message, $room_lang): bool diff --git a/test/Test.php b/test/Test.php index 27307bd..5d4d02c 100644 --- a/test/Test.php +++ b/test/Test.php @@ -1,10 +1,4 @@ assertNotNull( - reply_user('whatever', 0, 'whatever') + reply_user(5, 0, 'whatever') ); } public function testShouldNULLMessageID1(): void { $this->assertNull( - reply_user('whatever', 1, 'whatever') + reply_user(5, 1, 'whatever') ); } }