Add OwO handler functionality

This commit is contained in:
2018-12-21 18:25:20 +00:00
parent 79f86f018e
commit 5bdce43f34
3 changed files with 15 additions and 4 deletions

View File

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

View File

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

View File

@@ -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");