Bots Home
|
Create an App
asdfsdasdasda
Author:
zaxvert2
Description
Source Code
Launch Bot
Current Users
Created by:
Zaxvert2
class BaseBot{get description(){return"Default BaseBot description."}command(message){}onMessage(message){}onTip(){}onEnter(user){}}class PMRequestBot extends BaseBot{get description(){return"This bot notify users that sends a request in chat for pm that it costs tokens. It can also send the same type of message to users when they enter the room."}constructor(){super(),cb.settings_choices.push({name:"pmreq_header",type:"choice",choice1:" ",defaultValue:" ",label:"-------------------------------- PM-request settings: --------------------------------"},{name:"pmreq_cost",type:"int",minValue:1,maxValue:999999,defaultValue:5,label:"Token cost for PM"},{name:"pmreq_mod_allowed",type:"choice",choice1:"Yes",choice2:"No",defaultValue:"Yes",label:"Are mods allowed to operate the bot?"},{name:"pmreq_join_on",type:"choice",choice1:"On",choice2:"Off",defaultValue:"On",label:"On-join notifications"},{name:"pmreq_join_message",type:"str",minLength:1,maxLength:255,defaultValue:"Welcome, tip {cost} for pm!",label:'Message when joining, include "{cost}" where you want the tip cost to show up'},{name:"pmreq_ask_on",type:"choice",choice1:"On",choice2:"Off",defaultValue:"On",label:"Ask notifications"},{name:"pmreq_ask_message",type:"str",minLength:1,maxLength:255,defaultValue:"Tip {cost} for pm!",label:'Message when asking, include "{cost}" where you want the tip cost to show up'}),this.commands={},this.commands.cost=function(params,message){if(isEmpty(params))return void cb.sendNotice("/pmreq: No cost parameter was provided, a new cost was not set.",message.user,white,red,"normal","");let cost=parseInt(params);isNaN(cost)?cb.sendNotice("/pmreq: The provided cost parameter could not be parsed correctly, a new cost was not set.",message.user,white,red,"normal",""):(cb.settings.pmreq_cost=cost,cb.sendNotice("/pmreq: Cost was set to: "+cost,message.user,white,green,"normal",""))},this.commands.askmsg=function(params,message){isEmpty(params)?cb.sendNotice("/pmreq: No message parameter was provided, a new on-ask message was not set.",message.user,white,red,"normal",""):(cb.settings.pmreq_ask_message=params,cb.sendNotice("/pmreq: On-ask message was set to: "+params,message.user,white,green,"normal",""))},this.commands.joinmsg=function(params,message){isEmpty(params)?cb.sendNotice("/pmreq: No message parameter was provided, a new on-join message was not set.",message.user,white,red,"normal",""):(cb.settings.pmreq_ask_message=params,cb.sendNotice("/pmreq: On-join message was set to: "+params,message.user,white,green,"normal",""))},this.commands.askon=function(params,message){if(isEmpty(params))return void cb.sendNotice("/pmreq: No on/off parameter was provided, no changes has been made.",message.user,white,red,"normal","");let isEnabled;if(checkIfTrueFromString(params))isEnabled=!0;else{if(!checkIfFalseFromString(params))return void cb.sendNotice("/pmreq: The provided on/off parameter could not be parsed correctly, no changes has been made.",message.user,white,red,"normal","");isEnabled=!1}cb.settings.pmreq_ask_on=isEnabled,cb.sendNotice("/pmreq: On-ask notifications were set to: "+isEnabled,message.user,white,green,"normal","")},this.commands.joinon=function(params,message){if(isEmpty(params))return void cb.sendNotice("/pmreq: No on/off parameter was provided, no changes has been made.",message.user,white,red,"normal","");let isEnabled;if(checkIfTrueFromString(params))isEnabled=!0;else{if(!checkIfFalseFromString(params))return void cb.sendNotice("/pmreq: The provided on/off parameter could not be parsed correctly, no changes has been made.",message.user,white,red,"normal","");isEnabled=!1}cb.settings.pmreq_join_on=isEnabled,cb.sendNotice("/pmreq: On-join notifications were set to: "+isEnabled,message.user,white,green,"normal","")},this.commands.commands=function(params,message){let commandsMsg="/pmreq: Available commands are:\ncost [cost] : Sets the cost amount of both message types.\naskmsg [message] : Sets the message for when asking for pm in chat.\njoinmsg [message] : Sets the message for when joining the room.\naskon [on/yes/true/off/no/false] : Turns on or off the message for when asking in chat.\njoinon [on/yes/true/off/no/false]: Turns on or off the message for when joining the room.";cb.sendNotice(commandsMsg,message.user,white,black,"normal","")}}command(message){if(!this.hasCommandAccess(message))return void cb.sendNotice("Permission denied!",message.user,white,red,"normal","");let remainder=message.m.replace("/pmreq","").trim();if(!remainder)return void cb.sendNotice("No command was provided to /pmreq",message.user,white,red,"normal","");let cmd=remainder.match(commandRegex)[0].toLowerCase(),params=remainder.replace(cmd,"").trim();try{this.commands[cmd](params,message)}catch(e){cb.sendNotice('/pmreq: "'+remainder+'" That commands does not exist. Commands can be listed with /pmreq commands',message.user,white,red,"normal","")}}onMessage(message){settingToBool(cb.settings.pmreq_ask_on)&&message.m.toLowerCase().includes("pm")&&cb.sendNotice(cb.settings.pmreq_ask_message.replace("{cost}",cb.settings.pmreq_cost),message.user,white,red,normalFontWeight,"")}onEnter(user){settingToBool(cb.settings.pmreq_join_on)&&cb.sendNotice(cb.settings.pmreq_join_message.replace("{cost}",cb.settings.pmreq_cost),user,white,black,normalFontWeight,"")}hasCommandAccess(message){return message.user==broadcaster||settingToBool(cb.settings.pmreq_mod_allowed)&&message.is_mod}}class SecretShowBot extends BaseBot{get description(){return"A bot for doing secret/hidden shows with whitelist/blacklist functionality"}constructor(){super();let self=this;if(cb.settings_choices.push({name:"secshow_header",type:"choice",choice1:" ",defaultValue:" ",label:"-------------------------------- Secret Show settings: --------------------------------"},{name:"secshow_cost_before",type:"int",minValue:1,maxValue:999999,defaultValue:100,label:"Cost to join the secret show before it starts"},{name:"secshow_cost_during",type:"int",minValue:1,maxValue:999999,defaultValue:100,label:"Cost to join the secret show during it is going"},{name:"secshow_message",type:"str",minLength:1,maxLength:255,defaultValue:"Secret show in progress! Tip {cost} for access.",label:"Message when not viewing the secret show, include {cost} to have the cost for joining after start in the message"},{name:"secshow_mod_allowed_change",type:"choice",choice1:"Yes",choice2:"No",defaultValue:"Yes",label:"Are mods allowed to operate the bot?"},{name:"secshow_output_to_mods",type:"choice",choice1:"Yes",choice2:"No",defaultValue:"Yes",label:"Send add/remove notices to mods?"},{name:"secshow_output_to_broadcaster",type:"choice",choice1:"Yes",choice2:"No",defaultValue:"Yes",label:"Send add/remove notices to broadcaster?"},{name:"secshow_mod_allowed_view",type:"choice",choice1:"Yes",choice2:"No",defaultValue:"Yes",label:"Are mods always allowed to watch the secret show?"},{name:"secshow_fans_allowed_view",type:"choice",choice1:"Yes",choice2:"No",defaultValue:"Yes",label:"Is the fan club always allowed to watch the secret show?"},{name:"secshow_whitelist",type:"str",minLength:1,maxLength:9999,defaultValue:"",label:"List of names that are always allowed, seperated by comma (eg. name1,name2,name3 etc.)",required:!1},{name:"secshow_blacklist",type:"str",minLength:1,maxLength:9999,defaultValue:"",label:"List of names that are never allowed, seperated by comma (eg. name1,name2,name3 etc.)",required:!1}),this.blacklist=[],this.whitelist=[],cb.settings.secshow_blacklist&&0!=cb.settings.secshow_blacklist.length){let bl;cb.settings.secshow_blacklist.split(",").forEach(name=>this.blacklist.push(name))}cb.settings.secshow_whitelist&&0!=cb.settings.secshow_whitelist.length&&(this.whitelist=cb.settings.secshow_whitelist.split(","),this.whitelist.forEach(name=>this.addUser(name))),this.commands={},this.commands.start=function(params,message){cb.limitCam_isRunning()?cb.sendNotice("/secshow: Secret show is already running!",message.user,white,red,normalFontWeight,""):(cb.limitCam_start(cb.settings.secshow_message.replace("{cost}",cb.settings.secshow_cost_during)),self.sendNoticeToRoom("The secret show has started!"))},this.commands.stop=function(params,message){cb.limitCam_isRunning()?(cb.limitCam_stop(cb.settings.secshow_message),self.sendNoticeToRoom("The secret show has ended!")):cb.sendNotice("/secshow: Secret show is not running!",message.user,white,red,normalFontWeight,"")},this.commands.list=function(params,message){let allowed=cb.limitCam_allUsersWithAccess();if(allowed&&!allowed.length)return void cb.sendNotice("/secshow: No users currently has access.",message.user,white,black,normalFontWeight,"");let listMsg="/secshow: These users have access to the secret show:\n";allowed.forEach(name=>listMsg+=name+", "),cb.sendNotice(listMsg,message.user,white,black,normalFontWeight,"")},this.commands.clear=function(params,message){cb.limitCam_removeAllUsers(),self.sendNoticeToModsAndBroadcaster("/secshow: The user list has been cleared.")},this.commands.addfromwhitelist=function(params,message){cb.settings.secshow_whitelist&&0!=cb.settings.secshow_whitelist.length&&self.whitelist.forEach(name=>self.addUser(name))},this.commands.add=function(params,message){isEmpty(params)?cb.sendNotice("/secshow: No user parameter was provided, no user was added.",message.user,white,red,normalFontWeight,""):cb.limitCam_userHasAccess(params)?cb.sendNotice("/secshow: That user is already in the list",message.user,white,red,normalFontWeight,""):self.addUser(params)},this.commands.remove=function(params,message){isEmpty(params)?cb.sendNotice("/secshow: No user parameter was provided, no user was removed.",message.user,white,red,normalFontWeight,""):cb.limitCam_userHasAccess(params)?self.removeUser(params):cb.sendNotice("/secshow: That user is not in the list.",message.user,white,red,normalFontWeight,"")},this.commands.check=function(params,message){isEmpty(params)?cb.sendNotice("/secshow: No user parameter was provided, nothing could be checked.",message.user,white,red,normalFontWeight,""):cb.limitCam_userHasAccess(params)?cb.sendNotice("/secshow: The user "+params+" is in the list.",message.user,white,black,normalFontWeight,""):cb.sendNotice("/secshow: The user "+params+" is not in the list.",message.user,white,black,normalFontWeight,"")},this.commands.setmsg=function(params,message){isEmpty(params)?cb.sendNotice("/secshow: No message parameter was provided, no message was set.",message.user,white,red,normalFontWeight,""):(cb.settings.secshow_message=params,cb.sendNotice("/secshow: Message for users who can not view the show was set to: "+params,message.user,white,green,normalFontWeight,""))},this.commands.costbefore=function(params,message){if(isEmpty(params))return void cb.sendNotice("/secshow: No cost parameter was provided, a new cost was not set.",message.user,white,red,normalFontWeight,"");let cost=parseInt(params);isNaN(cost)?cb.sendNotice("/secshow: The provided cost parameter could not be parsed correctly, a new cost was not set.",message.user,white,red,normalFontWeight,""):(cb.settings.secshow_cost_before=cost,cb.sendNotice("/secshow: Cost before starting was set to: "+cost,message.user,white,green,normalFontWeight,""))},this.commands.costduring=function(params,message){if(isEmpty(params))return void cb.sendNotice("/secshow: No cost parameter was provided, a new cost was not set.",message.user,white,red,normalFontWeight,"");let cost=parseInt(params);isNaN(cost)?cb.sendNotice("/secshow: The provided cost parameter could not be parsed correctly, a new cost was not set.",message.user,white,red,normalFontWeight,""):(cb.settings.secshow_cost_during=cost,cb.sendNotice("/secshow: Cost during show was set to: "+cost,message.user,white,green,normalFontWeight,""))},this.commands.commands=function(params,message){let commandsMsg="/secshow: Available commands are:\nstart : Starts the secret show if it is not already started.\nstop : Stops the secret show if it is not already stopped.\nadd [user] : Adds a user to the allowed list.\nremove [user] : Removes a user from the allowed list.\ncheck [user] : Checks if the user is in the allowed list.\nlist : Lists which users are currently allowed to watch.\nclear : Clears the list of who is currently allowed to watch (overrides whitelist).\naddfromwhitelist : Adds all users from whitelist, useful for after doing a clear.\nsetmsg [message] : Sets the message that is shown to users that are not allowed to view, include {cost} to have the cost for joining after start in the message.\ncostbefore [cost]: Sets the cost to get added to the list of allowed before a show starts.\ncostduring [cost]: Sets the cost to get added to the list of allowed during the show is running.";cb.sendNotice(commandsMsg,message.user,white,black,"normal","")}}command(message){if(!this.hasCommandAccess(message))return void cb.sendNotice("/secshow: Permission denied!",message.user,white,red,"normal","");let remainder=message.m.replace("/secshow","").trim();if(!remainder)return void cb.sendNotice("/secshow: No command was provided to /secshow",message.user,white,red,"normal","");let cmd=remainder.match(commandRegex)[0].toLowerCase(),params=remainder.replace(cmd,"").trim();try{this.commands[cmd](params,message)}catch(e){cb.sendNotice('/secshow: The command "'+remainder+'" does not exist. Commands can be listed with /secshow commands',message.user,white,red,"normal","")}}onEnter(user){(settingToBool(cb.settings.secshow_mod_allowed_view)&&user.is_mod||settingToBool(cb.settings.secshow_fans_allowed_view)&&user.in_fanclub||this.whitelist.includes(user.user))&&this.addUser(user.user)}onTip(tip){cb.limitCam_isRunning()?parseInt(tip.amount)>=cb.settings.secshow_cost_during&&this.addUser(tip.from_user):parseInt(tip.amount)>=cb.settings.secshow_cost_before&&this.addUser(tip.from_user)}hasCommandAccess(message){return message.user==broadcaster||settingToBool(cb.settings.secshow_mod_allowed_change)&&message.is_mod}addUser(name){cb.limitCam_userHasAccess(name)||(this.blacklist.includes(name)?this.sendBlockedNotice(name):(cb.limitCam_addUsers(name),this.sendAddNotice(name)))}removeUser(name){cb.limitCam_userHasAccess(name)&&(cb.limitCam_removeUsers(name),this.sendRemovedNotice(name))}sendNoticeToRoom(message){cb.sendNotice(message,"",white,black,normalFontWeight,"")}sendNoticeToModsAndBroadcaster(message){settingToBool(cb.settings.secshow_output_to_mods)&&cb.sendNotice(message,"",white,black,normalFontWeight,mods),settingToBool(cb.settings.secshow_output_to_broadcaster)&&cb.sendNotice(message,broadcaster,white,black,normalFontWeight,"")}sendAddNotice(name){cb.sendNotice("You have been added to the secret show.",name,white,black,normalFontWeight,""),this.sendNoticeToModsAndBroadcaster("/secshow: The user "+name+" was added to the secret show.")}sendRemovedNotice(name){cb.sendNotice("You have been removed from the secret show.",name,white,black,normalFontWeight,""),this.sendNoticeToModsAndBroadcaster("/secshow: The user "+name+" was removed from the secret show.")}sendBlockedNotice(name){this.sendNoticeToModsAndBroadcaster("/secshow: The user "+name+" could not be added to the secret show due to them being on the blacklist.")}}const wrapperBotName="EllenBot",white="#FFFFFF",black="#000000",red="#C80000",green="#008C00",normalFontWeight="normal",mods="red",botNameRegex=/^(\/[\w]+)/,commandRegex=/^([\w]+)/,broadcaster=cb.room_slug;cb.settings_choices=[{name:"subbot_pmreq",type:"choice",choice1:"On",choice2:"Off",defaultValue:"On",label:"Enable PM-request sub-bot?"},{name:"subbot_secshow",type:"choice",choice1:"On",choice2:"Off",defaultValue:"On",label:"Enable Secret Show sub-bot?"}];let bots=new Map;function sendBotList(message){let botsMsg="Available bots in EllenBot are:";bots.forEach((bot,name)=>{botsMsg+="\n"+name+" : "+bot.description}),cb.sendNotice(botsMsg,message.user,white,black,"normal",""),message["X-Spam"]=!0}function settingToBool(setting){let settingLC=setting.toLowerCase();return"true"===settingLC||"on"===settingLC||"yes"===settingLC}function checkIfTrueFromString(input){let inputLC=input.toLowerCase();return"true"===inputLC||"on"===inputLC||"yes"===inputLC}function checkIfFalseFromString(input){let inputLC=input.toLowerCase();return"false"===inputLC||"off"===inputLC||"no"===inputLC}function isEmpty(str){return!str||0===str.length}bots.set("/pmreq",new PMRequestBot),bots.set("/secshow",new SecretShowBot),cb.settings.subbot_pmreq&&!settingToBool(cb.settings.subbot_pmreq)&&bots.delete("/pmreq"),cb.settings.subbot_secshow&&!settingToBool(cb.settings.subbot_secshow)&&bots.delete("/secshow"),cb.onMessage((function(message){if(message.m.startsWith("/"))if(message.m.startsWith("/listbots"))sendBotList(message);else try{let botName=message.m.match(botNameRegex)[0].toLowerCase();bots.get(botName).command(message),message["X-Spam"]=!0}catch(e){}else for(let bot of bots.values())bot.onMessage(message);return message})),cb.onTip((function(tip){for(let bot of bots.values())bot.onTip(tip)})),cb.onEnter((function(user){for(let bot of bots.values())bot.onEnter(user)}));
© Copyright Chaturbate 2011- 2025. All Rights Reserved.