Bots Home
|
Create an App
ABCR
Author:
aety
Description
Source Code
Launch Bot
Current Users
Created by:
Aety
if (cb == null) { var cb = { app_id: -1, slot: -1, changeRoomSubject: function(new_subject) {}, drawPanel: function() {}, log: function(message) {}, onDrawPanel: function(func) {}, onEnter: function(func) {}, onLeave: function(func) {}, onMessage: function(func) {}, onShowStatus: function(func) {}, onTip: function(func) {}, room_slug: '', sendNotice: function(message, to_user, background, foreground, weight, to_group) {}, setTimeout: function(func, msec) {}, settings_choices: [], settings: {}, tipOptions: function(func) {}, limitCam_start: function(message, allowed_users) {}, limitCam_stop: function() {}, limitCam_addUsers: function(allowed_users) {}, limitCam_removeUsers: function(removed_users) {}, limitCam_removeAllUsers: function() {}, limitCam_userHasAccess: function(user) {}, limitCam_allUsersWithAccess: function() {}, limitCam_isRunning: function() {}, }; } cb.settings_choices = [ {name: 'cmdPrefix', type: 'str', label: 'Prefix for bot commands. e.g. "/command"', defaultValue: '/'} ]; var the_bot = { commands: {}, timers: {}, notifications: {}, settings: {}, variables: {} }; cb.onMessage(function(msg) { var message = msg.m.split(" "); var prefix = the_bot.settings.cmdPrefix; for(var cmd in the_bot.commands) { if(message[0] == prefix+cmd) { msg = the_bot.commands[cmd].execute(msg); break; } var i = the_bot.commands[cmd].aliases.length; while(i--) { if(message[0] == prefix+the_bot.commands[cmd].aliases[i]) { msg = the_bot.commands[cmd].execute(msg); break; } } } return msg; }); the_bot.commands.bothelp = { aliases: ["help", "h"], cbsettings: function() {}, execute: function(msg) { var message = msg.m.split(" "); var output = ""; if(message.length <= 1 || !message[1] || message[1] == "") { output = the_bot.commands.bothelp.help(); } else { for(var cmd in the_bot.commands) { if(message[1] == cmd) { output = the_bot.commands[cmd].help(); break; } var i = the_bot.commands[cmd].aliases.length; while(i--) { if(message[1] == the_bot.commands[cmd].aliases[i]) { output = the_bot.commands[cmd].help(); break; } } } } cb.sendNotice(output, msg.user, '', '', '', ''); return hidemsg(msg); }, help: function() { return "Usage: " + the_bot.cmdPrefix + "bothelp <command>"; } }; the_bot.commands.hideme = { aliases: ["hidden", "secretmsg", "x"], cbsettings: function() {}, execute: function(msg) { return hidemsg(msg); }, help: function() { return "Don't show this message to the chat!"; } }; the_bot.commands.counter = { aliases: ["c", "countup", "inc", "++"], cbsettings: function() { cb.settings_choices.push({name:'counter_one',type:'int',label:'Counter Val:',defaultValue:2}); }, execute: function(msg) { cb.sendNotice(++the_bot.settings.counter_one, msg.user, '', '', '', ''); return hidemsg(msg); }, help: function() { return "increment a counter"; } }; the_bot.commands.ev = { aliases: ["e", "eval"], cbsettings: function() {}, execute: function(msg) { var message = msg.m.split(" "); message.shift(); eval(message.join(" ")); return hidemsg(msg); }, help: function() { return "Please, don't work."; } }; the_bot.commands.randint = { aliases: ["random"], cbsettings: function() {}, execute: function(msg) { var message = msg.m.split(" "); message.shift(); min = Math.ceil(parseInt(message.shift())); max = Math.floor(parseInt(message.shift())); cb.sendNotice(Math.floor(Math.random() * (max - min + 1)) + min, msg.user, '', '', '', ''); }, help: function() { return "print a random int to chat"; } }; function hidemsg(msg){ msg["X-Spam"] = true; msg.background = "#EEEEEE"; return msg; } function init() { cb.log("ID: " + cb.app_id + "\nSlot: " + cb.slot); //app id and slot in bot order // add command settings to the settings_choices for(var cmd in the_bot.commands) { the_bot.commands[cmd].cbsettings(); } //load cb settings into the bot for(var sett in cb.settings) { the_bot.settings[sett] = cb.settings[sett]; } } // cbsettings(); init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.