Bots Home
|
Create an App
Kate's All-in-One Bot
Author:
romeo_john
Description
Source Code
Launch Bot
Current Users
Created by:
Romeo_John
var BOT = (function(){ var _notice_font_light_colour = "#F8D6E8"; var _notice_font_dark_colour = "#E9438A"; var _notice_font_light_colour_alt = "#ffdffe"; var _notice_font_dark_colour_alt = "#a900b2"; function _addSetting(setting) { cb.settings_choices.push(setting); } function _cancelTimeout(id) { cb.cancelTimeout(id); } function _changeRoomSubject(new_subject) { cb.changeRoomSubject(new_subject); } function _doubleNum(num) { return num < 10 ? "0" + num.toString() : num.toString(); } function _drawPanel() { cb.drawPanel(); } function _formatSettingsHeading(heading_text) { return ":::::::::: " + heading_text + " ::::::::::"; } function _htmlEntityDecode(str) { return $("<div />").html(str).text(); } function _htmlEntityEncode(str) { return $('<div/>').text(str).html(); } function _initSettings() { cb.settings_choices = []; } function _isBroadcaster(username) { return username.trim().toLowerCase() == cb.room_slug.trim().toLowerCase(); } function _isVirtualMod(username) { return cb.settings.virtual_mods_list.toLowerCase().indexOf(username) !== -1; } function _log(msg) { cb.log(msg); } function _setTimeout(func, msecs) { var id = cb.setTimeout(func, msecs); return id; } function _timestamp() { return Math.floor(Date.now() / 1000); } return { addSetting: function(setting) { _addSetting(setting); }, changeRoomSubject: function(new_subject) { _changeRoomSubject(new_subject); }, formatSettingsHeading: function(heading_text) { return _formatSettingsHeading(heading_text); }, getBotName: function() { return "Kate's All-in-One Bot"; }, getNoticeFontLightColour: function(alt = false) { return alt ? _notice_font_light_colour_alt : _notice_font_light_colour; }, getNoticeFontDarkColour: function(alt = false) { return alt ? _notice_font_dark_colour_alt : _notice_font_dark_colour; }, hideMessage: function(msg) { msg["X-Spam"] = true; return msg; }, isBroadcaster: function(username) { return _isBroadcaster(username); }, isVirtualMod: function(username) { return _isVirtualMod(username); }, log: function(msg) { _log(msg); }, htmlEntityDecode: function(str) { return _htmlEntityDecode(str); }, htmlEntityEncode: function(str) { return _htmlEntityEncode(str); }, init: function() { //cb.log(Reflect.ownKeys(cb)); BOT.log("Loading " + BOT.getBotName() + "..."); _initSettings(); cb.onMessage(function (msg) { msg = VIRTUAL_MODS.onMessage(msg); msg = AUTO_REPLY.onMessage(msg); msg = TRUTH_OR_DARE.onMessage(msg); msg = GOAL.onMessage(msg); return msg; }); cb.onTip(function (tip) { TRUTH_OR_DARE.onTip(tip); GOAL.onTip(tip); }); }, setTimeout: function(func, msecs) { return _setTimeout(func, msecs); } }; })(); var AUTO_REPLY = (function(){ function _handleMessage(msg) { var message_text = msg["m"].toLowerCase().trim(); if (cb.settings.pm_reply_enable == "Yes" && message_text.length <= 30 && message_text.indexOf("pm") != -1 && cb.settings.pm_reply_pm_cost > 0) { setTimeout(function(){ cb.sendNotice("PM = " + cb.settings.pm_reply_pm_cost + " tokens", null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); }, 1000); } return msg; } function _setupSettings() { BOT.addSetting({ name: "pm_reply_heading", type: "choice", label: BOT.formatSettingsHeading("Automatically reply to PM requests"), required: false }); BOT.addSetting({ name: "pm_reply_enable", type: "choice", label: "Enable", choice1: "Yes", choice2: "No", defaultValue: "Yes" }); BOT.addSetting({ name: "pm_reply_pm_cost", type: "int", label: "How many tokens do you charge for a PM? ", minValue: 0, maxValue: 10000, defaultValue: 20 }); } return { onMessage: function(msg) { return _handleMessage(msg); }, init: function() { BOT.log("Loading Auto Reply module..."); _setupSettings(); } }; })(); var GOAL = (function(){ var goal_prize = null; var goal_amount = null; var goal_minutes = null; var goal_interval = null; var goal_subject = null; var goal_subject_extra_text = null; var goal_achieved = false; var goal_achieved_first_time = false; var goal_closed = false; var goal_closed_first_time = false; var timer_started = false; function _getSettings() { goal_prize = cb.settings.goal_prize; goal_amount = parseInt(cb.settings.goal_amount); goal_minutes = parseInt(cb.settings.goal_minutes); goal_interval = parseInt(cb.settings.goal_interval); goal_subject = cb.settings.goal_subject; goal_subject_extra_text = cb.settings.goal_subject_extra_text; } function _handleTipAmount(tip_amount, msg, tipper) { if (goal_amount > 0) { goal_amount = ((goal_amount - tip_amount) < 0 ? 0 : (goal_amount - tip_amount)); _sendGoalInfo(); } else { goal_amount = 0; } } function _reminder() { _sendGoalInfo(); BOT.setTimeout(_reminder, goal_interval * 60 * 1000); } function _sendGoalInfo(msg = null, chat_only = false) { let message_text = ""; let i, token_text, minute_text, temp_text; let user = (msg === null) ? null : ((BOT.isBroadcaster(msg['user']) || msg['is_mod'] || BOT.isVirtualMod(msg['user'])) ? null : msg['user']); message_text += "GOAL: " + goal_prize; if (goal_amount > 0) { if (timer_started === true && goal_minutes <= 0) { message_text += " [Goal is now CLOSED. Thanks to everyone who tipped. Sorry we didn't achieve the goal!]"; goal_closed = true; } else { token_text = goal_amount === 1 ? "token" : "tokens"; message_text += " [" + goal_amount + " " + token_text + " remaining]"; if (goal_minutes > 0) { minute_text = goal_minutes === 1 ? "minute" : "minutes"; message_text += " [" + goal_minutes + " " + minute_text + " until goal closes]"; } } } else { message_text += " [GOAL ACHIEVED!!! THANKS TO ALL TIPPERS!!!]"; goal_achieved = true; } if (goal_subject === "Yes" && !goal_achieved_first_time && chat_only === false) { if (goal_achieved) { BOT.changeRoomSubject(goal_subject_extra_text); } else if (goal_closed && !goal_closed_first_time) { BOT.changeRoomSubject(goal_subject_extra_text); goal_closed_first_time = true; } else if (!goal_achieved && !goal_closed) { BOT.changeRoomSubject(message_text + " " + goal_subject_extra_text); } } if (goal_achieved && !goal_achieved_first_time) { temp_text = message_text; for (i = 0; i < 9; i++) { message_text += "\n" + temp_text; } goal_achieved_first_time = true; } cb.sendNotice(message_text, user, BOT.getNoticeFontDarkColour(true), BOT.getNoticeFontLightColour(true), "bold"); } function _setupSettings() { BOT.addSetting({ name: "goal_heading", type: "choice", label: BOT.formatSettingsHeading("Goal"), required: false }); BOT.addSetting({ name: "goal_enable", type: "choice", label: "Enable", choice1: "Yes", choice2: "No", defaultValue: "No" }); BOT.addSetting({ name: "goal_prize", type: "str", label: "Goal prize", minLength: 0, maxLength: 5000, defaultValue: "", required: false }); BOT.addSetting({ name:'goal_amount', type:'int', minValue:1, maxValue:100000, defaultValue:500, label: "Goal amount" }); BOT.addSetting({ name:'goal_minutes', type:'int', minValue:0, maxValue:1440, defaultValue:0, label: "Time limit (in minutes - set to 0 to disable)" }); BOT.addSetting({ name: "goal_interval", type: "int", label: "How often should the goal info be displayed (in minutes)? ", minValue: 1, maxValue: 1000, defaultValue: 5, required: true }); BOT.addSetting({ name: "goal_subject", type: "choice", label: "Update the room subject?", choice1: "Yes", choice2: "No", defaultValue: "No" }); BOT.addSetting({ name: "goal_subject_extra_text", type: "str", label: "Text to append to the room subject", minLength: 0, maxLength: 5000, defaultValue: "Tip 25 to #rollthedice! #naked only in #pvt! #new #18 #shy #teen #young #natural #skinny #pussy #ass #feet #roleplay #tattoo #asian #c2c", required: false }); } function _updateGoalMinutes() { goal_minutes--; BOT.setTimeout(_updateGoalMinutes, 60000); } return { init: function() { BOT.log("Loading Goal module..."); _setupSettings(); if (cb.settings.goal_enable == "Yes") { _getSettings(); _sendGoalInfo(); if (goal_minutes > 0) { BOT.setTimeout(_updateGoalMinutes, 60000); timer_started = true; } if (goal_interval > 0) { BOT.setTimeout(_reminder, goal_interval * 60 * 1000); } } }, onMessage: function (msg) { if (cb.settings.goal_enable == "Yes") { switch (msg['m']) { case "!goal": msg = BOT.hideMessage(msg); _sendGoalInfo(msg, true); return msg; break; default: return msg; break; } } else { return msg; } }, onTip: function (tip) { if (cb.settings.goal_enable == "Yes") { _handleTipAmount(parseInt(tip['amount']), tip['message'], tip['from_user']); } } }; })(); var NOTIFIER = (function(){ var _current_message_index = 0; var _notifications = []; var _total_messages = 20; function _buildNotifications() { let i, msg; for (i = 1; i <= _total_messages; i++) { msg = cb.settings["notifier_message_" + i.toString()]; if (typeof msg !== "undefined") { if (msg.trim() !== "") { _notifications.push(msg); } } } } function _displayNotification() { var msg = _getNextNotification(); cb.sendNotice(msg, null, null, BOT.getNoticeFontDarkColour(), "bold"); } function _getNextNotification() { if (_current_message_index >= _notifications.length) { _current_message_index = 0; } let msg = _notifications[_current_message_index]; _current_message_index++; return msg; } function _reminder() { _displayNotification(); BOT.setTimeout(_reminder, (parseInt(cb.settings.notifier_interval) * 60 * 1000)); } function _setupSettings() { let i; BOT.addSetting({ name: "notifier_heading", type: "choice", label: BOT.formatSettingsHeading("Rotating Notifications"), required: false }); BOT.addSetting({ name: "notifier_enable", type: "choice", label: "Enable", choice1: "Yes", choice2: "No", defaultValue: "Yes" }); BOT.addSetting({ name: "notifier_interval", type: "int", label: "How often should a notification be displayed (in minutes)? ", minValue: 1, maxValue: 1000, defaultValue: 10, required: true }); for (i = 1; i <= _total_messages; i++) { BOT.addSetting({ name: "notifier_message_" + i.toString(), type: "str", label: "Message " + i.toString(), minLength: 0, maxLength: 5000, defaultValue: "", required: false }); } } return { init: function() { BOT.log("Loading Notifier module..."); _setupSettings(); _buildNotifications(); _displayNotification(); if (cb.settings.notifier_enable == "Yes") { BOT.setTimeout(_reminder, (parseInt(cb.settings.notifier_interval) * 60 * 1000)); } } }; })(); var TRUTH_OR_DARE = (function(){ var current_player = null; var current_type = null; var dareCost = 99; var truthCost = 49; var repeatNotice = true; var reminderTime = 60000; function _getDivider() { return "----------------------------------------"; } function _getSettings() { truthCost = cb.settings.truth_cost; dareCost = cb.settings.dare_cost; switch(cb.settings.reminder) { case "Never": repeatNotice = false; break; case "Every minute": reminderTime = 60000;//60 seconds break; case "Every five minutes": reminderTime = 300000;//300 seconds break; case "Every ten minutes": reminderTime = 600000;//600 seconds break; default: repeatNotice = false; break; } } function _handleTipAmount(tipAmount, msg, tipper) { var divider = _getDivider(); switch(tipAmount) { case(truthCost): current_player = tipper; current_type = "TRUTH"; cb.sendNotice(divider, null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); cb.sendNotice(":kates-truth", null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); cb.sendNotice(current_player + " chose TRUTH!", null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); cb.sendNotice("The question is: " + msg, null, BOT.getNoticeFontDarkColour(), BOT.getNoticeFontLightColour(), "bold"); cb.sendNotice(divider, null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); break; case(dareCost): current_player = tipper; current_type = "DARE"; cb.sendNotice(divider, null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); cb.sendNotice(":kates-dare", null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); cb.sendNotice(current_player + " chose DARE!", null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); cb.sendNotice("The dare is: " + msg, null, BOT.getNoticeFontDarkColour(), BOT.getNoticeFontLightColour(), "bold"); cb.sendNotice(divider, null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); break; default: break; } } function _reminder() { _sendAnnouncement(); BOT.setTimeout(_reminder, reminderTime); } function _sendAnnouncement() { cb.sendNotice(":kates-truth :kates-truth-or-dare-01 :kates-dare", null, null, null, "bold"); cb.sendNotice("We are playing TRUTH or DARE! To ask a TRUTH question, tip " + truthCost + " tokens. DARES cost " + dareCost + " tokens. Submit your question or dare in a tip note. For more info, check out the 'Truth or Dare' section of my bio! Let's have fun! xxx", null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); } function _sendDareNotice(msg) { cb.sendNotice(":kates-dare", null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); cb.sendNotice(msg['user'] + " chose DARE!", null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); cb.sendNotice("The dare is: " + msg["m"], null, BOT.getNoticeFontDarkColour(), BOT.getNoticeFontLightColour(), "bold"); } function _sendTruthNotice(msg) { cb.sendNotice(":kates-truth", null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); cb.sendNotice(msg['user'] + " chose TRUTH!", null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); cb.sendNotice("The question is: " + msg["m"], null, BOT.getNoticeFontDarkColour(), BOT.getNoticeFontLightColour(), "bold"); } function _setupSettings() { BOT.addSetting({ name: "truth_or_dare_heading", type: "choice", label: BOT.formatSettingsHeading("Truth or Dare"), required: false }); BOT.addSetting({ name: "truth_or_dare_enable", type: "choice", label: "Enable", choice1: "Yes", choice2: "No", defaultValue: "Yes" }); BOT.addSetting({ name:'truth_cost', type:'int', minValue:1, maxValue:1000, defaultValue:49, label: "Token cost for TRUTH" }); BOT.addSetting({ name:'dare_cost', type:'int', minValue:1, maxValue:1000, defaultValue:99, label: "Token cost for DARE" }); BOT.addSetting({ name:'reminder', type:'choice', choice1:'Every minute', choice2:'Every five minutes', choice3:'Every ten minutes', choice4:'Never', defaultValue:'Every minute', label: "How often should the rules/prices be announced?" }); } return { init: function() { BOT.log("Loading Truth or Dare module..."); _setupSettings(); if (cb.settings.truth_or_dare_enable == "Yes") { _getSettings(); if (repeatNotice == true) { BOT.setTimeout(_reminder, reminderTime); } _sendAnnouncement(); } }, onMessage: function (msg) { if (cb.settings.truth_or_dare_enable == "Yes") { switch (msg['m']) { case "!truth": if (BOT.isBroadcaster(msg['user']) || msg['is_mod'] || BOT.isVirtualMod(msg['user'])) { _sendTruthNotice(msg); return msg; } break; case "!dare": if (BOT.isBroadcaster(msg['user']) || msg['is_mod'] || BOT.isVirtualMod(msg['user'])) { _sendDareNotice(msg); return msg; } break; default: return msg; break; } } else { return msg; } }, onTip: function (tip) { if (cb.settings.truth_or_dare_enable == "Yes") { _handleTipAmount(parseInt(tip['amount']), tip['message'], tip['from_user']); } } }; })(); var VIRTUAL_MODS = (function(){ function _handleMessage(msg) { var message_text = msg["m"].toLowerCase().trim(); // Notices if (message_text.indexOf("!notice") === 0) { if (BOT.isBroadcaster(msg["user"]) || msg["is_mod"] || BOT.isVirtualMod(msg["user"])) { msg = BOT.hideMessage(msg); var notice_text = msg["m"].replace(/!notice\s*/gi, ""); if (notice_text.indexOf(":") !== -1) { cb.sendNotice(notice_text, null, null, null); } else { cb.sendNotice(notice_text, null, BOT.getNoticeFontLightColour(), BOT.getNoticeFontDarkColour(), "bold"); } } } return msg; } function _setupSettings() { BOT.addSetting({ name: "virtual_mods_heading", type: "choice", label: BOT.formatSettingsHeading("Virtual moderators"), required: false }); BOT.addSetting({ name: "virtual_mods_list", type: "str", label: "Comma-separated list of users who are allowed to be virtual moderators ", minLength: 1, maxLength: 1000, defaultValue: "romeo_john" }); } return { onMessage: function(msg) { return _handleMessage(msg); }, init: function() { BOT.log("Loading Virtual Mods module..."); _setupSettings(); } }; })(); BOT.init(); GOAL.init(); AUTO_REPLY.init(); NOTIFIER.init(); VIRTUAL_MODS.init(); TRUTH_OR_DARE.init();
© Copyright Freesexcam 2011- 2024. All Rights Reserved.