mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Merge branch 'master' into suspensionList
Conflicts: package.xml
This commit is contained in:
commit
4abb837878
@ -125,6 +125,9 @@ public function validateSend() {
|
|||||||
catch (\chat\system\command\UserNotFoundException $e) {
|
catch (\chat\system\command\UserNotFoundException $e) {
|
||||||
throw new UserInputException('text', WCF::getLanguage()->getDynamicVariable('chat.error.userNotFound', array('exception' => $e)));
|
throw new UserInputException('text', WCF::getLanguage()->getDynamicVariable('chat.error.userNotFound', array('exception' => $e)));
|
||||||
}
|
}
|
||||||
|
catch (\InvalidArgumentException $e) {
|
||||||
|
throw new UserInputException('text', WCF::getLanguage()->getDynamicVariable('chat.error.invalidArgument', array('exception' => $e)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->parameters['type'] = Message::TYPE_NORMAL;
|
$this->parameters['type'] = Message::TYPE_NORMAL;
|
||||||
|
@ -146,6 +146,9 @@ public function readCommands() {
|
|||||||
if ($command == 'Plain') continue;
|
if ($command == 'Plain') continue;
|
||||||
$this->commands[] = \wcf\util\StringUtil::toLowerCase($command);
|
$this->commands[] = \wcf\util\StringUtil::toLowerCase($command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->commands = array_merge($this->commands, array_keys(\chat\system\command\CommandHandler::getAliasMap()));
|
||||||
|
sort($this->commands);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,6 +39,29 @@ final class CommandHandler {
|
|||||||
public function __construct($text, \chat\data\room\Room $room = null) {
|
public function __construct($text, \chat\data\room\Room $room = null) {
|
||||||
$this->text = $text;
|
$this->text = $text;
|
||||||
$this->room = $room;
|
$this->room = $room;
|
||||||
|
|
||||||
|
$aliases = self::getAliasMap();
|
||||||
|
foreach ($aliases as $search => $replace) {
|
||||||
|
$this->text = \wcf\system\Regex::compile('^'.preg_quote(self::COMMAND_CHAR.$search).'( |$)')->replace($this->text, self::COMMAND_CHAR.$replace.' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->text = \wcf\system\Regex::compile('^//')->replace($this->text, '/plain ');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the alias map. Key is the alias, value is the target.
|
||||||
|
*
|
||||||
|
* @return array<string>
|
||||||
|
*/
|
||||||
|
public static function getAliasMap() {
|
||||||
|
$result = array();
|
||||||
|
foreach (explode("\n", StringUtil::unifyNewlines(StringUtil::toLowerCase(CHAT_COMMAND_ALIASES))) as $line) {
|
||||||
|
list($key, $val) = explode(':', $line, 2);
|
||||||
|
|
||||||
|
$result[$key] = $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,13 +109,9 @@ public function getParameters() {
|
|||||||
public function loadCommand() {
|
public function loadCommand() {
|
||||||
$parts = explode(' ', StringUtil::substring($this->text, StringUtil::length(static::COMMAND_CHAR)), 2);
|
$parts = explode(' ', StringUtil::substring($this->text, StringUtil::length(static::COMMAND_CHAR)), 2);
|
||||||
|
|
||||||
if ($this->isCommand($parts[0])) {
|
|
||||||
return new commands\PlainCommand($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
$class = '\chat\system\command\commands\\'.ucfirst(strtolower($parts[0])).'Command';
|
$class = '\chat\system\command\commands\\'.ucfirst(strtolower($parts[0])).'Command';
|
||||||
if (!class_exists($class)) {
|
if (!class_exists($class)) {
|
||||||
throw new NotFoundException();
|
throw new NotFoundException($parts[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new $class($this);
|
return new $class($this);
|
||||||
|
@ -10,4 +10,23 @@
|
|||||||
* @package be.bastelstu.chat
|
* @package be.bastelstu.chat
|
||||||
* @subpackage system.chat.command
|
* @subpackage system.chat.command
|
||||||
*/
|
*/
|
||||||
class NotFoundException extends \Exception { }
|
class NotFoundException extends \Exception {
|
||||||
|
/**
|
||||||
|
* given command
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $command = '';
|
||||||
|
|
||||||
|
public function __construct($command) {
|
||||||
|
$this->command = $command;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the given command
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCommand() {
|
||||||
|
return $this->command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -55,7 +55,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
|||||||
foreach ($color as $key => $val) {
|
foreach ($color as $key => $val) {
|
||||||
if (isset(self::$colors[$val])) $color[$key] = self::$colors[$val];
|
if (isset(self::$colors[$val])) $color[$key] = self::$colors[$val];
|
||||||
else {
|
else {
|
||||||
if (!$regex->match($val)) throw new \chat\system\command\NotFoundException();
|
if (!$regex->match($val)) throw new \InvalidArgumentException();
|
||||||
|
|
||||||
$matches = $regex->getMatches();
|
$matches = $regex->getMatches();
|
||||||
$val = $matches[1];
|
$val = $matches[1];
|
||||||
|
@ -15,7 +15,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
|||||||
parent::__construct($commandHandler);
|
parent::__construct($commandHandler);
|
||||||
|
|
||||||
if (\wcf\util\StringUtil::toLowerCase($this->commandHandler->getParameters()) != 'the fish') {
|
if (\wcf\util\StringUtil::toLowerCase($this->commandHandler->getParameters()) != 'the fish') {
|
||||||
throw new \chat\system\command\NotFoundException();
|
throw new \InvalidArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->didInit();
|
$this->didInit();
|
||||||
|
@ -39,7 +39,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
|||||||
$this->expires = min(max(-0x80000000, $expires), 0x7FFFFFFF);
|
$this->expires = min(max(-0x80000000, $expires), 0x7FFFFFFF);
|
||||||
}
|
}
|
||||||
catch (\wcf\system\exception\SystemException $e) {
|
catch (\wcf\system\exception\SystemException $e) {
|
||||||
throw new \chat\system\command\NotFoundException();
|
throw new \InvalidArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->user = User::getUserByUsername($username);
|
$this->user = User::getUserByUsername($username);
|
||||||
|
@ -24,7 +24,7 @@ public function getType() {
|
|||||||
* @see \chat\system\command\ICommand::getMessage()
|
* @see \chat\system\command\ICommand::getMessage()
|
||||||
*/
|
*/
|
||||||
public function getMessage() {
|
public function getMessage() {
|
||||||
return \wcf\system\bbcode\PreParser::getInstance()->parse(\wcf\util\StringUtil::substring($this->commandHandler->getText(), 1), explode(',', \wcf\system\WCF::getSession()->getPermission('user.chat.allowedBBCodes')));
|
return \wcf\system\bbcode\PreParser::getInstance()->parse(\chat\system\command\CommandHandler::COMMAND_CHAR.$this->commandHandler->getParameters(), explode(',', \wcf\system\WCF::getSession()->getPermission('user.chat.allowedBBCodes')));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
|||||||
$this->message = \wcf\util\StringUtil::trim($message);
|
$this->message = \wcf\util\StringUtil::trim($message);
|
||||||
}
|
}
|
||||||
catch (\wcf\system\exception\SystemException $e) {
|
catch (\wcf\system\exception\SystemException $e) {
|
||||||
throw new \chat\system\command\NotFoundException();
|
throw new \InvalidArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->user = User::getUserByUsername($username);
|
$this->user = User::getUserByUsername($username);
|
||||||
|
@ -136,7 +136,7 @@
|
|||||||
> .chatSidebarMenu {
|
> .chatSidebarMenu {
|
||||||
background: @wcfContentBackgroundColor;
|
background: @wcfContentBackgroundColor;
|
||||||
margin: -14px 0 0;
|
margin: -14px 0 0;
|
||||||
.borderRadius(0);
|
border-radius: 0px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@
|
|||||||
<item name="chat.general.profile"><![CDATA[Profil]]></item>
|
<item name="chat.general.profile"><![CDATA[Profil]]></item>
|
||||||
|
|
||||||
<item name="chat.general.information"><![CDATA[Information]]></item>
|
<item name="chat.general.information"><![CDATA[Information]]></item>
|
||||||
<item name="chat.general.information.chatUpdate"><![CDATA[Der Chat wurde aktualisiert. Bitte lade die Seite neu, da es sonst zu Fehlern kommen kann.]]></item>
|
<item name="chat.general.information.chatUpdate"><![CDATA[Der Chat wurde aktualisiert. Bitte laden Sie die Seite neu, da es sonst zu Fehlern kommen kann.]]></item>
|
||||||
<item name="chat.general.information.suspension"><![CDATA[{lang}chat.suspension.{$suspension->type}{/lang} ({if $room}{$room}{else}{lang}chat.room.global{/lang}{/if})]]></item>
|
<item name="chat.general.information.suspension"><![CDATA[{lang}chat.suspension.{$suspension->type}{/lang} ({if $room}{$room}{else}{lang}chat.room.global{/lang}{/if})]]></item>
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
|
@ -44,10 +44,12 @@
|
|||||||
<minvalue>1</minvalue>
|
<minvalue>1</minvalue>
|
||||||
<maxvalue>5000</maxvalue>
|
<maxvalue>5000</maxvalue>
|
||||||
</option>
|
</option>
|
||||||
<option name="chat_show_version">
|
<option name="chat_command_aliases">
|
||||||
<categoryname>chat.general</categoryname>
|
<categoryname>chat.general</categoryname>
|
||||||
<optiontype>boolean</optiontype>
|
<optiontype>textarea</optiontype>
|
||||||
<defaultvalue>1</defaultvalue>
|
<defaultvalue>afk:away
|
||||||
|
col:color
|
||||||
|
msg:whisper</defaultvalue>
|
||||||
</option>
|
</option>
|
||||||
<!-- general chat options end -->
|
<!-- general chat options end -->
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<isapplication>1</isapplication>
|
<isapplication>1</isapplication>
|
||||||
<version>3.0.0 Alpha 59</version><!-- Codename: Codenames are overrated -->
|
<version>3.0.0 Alpha 59</version><!-- Codename: Codenames are overrated -->
|
||||||
<date>2011-11-26</date>
|
<date>2011-11-26</date>
|
||||||
|
<license><![CDATA[Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>]]></license>
|
||||||
</packageinformation>
|
</packageinformation>
|
||||||
|
|
||||||
<authorinformation>
|
<authorinformation>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<dt>{lang}chat.general.copyright.leader{/lang}</dt>
|
<dt>{lang}chat.general.copyright.leader{/lang}</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://tims.bastelstu.be/">Tim Düsterhus</a></li>
|
<li><a href="http://tims.bastelstu.be/"{if EXTERNAL_LINK_TARGET_BLANK} target="_blank"{/if}>Tim Düsterhus</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@ -14,8 +14,8 @@
|
|||||||
<dt>{lang}chat.general.copyright.developer{/lang}</dt>
|
<dt>{lang}chat.general.copyright.developer{/lang}</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://tims.bastelstu.be/">Tim Düsterhus</a></li>
|
<li><a href="http://tims.bastelstu.be/"{if EXTERNAL_LINK_TARGET_BLANK} target="_blank"{/if}>Tim Düsterhus</a></li>
|
||||||
<li><a href="https://github.com/max-m">Maximilian Mader</a></li>
|
<li><a href="https://github.com/max-m"{if EXTERNAL_LINK_TARGET_BLANK} target="_blank"{/if}>Maximilian Mader</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@ -23,7 +23,7 @@
|
|||||||
<dt>{lang}chat.general.copyright.graphics{/lang}</dt>
|
<dt>{lang}chat.general.copyright.graphics{/lang}</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://www.cls-design.com/">Tom</a></li>
|
<li><a href="http://www.cls-design.com/"{if EXTERNAL_LINK_TARGET_BLANK} target="_blank"{/if}>Tom</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@ -37,10 +37,10 @@
|
|||||||
<dt>{lang}chat.general.copyright.thanks{/lang}</dt>
|
<dt>{lang}chat.general.copyright.thanks{/lang}</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://www.wbbaddons.de/user/2020-noone/">-noone-</a></li>
|
<li><a href="http://www.wbbaddons.de/user/2020-noone/"{if EXTERNAL_LINK_TARGET_BLANK} target="_blank"{/if}>-noone-</a></li>
|
||||||
<li><a href="https://github.com/Gabbid">Gabi</a></li>
|
<li><a href="https://github.com/Gabbid"{if EXTERNAL_LINK_TARGET_BLANK} target="_blank"{/if}>Gabi</a></li>
|
||||||
<li><a href="https://github.com/Leon-">Stefan Hahn</a></li>
|
<li><a href="https://github.com/Leon-"{if EXTERNAL_LINK_TARGET_BLANK} target="_blank"{/if}>Stefan Hahn</a></li>
|
||||||
<li><a href="http://www.wbbaddons.de">Martin Schwendowius</a></li>
|
<li><a href="http://www.wbbaddons.de"{if EXTERNAL_LINK_TARGET_BLANK} target="_blank"{/if}>Martin Schwendowius</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
Loading…
Reference in New Issue
Block a user