mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Introducing ChatCommandHandler
This commit is contained in:
parent
a5c1f7c575
commit
44737e2df2
@ -86,6 +86,8 @@ public function validate() {
|
|||||||
public function save() {
|
public function save() {
|
||||||
parent::save();
|
parent::save();
|
||||||
|
|
||||||
|
$commandHandler = new \wcf\system\chat\commands\ChatCommandHandler();
|
||||||
|
var_dump($commandHandler->isCommand($this->message));
|
||||||
$messageAction = new chat\message\ChatMessageAction(array(), 'create', array(
|
$messageAction = new chat\message\ChatMessageAction(array(), 'create', array(
|
||||||
'data' => array(
|
'data' => array(
|
||||||
'roomID' => $this->userData['roomID'],
|
'roomID' => $this->userData['roomID'],
|
||||||
|
26
file/lib/system/chat/commands/ChatCommandHandler.class.php
Normal file
26
file/lib/system/chat/commands/ChatCommandHandler.class.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
namespace wcf\system\chat\commands;
|
||||||
|
use \wcf\util\StringUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserts a message.
|
||||||
|
*
|
||||||
|
* @author Tim Düsterhus
|
||||||
|
* @copyright 2010-2011 Tim Düsterhus
|
||||||
|
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
||||||
|
* @package timwolla.wcf.chat
|
||||||
|
* @subpackage system.chat.commands
|
||||||
|
*/
|
||||||
|
class ChatCommandHandler {
|
||||||
|
const COMMAND_CHAR = '/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the given text is a command.
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function isCommand($text) {
|
||||||
|
return StringUtil::substring($text, 0, StringUtil::length(static::COMMAND_CHAR)) == static::COMMAND_CHAR;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user