Add beat handler

This commit is contained in:
2018-12-21 17:46:29 +00:00
parent 1adf272d2a
commit 022c54ca70
3 changed files with 23 additions and 15 deletions

View File

@@ -1,16 +1,25 @@
<?php
require_once 'MessageHandler.php';
class TestHandler extends MessageHandler
class BeatHandler extends MessageHandler
{
public function TryHandle($room_id, $msgid, $message, $room_lang): bool
{
if($msgid != 0)
if(strpos ($message, "ฟาด") === false)
return false;
$this->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;
}
}

View File

@@ -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