mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Read out available commands
This commit is contained in:
parent
9bb3a337a7
commit
9d637efa15
@ -180,7 +180,7 @@ The the word the caret is in will be passed to `autocomplete` and replaced if a
|
||||
if beforeComplete is '' and toComplete.substring(0, 1) is '/'
|
||||
regex = new RegExp "^#{WCF.String.escapeRegExp toComplete.substring 1}", "i"
|
||||
# TODO: Proper command list
|
||||
commands = (command for command in [ 'gmute', 'gban', 'ban', 'mute', 'whisper', 'where', 'info' ] when regex.test command)
|
||||
commands = (command for command in v.config.installedCommands when regex.test command)
|
||||
|
||||
toComplete = '/' + commands[autocomplete.offset++ % commands.length] + ' ' if commands.length isnt 0
|
||||
else
|
||||
|
@ -50,6 +50,13 @@ class ChatPage extends \wcf\page\AbstractPage {
|
||||
*/
|
||||
public $rooms = array();
|
||||
|
||||
/**
|
||||
* List of installed commands.
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
public $commands = array();
|
||||
|
||||
/**
|
||||
* List of smilies in the default category.
|
||||
*
|
||||
@ -81,6 +88,7 @@ public function assignVariables() {
|
||||
'room' => $this->room,
|
||||
'roomID' => $this->roomID,
|
||||
'rooms' => $this->rooms,
|
||||
'commands' => $this->commands,
|
||||
'defaultSmilies' => $this->defaultSmilies,
|
||||
'smileyCategories' => $this->smileyCategories,
|
||||
'sidebarCollapsed' => \wcf\system\user\collapsible\content\UserCollapsibleContentHandler::getInstance()->isCollapsed('com.woltlab.wcf.collapsibleSidebar', 'be.bastelstu.chat.ChatPage'),
|
||||
@ -95,6 +103,7 @@ public function readData() {
|
||||
parent::readData();
|
||||
|
||||
$this->readRoom();
|
||||
$this->readCommands();
|
||||
|
||||
// get default smilies
|
||||
if (MODULE_SMILEY) {
|
||||
@ -124,6 +133,21 @@ public function readParameters() {
|
||||
if (isset($_REQUEST['id'])) $this->roomID = (int) $_REQUEST['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads installed commands.
|
||||
*/
|
||||
public function readCommands() {
|
||||
$regex = new \wcf\system\Regex('Command.class.php$');
|
||||
$directory = \wcf\utilDirectoryUtil::getInstance(CHAT_DIR.'lib/system/command/commands/', false);
|
||||
$files = $directory->getFiles(SORT_ASC, $regex);
|
||||
|
||||
foreach ($files as $file) {
|
||||
$command = $regex->replace(basename($file), '');
|
||||
if ($command == 'Plain') continue;
|
||||
$this->commands[] = \wcf\util\StringUtil::toLowerCase($command);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads room data.
|
||||
*/
|
||||
|
@ -33,7 +33,8 @@
|
||||
{$roomID},
|
||||
{
|
||||
reloadTime: {@CHAT_RELOADTIME},
|
||||
messageURL: '{link application="chat" controller="NewMessages"}{/link}'
|
||||
messageURL: '{link application="chat" controller="NewMessages"}{/link}',
|
||||
installedCommands: [ {implode from=$commands item='command'}'{$command|encodeJS}'{/implode} ]
|
||||
},
|
||||
new WCF.Template('{literal}{if $newMessageCount}({#$newMessageCount}) {/if}{$title} - {/literal}{"chat.general.title"|language|encodeJS} - {PAGE_TITLE|language|encodeJS}'),
|
||||
new WCF.Template('{@$messageTemplate|encodeJS}'),
|
||||
|
Loading…
Reference in New Issue
Block a user