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

View File

@@ -10,12 +10,17 @@ define("INTER_ROOM", 111213);
// randomorg($start,$end); // randomorg($start,$end);
// Placeholder
function randomorg(int $min, int $max) {
return random_int ($min, $max);
}
require_once 'MessageHandler.php'; require_once 'MessageHandler.php';
require_once 'Handlers.php'; require_once 'Handlers.php';
$handlers = array( $handlers = array(
new TestHandler(), new BeatHandler()
new TestHandler()
); );
function reply_user(int $room_id, int $msgid, string $message, $room_lang): bool function reply_user(int $room_id, int $msgid, string $message, $room_lang): bool

View File

@@ -1,10 +1,4 @@
<?php <?php
/**
* Created by PhpStorm.
* User: Brian
* Date: 19/12/2018
* Time: 21:00
*/
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
require_once '../src/entryPoint.php'; require_once '../src/entryPoint.php';
@@ -14,13 +8,13 @@ class Test extends TestCase
public function testShouldNotNULLMessageID0(): void public function testShouldNotNULLMessageID0(): void
{ {
$this->assertNotNull( $this->assertNotNull(
reply_user('whatever', 0, 'whatever') reply_user(5, 0, 'whatever')
); );
} }
public function testShouldNULLMessageID1(): void public function testShouldNULLMessageID1(): void
{ {
$this->assertNull( $this->assertNull(
reply_user('whatever', 1, 'whatever') reply_user(5, 1, 'whatever')
); );
} }
} }