This repository has been archived by the owner on Feb 11, 2023. It is now read-only.
forked from Frug/AJAX-Chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Mod takeover
Frug edited this page Oct 11, 2012
·
1 revision
This modification adds the command /takeover which allows users (or only admins and mods) to make the chatbot say things.
Open lib/class/customAJAXChat.php
Before the last } add the following code:
// Add custom commands function parseCustomCommands($text, $textParts) { switch($textParts[0]) { case '/takeover': $this->insertChatBotMessage( $this->getChannel(), $text ); return true; default: return false; } }
Now open js/custom.js and add this to the end of the file:
ajaxChat.replaceCustomCommands = function(text, textParts) { switch(textParts[0]) { case '/takeover': text=text.replace('/takeover', ' '); return '<span class="chatBotMessage">' + text + '</span>'; default: return text; } }
This will give all users the ability to use the /takeover command.
If you want to only allow this command for administrators and moderators, you should put the following in customAJAXChat.php instead of the first part of the code provided above. Notice that there is an added "if" statement:
function parseCustomCommands($text, $textParts) { if($this->getUserRole() == AJAX_CHAT_ADMIN || $this->getUserRole() == AJAX_CHAT_MODERATOR) { switch($textParts[0]) { case '/takeover': $this->insertChatBotMessage( $this->getChannel(), $text ); return true; default: return false; } } }
Thank you to KID52 for help with this mod
Blueimp's AJAX Chat is released under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3