Rearchitect for different types of response

This commit is contained in:
2018-12-20 21:10:39 +00:00
parent a8c3fa4a00
commit d72474e296
5 changed files with 74 additions and 27 deletions

View File

@@ -1,9 +1,9 @@
<?php
// Placeholder Globals
$userid = 0;
$room_lang = "th";
$is_admin = false;
//$userid = 0;
//$room_lang = "th";
//$is_admin = false;
define("BLUE_ROOM", 12345);
define("RED_ROOM", 67890);
define("INTER_ROOM", 111213);
@@ -14,21 +14,16 @@ require_once 'MessageHandler.php';
require_once 'Handlers.php';
$handlers = array(
new TestHandler(),
new TestHandler()
);
function reply_user($room_id, $msgid, $message)
function reply_user($room_id, $msgid, $message, $room_lang)
{
// Placeholder Globals
global $userid;
global $room_lang;
global $is_admin;
global $handlers;
foreach ($handlers as $handler) {
if($handler->CanHandle($room_id, $msgid, $message)) {
return $handler->Handle($room_id, $msgid, $message);
if($handler->TryHandle($room_id, $msgid, $message, $room_lang)) {
break;
}
}
return ;
}