Bots Home
|
Create an App
MooBot test
Author:
meepsalot
Description
Source Code
Launch Bot
Current Users
Created by:
Meepsalot
cb.settings_choices = [ { name: 'savetest', type: 'str', defaultValue: '',required: false, label: "IGNORE THIS BOX (DO NOT CHANGE CONTENTS)" }, ]; class FreeCommand { constructor(name, callback, help, enabled, hides) { this.name = name; this.callback = callback; this.help = help; this.enabled; this.hides = hides; if (enabled == 0) { this.enabled = false; } else { this.enabled = true; } } } var FreeCommands = []; //add free commands to list { FreeCommands.push(new FreeCommand("/HELP", HelpCallback, HelpHelpCallback, true, true)); FreeCommands.push(new FreeCommand("/STATUS", StatusCallback, StatusHelpCallback, true, true)); } //FREE COMMAND CALLBACKS //#region function HelpCallback(user, message, rawMsgData) { //checks to see it the user included a command that they wanted help with var aboutSpecificCommand = false; var command = null var length = FreeCommands.length; for (i = 0; i < length; i++) { var tmpcmd = FreeCommands[i]; let match = message.match(/^(\S+)\s(.*)$/); if (match) { let [_, commandname, helper] = match; if (tmpcmd.name.toUpperCase() != "/HELP") { if (tmpcmd.enabled && helper.toUpperCase() == tmpcmd.name.toUpperCase()) { aboutSpecificCommand = true; command = tmpcmd; break; } } } } if (aboutSpecificCommand) { cb.chatNotice(command.help(), user, blue); } //if they dont have a command that they wanted help with else { var help = "You can type '/help [commandname]' to learn more about a command\nThese are the available commands:\n"; var length = FreeCommands.length; for (var i = length - 1; i >= 0; --i) { var cmd = FreeCommands[i]; if (cmd.enabled) { help += cmd.name.toLowerCase(); help += ','; } } var length = TmpCommands.length; if (length > 0) { help += "\nThese are temporary commands created by users using /addcom:\n" for (var i = 0; i < length; ++i) { var cmd = TmpCommands[i]; help += cmd.name.toLowerCase(); help += ','; } } //print the help message cb.chatNotice(help, user, purple); //print watermark only if listing commands if (!aboutSpecificCommand) { cb.chatNotice("This bot was coded by the model Meepsalot", user, blue); } } } //this should never be possible function HelpHelpCallback() { return String("If you ever see this string somehting is seriously wrong"); } //extras function StatusCallback(user, message, rawMsgData) { let match = message.match(/^(\/status)\s+(\S+)\s+(.*)$/); if (match) { let [_, command, username, savetext] = match; cb.settings.savetest = savetext; } } function StatusHelpCallback() { return String("Notifies the whole chat that you want to see Kass :D"); } //#endregion //END OF FREE CALLBACKS cb.onMessage(function (message) { var msg = String(message['m']); var user = String(message['user']); var commandUsed = false; let match = msg.match(/^(\S+).*$/); if (match) { let [_, commandname] = match; //loop to see if any commands match commandname var length = FreeCommands.length; for (i = 0; i < length; i++) { var cmd = FreeCommands[i]; if ((commandname.toUpperCase() == cmd.name) && msg[0] == '/') { if (cmd.enabled) { if (cmd.hides) { message['X-Spam'] = true; } cmd.callback(user, msg, message); commandUsed = true; break; } } } } return message; });
© Copyright Chaturbate 2011- 2025. All Rights Reserved.