mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
system.chat.commands -> system.chat.command
This commit is contained in:
parent
4c05e38d1e
commit
2af603c8e5
@ -74,23 +74,23 @@ public function save() {
|
||||
parent::save();
|
||||
|
||||
\wcf\util\ChatUtil::writeUserData(array('away' => null));
|
||||
$commandHandler = new \wcf\system\chat\commands\CommandHandler($this->message);
|
||||
$commandHandler = new \wcf\system\chat\command\CommandHandler($this->message);
|
||||
if ($commandHandler->isCommand()) {
|
||||
try {
|
||||
$command = $commandHandler->loadCommand();
|
||||
|
||||
if ($command->enableSmilies != \wcf\system\chat\commands\ICommand::SMILEY_USER) $this->enableSmilies = $command->enableSmilies;
|
||||
if ($command->enableSmilies != \wcf\system\chat\command\ICommand::SMILEY_USER) $this->enableSmilies = $command->enableSmilies;
|
||||
$this->enableHTML = $command->enableHTML;
|
||||
$type = $command->getType();
|
||||
$this->message = $command->getMessage();
|
||||
$receiver = $command->getReceiver();
|
||||
}
|
||||
catch (\wcf\system\chat\commands\NotFoundException $e) {
|
||||
catch (\wcf\system\chat\command\NotFoundException $e) {
|
||||
$this->message = WCF::getLanguage()->get('wcf.chat.command.error.notFound');
|
||||
$type = chat\message\ChatMessage::TYPE_ERROR;
|
||||
$receiver = WCF::getUser()->userID;
|
||||
}
|
||||
catch (\wcf\system\chat\commands\UserNotFoundException $e) {
|
||||
catch (\wcf\system\chat\command\UserNotFoundException $e) {
|
||||
$this->message = WCF::getLanguage()->get('wcf.chat.command.error.userNotFound');
|
||||
$type = chat\message\ChatMessage::TYPE_ERROR;
|
||||
$receiver = WCF::getUser()->userID;
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace wcf\system\chat\commands;
|
||||
namespace wcf\system\chat\command;
|
||||
use \wcf\system\event\EventHandler;
|
||||
|
||||
/**
|
||||
@ -9,7 +9,7 @@
|
||||
* @copyright 2010-2012 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
|
||||
* @subpackage system.chat.command
|
||||
*/
|
||||
abstract class AbstractCommand implements ICommand {
|
||||
public $commandHandler = null;
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace wcf\system\chat\commands;
|
||||
namespace wcf\system\chat\command;
|
||||
use \wcf\system\event\EventHandler;
|
||||
|
||||
/**
|
||||
@ -9,7 +9,7 @@
|
||||
* @copyright 2010-2012 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
|
||||
* @subpackage system.chat.command
|
||||
*/
|
||||
abstract class AbstractRestrictedCommand extends AbstractCommand implements IRestrictedCommand {
|
||||
public function __construct(CommandHandler $commandHandler) {
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace wcf\system\chat\commands;
|
||||
namespace wcf\system\chat\command;
|
||||
use \wcf\util\StringUtil;
|
||||
|
||||
/**
|
||||
@ -9,7 +9,7 @@
|
||||
* @copyright 2010-2012 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
|
||||
* @subpackage system.chat.command
|
||||
*/
|
||||
final class CommandHandler {
|
||||
const COMMAND_CHAR = '/';
|
||||
@ -63,7 +63,7 @@ public function loadCommand() {
|
||||
return new commands\Plain($this);
|
||||
}
|
||||
|
||||
$class = '\wcf\system\chat\commands\commands\\'.ucfirst($parts[0]);
|
||||
$class = '\wcf\system\chat\command\commands\\'.ucfirst($parts[0]);
|
||||
if (!class_exists($class)) {
|
||||
throw new NotFoundException();
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace wcf\system\chat\commands\commands;
|
||||
namespace wcf\system\chat\command\commands;
|
||||
use \wcf\util\StringUtil;
|
||||
|
||||
/**
|
||||
@ -9,12 +9,12 @@
|
||||
* @copyright 2010-2012 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.commands
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class Away extends \wcf\system\chat\commands\AbstractCommand {
|
||||
public $enableSmilies = \wcf\system\chat\commands\ICommand::SMILEY_OFF;
|
||||
class Away extends \wcf\system\chat\command\AbstractCommand {
|
||||
public $enableSmilies = \wcf\system\chat\command\ICommand::SMILEY_OFF;
|
||||
|
||||
public function __construct(\wcf\system\chat\commands\CommandHandler $commandHandler) {
|
||||
public function __construct(\wcf\system\chat\command\CommandHandler $commandHandler) {
|
||||
parent::__construct($commandHandler);
|
||||
|
||||
\wcf\util\ChatUtil::writeUserData(array('away' => $commandHandler->getParameters()));
|
||||
@ -22,21 +22,21 @@ public function __construct(\wcf\system\chat\commands\CommandHandler $commandHan
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getType()
|
||||
* @see \wcf\system\chat\command\ICommand::getType()
|
||||
*/
|
||||
public function getType() {
|
||||
return \wcf\data\chat\message\ChatMessage::TYPE_AWAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getMessage()
|
||||
* @see \wcf\system\chat\command\ICommand::getMessage()
|
||||
*/
|
||||
public function getMessage() {
|
||||
return $this->commandHandler->getParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getReceiver()
|
||||
* @see \wcf\system\chat\command\ICommand::getReceiver()
|
||||
*/
|
||||
public function getReceiver() {
|
||||
return \wcf\system\WCF::getUser()->userID;
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace wcf\system\chat\commands\commands;
|
||||
namespace wcf\system\chat\command\commands;
|
||||
use \wcf\util\StringUtil;
|
||||
|
||||
/**
|
||||
@ -9,10 +9,10 @@
|
||||
* @copyright 2010-2012 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.commands
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class Color extends \wcf\system\chat\commands\AbstractCommand {
|
||||
public $enableSmilies = \wcf\system\chat\commands\ICommand::SMILEY_OFF;
|
||||
class Color extends \wcf\system\chat\command\AbstractCommand {
|
||||
public $enableSmilies = \wcf\system\chat\command\ICommand::SMILEY_OFF;
|
||||
public static $colors = array(
|
||||
'red' => 0xFF0000,
|
||||
'blue' => 0x0000FF,
|
||||
@ -37,7 +37,7 @@ class Color extends \wcf\system\chat\commands\AbstractCommand {
|
||||
'oxford' => 0xF02D // looks like green
|
||||
);
|
||||
|
||||
public function __construct(\wcf\system\chat\commands\CommandHandler $commandHandler) {
|
||||
public function __construct(\wcf\system\chat\command\CommandHandler $commandHandler) {
|
||||
parent::__construct($commandHandler);
|
||||
try {
|
||||
list($color[1], $color[2]) = explode(' ', $commandHandler->getParameters());
|
||||
@ -50,7 +50,7 @@ public function __construct(\wcf\system\chat\commands\CommandHandler $commandHan
|
||||
foreach ($color as $key => $val) {
|
||||
if (isset(self::$colors[$val])) $color[$key] = self::$colors[$val];
|
||||
else {
|
||||
if (!$regex->match($val)) throw new \wcf\system\chat\commands\NotFoundException();
|
||||
if (!$regex->match($val)) throw new \wcf\system\chat\command\NotFoundException();
|
||||
$matches = $regex->getMatches();
|
||||
$val = $matches[1];
|
||||
if (strlen($val) == 3) $val = $val[0].$val[0].$val[1].$val[1].$val[2].$val[2];
|
||||
@ -62,21 +62,21 @@ public function __construct(\wcf\system\chat\commands\CommandHandler $commandHan
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getType()
|
||||
* @see \wcf\system\chat\command\ICommand::getType()
|
||||
*/
|
||||
public function getType() {
|
||||
return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getMessage()
|
||||
* @see \wcf\system\chat\command\ICommand::getMessage()
|
||||
*/
|
||||
public function getMessage() {
|
||||
return 'color changed';
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getReceiver()
|
||||
* @see \wcf\system\chat\command\ICommand::getReceiver()
|
||||
*/
|
||||
public function getReceiver() {
|
||||
return \wcf\system\WCF::getUser()->userID;
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace wcf\system\chat\commands\commands;
|
||||
namespace wcf\system\chat\command\commands;
|
||||
|
||||
/**
|
||||
* Informs everyone that the fish was freed. OH A NOEZ.
|
||||
@ -8,23 +8,23 @@
|
||||
* @copyright 2010-2012 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.commands
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class Free extends Me {
|
||||
public $enableSmilies = \wcf\system\chat\commands\ICommand::SMILEY_OFF;
|
||||
public $enableSmilies = \wcf\system\chat\command\ICommand::SMILEY_OFF;
|
||||
|
||||
public function __construct(\wcf\system\chat\commands\CommandHandler $commandHandler) {
|
||||
public function __construct(\wcf\system\chat\command\CommandHandler $commandHandler) {
|
||||
parent::__construct($commandHandler);
|
||||
|
||||
if (\wcf\util\StringUtil::toLowerCase($this->commandHandler->getParameters()) != 'the fish') {
|
||||
throw new \wcf\system\chat\commands\NotFoundException();
|
||||
throw new \wcf\system\chat\command\NotFoundException();
|
||||
}
|
||||
|
||||
$this->didInit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getMessage()
|
||||
* @see \wcf\system\chat\command\ICommand::getMessage()
|
||||
*/
|
||||
public function getMessage() {
|
||||
return 'freed the fish. OH A NOEZ';
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace wcf\system\chat\commands\commands;
|
||||
namespace wcf\system\chat\command\commands;
|
||||
use \wcf\system\WCF;
|
||||
use \wcf\util\ChatUtil;
|
||||
use \wcf\util\StringUtil;
|
||||
@ -11,18 +11,18 @@
|
||||
* @copyright 2010-2012 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.commands
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class Info extends \wcf\system\chat\commands\AbstractCommand {
|
||||
public $enableSmilies = \wcf\system\chat\commands\ICommand::SMILEY_OFF;
|
||||
class Info extends \wcf\system\chat\command\AbstractCommand {
|
||||
public $enableSmilies = \wcf\system\chat\command\ICommand::SMILEY_OFF;
|
||||
public $enableHTML = 1;
|
||||
private $lines = array();
|
||||
|
||||
public function __construct(\wcf\system\chat\commands\CommandHandler $commandHandler) {
|
||||
public function __construct(\wcf\system\chat\command\CommandHandler $commandHandler) {
|
||||
parent::__construct($commandHandler);
|
||||
|
||||
$user = \wcf\data\user\User::getUserByUsername(rtrim($commandHandler->getParameters(), ','));
|
||||
if (!$user->userID) throw new \wcf\system\chat\commands\UserNotFoundException(rtrim($commandHandler->getParameters(), ','));
|
||||
if (!$user->userID) throw new \wcf\system\chat\command\UserNotFoundException(rtrim($commandHandler->getParameters(), ','));
|
||||
$room = new \wcf\data\chat\room\ChatRoom(ChatUtil::readUserData('roomID', $user));
|
||||
$color = ChatUtil::readUserData('color', $user);
|
||||
|
||||
@ -38,14 +38,14 @@ public function __construct(\wcf\system\chat\commands\CommandHandler $commandHan
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getType()
|
||||
* @see \wcf\system\chat\command\ICommand::getType()
|
||||
*/
|
||||
public function getType() {
|
||||
return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getMessage()
|
||||
* @see \wcf\system\chat\command\ICommand::getMessage()
|
||||
*/
|
||||
public function getMessage() {
|
||||
$lines = array();
|
||||
@ -56,7 +56,7 @@ public function getMessage() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getReceiver()
|
||||
* @see \wcf\system\chat\command\ICommand::getReceiver()
|
||||
*/
|
||||
public function getReceiver() {
|
||||
return \wcf\system\WCF::getUser()->userID;
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace wcf\system\chat\commands\commands;
|
||||
namespace wcf\system\chat\command\commands;
|
||||
use \wcf\util\StringUtil;
|
||||
|
||||
/**
|
||||
@ -9,26 +9,26 @@
|
||||
* @copyright 2010-2012 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.commands
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class Me extends \wcf\system\chat\commands\AbstractCommand {
|
||||
public $enableSmilies = \wcf\system\chat\commands\ICommand::SMILEY_USER;
|
||||
class Me extends \wcf\system\chat\command\AbstractCommand {
|
||||
public $enableSmilies = \wcf\system\chat\command\ICommand::SMILEY_USER;
|
||||
|
||||
public function __construct(\wcf\system\chat\commands\CommandHandler $commandHandler) {
|
||||
public function __construct(\wcf\system\chat\command\CommandHandler $commandHandler) {
|
||||
parent::__construct($commandHandler);
|
||||
|
||||
$this->didInit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getType()
|
||||
* @see \wcf\system\chat\command\ICommand::getType()
|
||||
*/
|
||||
public function getType() {
|
||||
return \wcf\data\chat\message\ChatMessage::TYPE_ME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getMessage()
|
||||
* @see \wcf\system\chat\command\ICommand::getMessage()
|
||||
*/
|
||||
public function getMessage() {
|
||||
return $this->commandHandler->getParameters();
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace wcf\system\chat\commands\commands;
|
||||
namespace wcf\system\chat\command\commands;
|
||||
|
||||
/**
|
||||
* Sends a message that starts with a slash.
|
||||
@ -8,27 +8,27 @@
|
||||
* @copyright 2010-2012 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.commands
|
||||
* @subpackage system.chat.command.commands
|
||||
*/
|
||||
class Plain extends \wcf\system\chat\commands\AbstractCommand {
|
||||
public $enableSmilies = \wcf\system\chat\commands\ICommand::SMILEY_USER;
|
||||
class Plain extends \wcf\system\chat\command\AbstractCommand {
|
||||
public $enableSmilies = \wcf\system\chat\command\ICommand::SMILEY_USER;
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getType()
|
||||
* @see \wcf\system\chat\command\ICommand::getType()
|
||||
*/
|
||||
public function getType() {
|
||||
return \wcf\data\chat\message\ChatMessage::TYPE_NORMAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getMessage()
|
||||
* @see \wcf\system\chat\command\ICommand::getMessage()
|
||||
*/
|
||||
public function getMessage() {
|
||||
return \wcf\util\StringUtil::substring($this->commandHandler->getText(), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\system\chat\commands\ICommand::getReceiver()
|
||||
* @see \wcf\system\chat\command\ICommand::getReceiver()
|
||||
*/
|
||||
public function getReceiver() {
|
||||
return null;
|
Loading…
Reference in New Issue
Block a user