Bots Home
|
Create an App
MyHumminBot
Author:
aaronnhammer
Description
Source Code
Launch Bot
Current Users
Created by:
Aaronnhammer
/** * Chaturbate Multi-usage Bot: * see /help * * @author: aaronn.hammer@gmail.com */ var HumminBot = { consts: { yes: 'Yes', no: 'No', on: 'on', off: 'off', bold: 'bold', timer_ratio: 60000, split_token: ',', color: { bg: '#FFFFFF', grey: '#757575' }, tokens: { ifreg: /\?\[([^\\]+)\]/ig }, genders: { m: ':avatar_gen_male', f: ':avatar_gen_female', t: ':avatar_gen_trans', c: ':avatar_gen_couple' } }, utils: { emptyMessage: function (msg) { msg.m = ""; return msg; }, preventMessage: function (msg) { msg['X-Spam'] = true; return HumminBot.utils.emptyMessage(msg); }, replaceInString: function (str, token, value) { return str.replace('[' + token + ']', value); }, sendNotice: function (msg, setting, user) { setting = setting || 'notice'; cb.chatNotice(msg, user, HumminBot.settings[setting + "_color_bg"], HumminBot.settings[setting + "_color"], HumminBot.consts.bold); }, sendSlugNotice: function (msg) { cb.chatNotice(msg, cb.room_slug, HumminBot.settings.notice_color_bg, HumminBot.settings.notice_color, HumminBot.consts.bold); }, sendAlert: function (msg, setting, user) { setting = setting || 'alert'; cb.chatNotice(msg, user, HumminBot.settings[setting + "_color_bg"], HumminBot.settings[setting + "_color"], HumminBot.consts.bold); }, isOn: function (setting, args) { if (!args || 0 == args.length) args = [HumminBot.consts.on]; return HumminBot.settings[setting] = (args[0] == HumminBot.consts.on); }, setTimeout: function (command) { if (HumminBot.timeouts.hasOwnProperty(command) && HumminBot.timeouts[command]) HumminBot.commands[command].fn(); var timer = HumminBot.settings[command + "_timer"]; if (timer == 0) { HumminBot.timeouts[command] = false; return; } cb.setTimeout(function () { HumminBot.utils.setTimeout(command); HumminBot.timeouts[command] = true; }, (timer * HumminBot.consts.timer_ratio)); }, setTimer: function (command, timer) { var oldTimer = HumminBot.settings[command + "_timer"]; HumminBot.settings[command + "_timer"] = timer || oldTimer; if (0 == oldTimer && timer && 0 != timer && HumminBot.timeouts[command]) HumminBot.utils.setTimeout(command); } }, settings: {}, timeouts: {}, rules: [], menu: { items: [] }, commands: {}, tips: {}, leaders: [], notices: { base: [], free: [] }, king: null, club: { members: [] }, lounge: { members: [] }, mod: { anonReg: /anon.{0,3}ib/, repeatedCharReg: /(([:]*)[^\s]*([^\s])\3{3,})/, phraseReg: /\s+/, phraseRegToken: ".{0,16}", emoReg: /^:/, bannedWordReg: null, bannedPhraseReg: null, silenced: [], warned: [] } }; cb.settings_choices = [ /** MESSAGE **/ /** User Gender**/ {name: 'gender_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Show users gender in chat ?'}, {name: 'match_color_allowed', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Match message color to username color ?'}, {name: 'notice_color', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the default notices\' color', defaultValue: "#B7879B"}, {name: 'notice_color_bg', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the default notices\' background color', defaultValue: "#FFFFFF"}, {name: 'alert_color', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the default alerts\' color', defaultValue: "#FF788E"}, {name: 'alert_color_bg', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the default alerts\' background color', defaultValue: "#FFFFFF"}, /** ENTER **/ {name: 'welcome_msg', type: 'str', minLength: 8, maxLength: 255, label: 'Welcome message, [user] = user\'s name', defaultValue: 'Welcome to my room [user] '}, {name: 'block_msg', label: 'Message for blocked users', type: 'str', minLength: 1, maxLength: 99, required: true, defaultValue: 'Anonymous viewers blocked, log in to view cam.'}, /** TIPS **/ {name: 'tip_auto_thank', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Show auto tip thank you ?'}, {name: 'tip_min', type: 'int', minValue: 0, defaultValue: 10, label: 'Minimum tokens required for a thank you message'}, {name: 'tip_msg', type: 'str', minLength: 8, maxLength: 128, defaultValue: 'Thank you [tipper] for your tip!', label: 'Tip thank you message, [tipper] = tipper\'s name'}, /** Rules **/ {name: 'rule_color', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the rules', defaultValue: "#B7879B", required: false}, {name: 'rule_color_bg', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb background color code of the rules', defaultValue: "#FFFFFF", required: false}, {name: 'rule1', type: 'str', minLength: 0, maxLength: 255, label: 'Rule #1', defaultValue: 'rules rules!', required: false}, {name: 'rule2', type: 'str', minLength: 0, maxLength: 255, label: 'Rule #2', defaultValue: 'rules rules!', required: false}, {name: 'rule3', type: 'str', minLength: 0, maxLength: 255, label: 'Rule #3', defaultValue: 'rules rules!', required: false}, {name: 'rule4', type: 'str', minLength: 0, maxLength: 255, label: 'Rule #4', defaultValue: 'rules rules!', required: false}, {name: 'rule5', type: 'str', minLength: 0, maxLength: 255, label: 'Rule #5', defaultValue: 'rules rules!', required: false}, {name: 'rule6', type: 'str', minLength: 0, maxLength: 255, label: 'Rule #6', defaultValue: 'rules rules!', required: false}, {name: 'rule7', type: 'str', minLength: 0, maxLength: 255, label: 'Rule #7', defaultValue: 'rules rules!', required: false}, {name: 'rule8', type: 'str', minLength: 0, maxLength: 255, label: 'Rule #8', defaultValue: 'rules rules!', required: false}, {name: 'rule9', type: 'str', minLength: 0, maxLength: 255, label: 'Rule #9', defaultValue: 'rules rules!', required: false}, {name: 'rule10', type: 'str', minLength: 0, maxLength: 255, label: 'Rule #10', defaultValue: 'rules rules!', required: false}, /** Tip Menu **/ {name: 'menu_color', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the menu', defaultValue: "#B7879B", required: false}, {name: 'menu_color_bg', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb background color code of the menu', defaultValue: "#FFFFFF", required: false}, {name: 'menu_timer', type: 'int', minValue: 0, maxValue: 999, defaultValue: 15, label: 'Delay in minutes between menu being displayed (0 to disable)'}, {name: 'menu_item_1', type: 'str', minLength: 0, maxLength: 60, label: 'Menu Item #1', defaultValue: "itemmenu", required: false}, {name: 'menu_price_1', type: 'int', minValue: 0, label: 'Menu Item #1 Price', defaultValue: 1, required: false}, {name: 'menu_item_2', type: 'str', minLength: 0, maxLength: 60, label: 'Menu Item #2', defaultValue: "itemmenu", required: false}, {name: 'menu_price_2', type: 'int', minValue: 0, label: 'Menu Item #2 Price', defaultValue: 2, required: false}, {name: 'menu_item_3', type: 'str', minLength: 0, maxLength: 60, label: 'Menu Item #3', defaultValue: "itemmenu", required: false}, {name: 'menu_price_3', type: 'int', minValue: 0, label: 'Menu Item #3 Price', defaultValue: 3, required: false}, {name: 'menu_item_4', type: 'str', minLength: 0, maxLength: 60, label: 'Menu Item #4', defaultValue: "itemmenu", required: false}, {name: 'menu_price_4', type: 'int', minValue: 0, label: 'Menu Item #4 Price', defaultValue: 4, required: false}, {name: 'menu_item_5', type: 'str', minLength: 0, maxLength: 60, label: 'Menu Item #5', defaultValue: "itemmenu", required: false}, {name: 'menu_price_5', type: 'int', minValue: 0, label: 'Menu Item #5 Price', defaultValue: 5, required: false}, {name: 'menu_item_6', type: 'str', minLength: 0, maxLength: 60, label: 'Menu Item #6', defaultValue: "itemmenu", required: false}, {name: 'menu_price_6', type: 'int', minValue: 0, label: 'Menu Item #6 Price', defaultValue: 6, required: false}, {name: 'menu_item_7', type: 'str', minLength: 0, maxLength: 60, label: 'Menu Item #7', defaultValue: "itemmenu", required: false}, {name: 'menu_price_7', type: 'int', minValue: 0, label: 'Menu Item #7 Price', defaultValue: 7, required: false}, {name: 'menu_item_8', type: 'str', minLength: 0, maxLength: 60, label: 'Menu Item #8', defaultValue: "itemmenu", required: false}, {name: 'menu_price_8', type: 'int', minValue: 0, label: 'Menu Item #8 Price', defaultValue: 8, required: false}, {name: 'menu_item_9', type: 'str', minLength: 0, maxLength: 60, label: 'Menu Item #9', defaultValue: "itemmenu", required: false}, {name: 'menu_price_9', type: 'int', minValue: 0, label: 'Menu Item #9 Price', defaultValue: 9, required: false}, {name: 'menu_item_10', type: 'str', minLength: 0, maxLength: 60, label: 'Menu Item #10', defaultValue: "itemmenu", required: false}, {name: 'menu_price_10', type: 'int', minValue: 0, label: 'Menu Item #10 Price', defaultValue: 10, required: false}, /** Notices **/ {name: 'notice_timer', type: 'int', minValue: 0, maxValue: 999, defaultValue: 15, label: 'Delay in minutes between notices being displayed (0 to disable)'}, {name: 'notice_1', type: 'str', minLength: 0, maxLength: 255, label: 'Notice #1', defaultValue: "", required: false}, {name: 'notice_1_color', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the #1 notice', defaultValue: "#B7879B", required: false}, {name: 'notice_1_color_bg', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb background color code of the #1 notice', defaultValue: "#FFFFFF", required: false}, {name: 'notice_2', type: 'str', minLength: 0, maxLength: 255, label: 'Notice #2', defaultValue: "", required: false}, {name: 'notice_2_color', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the #2 notice', defaultValue: "#B7879B", required: false}, {name: 'notice_2_color_bg', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb background color code of the #2 notice', defaultValue: "#FFFFFF", required: false}, {name: 'notice_3', type: 'str', minLength: 0, maxLength: 255, label: 'Notice #3', defaultValue: "", required: false}, {name: 'notice_3_color', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the #3 notice', defaultValue: "#B7879B", required: false}, {name: 'notice_3_color_bg', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb background color code of the #3 notice', defaultValue: "#FFFFFF", required: false}, {name: 'notice_4', type: 'str', minLength: 0, maxLength: 255, label: 'Notice #4', defaultValue: "", required: false}, {name: 'notice_4_color', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the #4 notice', defaultValue: "#B7879B", required: false}, {name: 'notice_4_color_bg', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb background color code of the #4 notice', defaultValue: "#FFFFFF", required: false}, {name: 'notice_5', type: 'str', minLength: 0, maxLength: 255, label: 'Notice #5', defaultValue: "", required: false}, {name: 'notice_5_color', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the #5 notice', defaultValue: "#B7879B", required: false}, {name: 'notice_5_color_bg', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb background color code of the #5 notice', defaultValue: "#FFFFFF", required: false}, /** King **/ {name: 'king_activated', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Show the king notification'}, {name: 'king_timer', label: 'Delay in minutes between "The King" announcement being displayed (0 to disable):', type: 'int', minValue: 0, maxValue: 60, defaultValue: 5}, {name: 'king_min', label: 'Enter the minimum tip level for a user to become King:', type: 'int', minValue: 1, maxValue: 1000000, defaultValue: 25}, {name: 'king_msg_notice', label: '"The King" notice. [amount] to display the amount to become king. [king] to display the king\'s name. ?[...] to make the string part invisible if no current king.', type: 'str', minLength: 1, maxLength: 99, required: true, defaultValue: "Tip a total of [amount] ?[to dethrone [king]] and become The King"}, {name: 'king_msg_new', label: 'Message displayed when someone become "The King".', type: 'str', minLength: 1, maxLength: 999, required: true, defaultValue: "We have a new King!\nAll hail :jdt-kingspud [king] :jdt-kingspud"}, {name: 'king_msg_dethrone', label: 'Message displayed to the person whom was king before.', type: 'str', minLength: 1, maxLength: 999, required: true, defaultValue: "You have been dethroned by [king], but revenge is sweet..."}, {name: 'king_color', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the king notices', defaultValue: "#B7879B", required: false}, {name: 'king_color_bg', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb background color code of the king notices', defaultValue: "#FFFFFF", required: false}, /** Leaders **/ {name: 'leaders_timer', label: 'Delay in minutes between the leaderboard being displayed (0 to disable):', type: 'int', minValue: 0, maxValue: 60, defaultValue: 5}, {name: 'leaders_color', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the leaders notices', defaultValue: "#B7879B", required: false}, {name: 'leaders_color_bg', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb background color code of the leaders notices', defaultValue: "#FFFFFF", required: false}, /** Club **/ {name: 'club_name', type: 'str', minLength: 0, maxLength: 255, label: 'Site\'s fan club', defaultValue: "VIP Member", required: false}, {name: 'club_prefix', type: 'str', minLength: 0, maxLength: 255, label: 'Prefix to put in front of fan club Members\' messages', defaultValue: "VIP", required: false}, {name: 'club_members', type: 'str', minLength: 0, label: 'Members comma separated no space', defaultValue: "", required: false}, {name: 'club_join_msg', label: 'Message displayed when someone enter the lounge club.', type: 'str', minLength: 1, maxLength: 99, required: true, defaultValue: "[user] is now a member of [club]."}, {name: 'club_color', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the club members\' messages', defaultValue: "#000000", required: false}, {name: 'club_color_bg', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb background color code of the club members\' messages', defaultValue: "#AAC0BB", required: false}, /** Lounge **/ {name: 'lounge_name', type: 'str', minLength: 0, maxLength: 255, label: 'Lounge club', defaultValue: "Lounge", required: false}, {name: 'lounge_prefix', type: 'str', minLength: 0, maxLength: 255, label: 'Prefix to put in front of lounge Members\' messages', defaultValue: "Fan", required: false}, {name: 'lounge_members', type: 'str', minLength: 0, label: 'Members comma separated no space', defaultValue: "", required: false}, {name: 'lounge_cost', label: 'Enter the cost to become lounge member :', type: 'int', minValue: 1, maxValue: 1000000, defaultValue: 750}, {name: 'lounge_join_msg', label: 'Message displayed when someone enter the lounge club.', type: 'str', minLength: 1, maxLength: 99, required: true, defaultValue: "[user] is now a member of [lounge]."}, {name: 'lounge_color', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb color code of the lounge members\' messages', defaultValue: "#078102", required: false}, {name: 'lounge_color_bg', type: 'str', minLength: 7, maxLength: 7, label: 'Hexadecimal rgb background color code of the lounge members\' messages', defaultValue: "#FFFFFF", required: false}, /** Moderator **/ {name: 'mod_bad_words', label: 'Words or phrases you want to silence users for saying (separated by commas)', type: 'str', minLength: 0, maxLength: 10240, defaultValue: 'bb,baby,babe,show boobs,show feet,:goat'}, {name: 'mod_repeated_char', type: 'choice', label: 'Also block messages with lots of repeated letters (e.g. mmmmmmmmmmmm)', choice1: 'Yes', choice2: 'No', defaultValue: 'No'}, {name: 'mod_warning_msg', label: 'Warning message users get when they talk shit.', type: 'str', minLength: 1, maxLength: 99, required: true, defaultValue: "You sent a bad message either bad words, expression, or repeated character.\nThis is your [warning] warning(s). Be nice or you'll get silenced."}, {name: 'mod_warning_max', label: 'Number of times to warn users before permanently silencing them (enter 0 to silence on first offence)', type: 'int', minValue: 0, maxValue: 10, defaultValue: 1}, {name: 'mod_silenced', label: 'Users you want permanently silenced (separated by commas)', type: 'str', minLength: 0, maxLength: 10240, required: false}, {name: 'mod_silenced_msg', label: 'Message displayed to the user getting silenced.', type: 'str', minLength: 1, maxLength: 999, required: true, defaultValue: "You've been silenced."} ]; cb.onEnter(function (user) { return HumminBot.onEnter(user); }); cb.onMessage(function (msg) { return HumminBot.onMessage(msg); }); cb.onTip(function (tip) { HumminBot.onTip(tip); }); HumminBot.onEnter = function (user) { if (!HumminBot.hasAccess(user.user)) return; var welcome = HumminBot.utils.replaceInString(HumminBot.settings.welcome_msg, 'user', user.user); HumminBot.utils.sendNotice(welcome, null, user.user); HumminBot.commands.rules.fn([user.user]); }; HumminBot.onMessage = function (msg) { if (!HumminBot.hasAccess(msg.user) || cbjs.arrayContains(HumminBot.mod.silenced, msg.user)) return HumminBot.utils.preventMessage(msg); if (msg.m[0] === '/') return HumminBot.executeCommand(msg); msg.m = msg.m.toLowerCase(); if (msg.user != cb.room_slug && HumminBot.isEvilMessage(msg)) return HumminBot.utils.preventMessage(msg); if (msg.user != cb.room_slug) HumminBot.addPrefixes(msg); HumminBot.matchMessageColor(msg); HumminBot.removeGreysEmojis(msg); return msg; }; HumminBot.isEvilMessage = function (msg) { if (!(HumminBot.mod.repeatedCharReg.test(msg.m) || (HumminBot.mod.bannedWordReg && HumminBot.mod.bannedWordReg.test(msg.m)) || (HumminBot.mod.bannedPhraseReg && HumminBot.mod.bannedPhraseReg.test(msg.m)))) return false; var warned = HumminBot.mod.warned[msg.user]; if (!warned) warned = 0; warned++; if (HumminBot.settings.mod_warning_max >= warned) { var message = HumminBot.utils.replaceInString(HumminBot.settings.mod_warning_msg, 'warning', warned + "/" + HumminBot.settings.mod_warning_max); HumminBot.utils.sendAlert(HumminBot.settings.mod_warning_msg, null, msg.user); HumminBot.utils.sendSlugNotice(msg.user + " sent a bad message. warning number : " + warned + "."); // TODO // HumminBot.utils.sendSlugNotice("Message : "+ msg.m); } else { HumminBot.commands.silence.fn.call(this, [msg.user]); HumminBot.utils.sendAlert(HumminBot.settings.mod_silenced_msg, null, msg.user); } HumminBot.mod.warned[msg.user] = warned; return true; }; HumminBot.addPrefixes = function (msg) { var prefixed = 0; if (cbjs.arrayContains(HumminBot.club.members, msg.user)) { msg.m = HumminBot.settings.club_prefix + ' | ' + msg.m; prefixed++; } else if (cbjs.arrayContains(HumminBot.lounge.members, msg.user)) { msg.m = HumminBot.settings.lounge_prefix + ' | ' + msg.m; prefixed++; } if (HumminBot.king && HumminBot.king.tipper == msg.user) { msg.m = ' :jdt-kingspud | ' + msg.m; prefixed++; if (2 == prefixed) return; } var userTips = HumminBot.tips[msg.user]; if (userTips) { msg.m = ' ' + userTips.total + ' | ' + msg.m; if (2 == prefixed) return; } msg.m = ' ' + HumminBot.consts.genders[msg.gender] + ' | ' + msg.m }; HumminBot.matchMessageColor = function (msg) { msg.background = HumminBot.consts.color.bg; if (msg.user == cb.room_slug) { msg.background = HumminBot.settings.alert_color_bg; msg.c = HumminBot.settings.alert_color; } else if (cbjs.arrayContains(HumminBot.club.members, msg.user)) { msg.background = HumminBot.settings.club_color_bg; msg.c = HumminBot.settings.club_color; } else if (msg.is_fanclub || cbjs.arrayContains(HumminBot.lounge.members, msg.user)) { msg.background = HumminBot.settings.lounge_color_bg; msg.c = HumminBot.settings.lounge_color; } else if (msg.is_mod) msg.c = '#FF0000'; else if (msg.tipped_tons_recently) msg.c = '#8F006B'; else if (msg.tipped_alot_recently) msg.c = '#D633AD'; else if (msg.tipped_recently) msg.c = '#000099'; else if (msg.has_tokens) msg.c = '#0066FF'; else msg.c = HumminBot.consts.color.grey; }; HumminBot.removeGreysEmojis = function (msg) { if (msg.c == HumminBot.consts.color.grey) msg.m.replace(HumminBot.mod.emoReg, " "); }; HumminBot.executeCommand = function (msg) { if (msg.user !== cb.room_slug) return HumminBot.utils.preventMessage(msg); var commandParts = msg.m.replace(/\s+$/, '').split(/\s+/); var commandName = commandParts[0].substring(1); var commandArgs = commandParts.slice(1); var command = HumminBot.commands[commandName]; if (!command || typeof command.fn != "function") return msg; command.fn.call(this, commandArgs); return HumminBot.utils.preventMessage(msg); }; HumminBot.commands.block = { alias: "block [on/off]", desc: "Start or stop blocking anonymous users (usage: '/block on' or '/block off').", fn: function (args) { if (!HumminBot.utils.isOn('block_anons', args)) return HumminBot.commands.unblock.fn(); cb.limitCam_removeAllUsers(); cb.limitCam_start(HumminBot.settings.block_msg); HumminBot.utils.sendSlugNotice("Anonymous viewers blocked"); } }; HumminBot.commands.unblock = { alias: "unblock", desc: "Stop blocking anonymous users (usage: '/unblock).", fn: function (args) { cb.limitCam_removeAllUsers(); cb.limitCam_stop(); HumminBot.utils.sendSlugNotice("Anonymous viewers unblocked"); } }; HumminBot.commands.addaccess = { alias: "addaccess [usernames]", desc: "Add access to the users specified ('/addaccess Bob Alice' will add access to Bob and Alice.", fn: function (args) { if (!args || args.length == 0) return; cb.limitCam_addUsers(args); HumminBot.utils.sendSlugNotice("Access granted to " + args.join(", ")); } }; HumminBot.commands.removeaccess = { alias: "removeaccess [usernames]", desc: "remove access to the users specified ('/removeaccess Bob Alice' will silence Bob and Alice.", fn: function (args) { if (!args || args.length == 0) return; cb.limitCam_removeUsers(args); HumminBot.utils.sendSlugNotice("Access removed to " + args.join(", ")); } }; HumminBot.commands.thanktips = { alias: "thanktips [on/off] ?[tip_min]", desc: "Start or stop auto-sending a 'Thank you notice' on tip for the minimum amount in parameter. " + "If no amount passed we use the settings amount " + " (usage: '/thanktips on 10' or '/thanktips off').", fn: function (args) { if (!HumminBot.utils.isOn('tip_auto_thank', args)) { HumminBot.utils.sendSlugNotice("Tips not auto thanked"); return; } HumminBot.utils.sendSlugNotice("Tips auto thanked from " + HumminBot.settings.tip_min + " tokens and above."); } }; HumminBot.commands.rules = { alias: "rules", desc: "Show the room rules", fn: function (args) { var name = args[0] || null; if (0 != HumminBot.rules.length) HumminBot.utils.sendNotice(HumminBot.settings.formatted_rules, "rule", name); } }; HumminBot.commands.menu = { alias: "menu ?timer(minutes)", desc: "Show the menu notice. Timer is used to show the menu again after [timer] minutes. If timer is 0 stop the cycle. ", fn: function (args) { if (args && args.length != 0) return HumminBot.utils.setTimer('menu', parseInt(args[0])); if (0 == HumminBot.settings.menu_timer || 0 == HumminBot.menu.items.length) return; HumminBot.utils.sendNotice(HumminBot.settings.formatted_menu, "menu"); } }; HumminBot.commands.notice = { alias: "notice ?timer(minutes)", desc: "Periodically show a random notice from the pre-configured ones." + " Each notice is equally displayed every [timer] minutes." + " If timer is 0 stop the cycle. ", fn: function (args) { if (args && args.length != 0) return HumminBot.utils.setTimer('notice', parseInt(args[0])); var timer = HumminBot.settings.notice_timer; if (0 == timer || 0 == HumminBot.notices.base.length) return; var idx = Math.floor(Math.random() * (HumminBot.notices.free.length)); HumminBot.utils.sendNotice(HumminBot.notices.free[idx], 'notice_' + idx); var newFree = []; if (1 == HumminBot.notices.free.length) for (var j = 0; j < HumminBot.notices.base.length; j++) newFree.push(HumminBot.notices.base[j]); else for (var i = 0; i < HumminBot.notices.free.length; i++) if (idx != i) newFree.push(HumminBot.notices.free[i]); HumminBot.notices.free = newFree; } }; HumminBot.commands.leaders = { alias: "leaders ?timer(minutes)", desc: "Periodically show the tippers leader board." + " If timer is 0 stop the cycle. ", fn: function (args) { if (args && args.length != 0) return HumminBot.utils.setTimer('leaders', parseInt(args[0])); var timer = HumminBot.settings.leaders_timer; if (0 == timer || 0 == HumminBot.leaders.length) return; var leaders = 'Leaders :'; leaders += "\n:crowngold | " + HumminBot.leaders[0].tipper + " | " + HumminBot.leaders[0].total; for (var i = 1; i < 3; i++) if (HumminBot.leaders[i]) leaders += "\n:crownsilver | " + HumminBot.leaders[i].tipper + " | " + HumminBot.leaders[i].total; HumminBot.utils.sendNotice(leaders, "leaders"); } }; HumminBot.commands.king = { alias: "king [on/off]?timer(minutes)", desc: "Periodically show \"The KING tipper\"." + " If timer is 0 stop the cycle. ", fn: function (args) { if (args && args.length != 0) { if (HumminBot.consts.on == args[0]) HumminBot.settings.king_activated = true; else if (HumminBot.consts.off == args[0]) HumminBot.settings.king_activated = false; else HumminBot.utils.setTimer('king', parseInt(args[0])); HumminBot.settings.king_timer = parseInt(args[0]); return; } var timer = HumminBot.settings.king_timer; if (0 == timer || !HumminBot.settings.king_activated) return; var supplant = HumminBot.king ? HumminBot.king.total + 1 : HumminBot.settings.king_min; var message = HumminBot.utils.replaceInString(HumminBot.settings.king_msg_notice, 'amount', supplant); if (HumminBot.king) { message = HumminBot.utils.replaceInString(message, 'king', HumminBot.king.tipper); var matches = HumminBot.consts.tokens.ifreg.exec(message); if (matches) message = message.replace(HumminBot.consts.tokens.ifreg, matches[1]); } else message = message.replace(HumminBot.consts.tokens.ifreg, ""); HumminBot.utils.sendNotice(message, "king"); } }; HumminBot.commands.addmember = { alias: "addmember [club|lounge] [username]", desc: "add a member to the specified room", fn: function (args) { if (!args || args.length != 2) return; var name = args[0]; var user = args[1]; HumminBot[name].members.push(user); var msg = "" + HumminBot.settings[name + "_join_msg"]; var setting_name = HumminBot.settings[name + '_name']; msg = HumminBot.utils.replaceInString(msg, "user", user); msg = HumminBot.utils.replaceInString(msg, name, setting_name); HumminBot.utils.sendNotice(msg, name); } }; HumminBot.commands.removemember = { alias: "removemember [club|lounge] [username]", desc: "remove a member from the specified room", fn: function (args) { if (!args || args.length != 2) return; cbjs.arrayRemove(HumminBot[args[0]].members, args[1]); HumminBot.utils.sendSlugNotice(args[1] + " have been removed from " + HumminBot.settings[name + '_name']); } }; HumminBot.commands.silence = { alias: "silence [usernames]", desc: "Silence the users specified ('/silence Bob Alice' will silence Bob and Alice.", fn: function (args) { if (!args || args.length == 0) return; for (var i in args) if (args.hasOwnProperty(i)) { var user = args[i]; HumminBot.mod.silenced.push(user); HumminBot.utils.sendSlugNotice(user + " have been silenced."); } } }; HumminBot.commands.unsilence = { alias: "unsilence [usernames]", desc: "Unsilence the users specified ('/unsilence Bob Alice' will silence Bob and Alice.", fn: function (args) { if (!args || args.length == 0) return; for (var i in args) if (args.hasOwnProperty(i)) { var user = args[i]; cbjs.arrayRemove(HumminBot.mod.silenced, user); HumminBot.utils.sendSlugNotice(user + " have been unsilenced."); HumminBot.utils.sendNotice("You have been unsilenced.", null, user); } } }; HumminBot.commands.silenced = { alias: "silenced ", desc: "Show you the list of silenced people to copy in your settings for the next time.", fn: function () { HumminBot.utils.sendSlugNotice(HumminBot.mod.silenced.join(HumminBot.consts.split_token)); } }; HumminBot.commands.help = { alias: "help", desc: "Show this message", fn: function () { HumminBot.utils.sendSlugNotice('Available commands:'); for (var commandName in HumminBot.commands) { if (!HumminBot.commands.hasOwnProperty(commandName)) continue; var command = HumminBot.commands[commandName]; HumminBot.utils.sendSlugNotice("\n/" + command.alias + " > " + command.desc); } } }; HumminBot.onTip = function (tip) { var tipAmount = parseInt(tip.amount); var tipUser = tip.from_user; HumminBot.hasAccess(tipUser); HumminBot.recordTip(tipUser, tipAmount); HumminBot.thankTip(tipUser, tipAmount); HumminBot.noticeMenuItem(tipUser, tipAmount); if (tipAmount == HumminBot.settings.lounge_cost && !cbjs.arrayContains(HumminBot.lounge.members, tipUser)) HumminBot.commands.addmember.fn(['lounge', tipUser]); }; HumminBot.recordTip = function (tipUser, tipAmount) { var tipHistory = HumminBot.tips[tipUser]; if (!tipHistory) tipHistory = {total: 0, tipper: tipUser, tips: []}; tipHistory.tips.push({date: Date.now(), amount: tipAmount}); tipHistory.lastTip = tipAmount; tipHistory.total += tipAmount; HumminBot.tips[tipUser] = tipHistory; HumminBot.updateLeaderBoard(); HumminBot.updateKing(tipHistory) }; HumminBot.updateLeaderBoard = function () { var leaders = []; for (var tipper in HumminBot.tips) if (HumminBot.tips.hasOwnProperty(tipper)) leaders.push(HumminBot.tips[tipper]); if (1 < leaders.length) leaders.sort(function (l, r) { return r.total - l.total; }); var to = leaders.length > 3 ? 3 : leaders.length; for (var i = 0; i < to; i++) { var tipHistory = HumminBot.leaders[i]; if (!tipHistory || leaders[i].tipper != tipHistory.tipper) { HumminBot.leaders = leaders; return HumminBot.commands.leaders.fn(); } } HumminBot.leaders = leaders; }; HumminBot.updateKing = function (tipHistory) { if (!HumminBot.king) { if (HumminBot.settings.king_min > tipHistory.total) return; HumminBot.king = tipHistory; return HumminBot.sendNewKingNotice(); } if (HumminBot.king.tipper == tipHistory.tipper) { HumminBot.king = tipHistory; return; } if (HumminBot.king.total < tipHistory.total) { var message = HumminBot.utils.replaceInString(HumminBot.settings.king_msg_dethorne, 'king', tipHistory.tipper); HumminBot.utils.sendNotice(message, 'king', HumminBot.king.tipper); HumminBot.king = tipHistory; HumminBot.sendNewKingNotice(); } }; HumminBot.sendNewKingNotice = function () { var msg = HumminBot.utils.replaceInString(HumminBot.settings.king_msg_new, 'king', HumminBot.king.tipper); HumminBot.utils.sendNotice(msg, 'king'); }; HumminBot.thankTip = function (tipUser, tipAmout) { if (!HumminBot.settings.tip_auto_thank || tipAmout < HumminBot.settings.tip_min) return; var msg = HumminBot.utils.replaceInString(HumminBot.settings.tip_msg, 'tipper', tipUser); HumminBot.utils.sendNotice(msg); }; HumminBot.noticeMenuItem = function (tipUser, tipAmout) { var item = HumminBot.menu[tipAmout]; if (item) HumminBot.utils.sendNotice(':heart7 :heart7 ' + tipUser + ' tipped for : ' + item, "menu"); }; HumminBot.hasAccess = function (user) { if (cb.limitCam_userHasAccess(user) || !HumminBot.mod.anonReg.test(user)) { if (!cb.limitCam_userHasAccess(user)) cb.limitCam_addUsers([user]); return true; } HumminBot.utils.sendAlert(cb.settings.block_msg, null, user); return false; }; HumminBot.init = function () { HumminBot.settings = {}; for (var setting in cb.settings) { if (!cb.settings.hasOwnProperty(setting)) continue; var value = HumminBot.settings[setting] = cb.settings[setting]; if (value == HumminBot.consts.yes) HumminBot.settings[setting] = true; if (value == HumminBot.consts.no) HumminBot.settings[setting] = false; } HumminBot.initRules(); HumminBot.initMenu(); HumminBot.initNotice(); HumminBot.initClub(); HumminBot.initLounge(); HumminBot.initLeaders(); HumminBot.initKing(); HumminBot.initMod(); }; HumminBot.initBlock = function () { HumminBot.commands.unblock.fn(); HumminBot.commands.block.fn(); }; HumminBot.initRules = function () { var rules = 'Please take a moment to read my room rules before chatting. Thank you!'; rules += '\n:yay2 ROOM RULES :yay2'; HumminBot.rules = []; for (var i = 1; i < 11; i++) { var rule = HumminBot.settings['rule' + i]; if ("" == rule) continue; rules += '\n Rule ' + i + ' : ' + rule; HumminBot.rules.push(rule); } rules += '\n:yay2 :yay2'; HumminBot.settings.formatted_rules = rules; }; HumminBot.initMenu = function () { HumminBot.menu = {items: []}; for (var k = 1; k < 11; k++) { var price = HumminBot.settings['menu_price_' + k]; var item = HumminBot.settings['menu_item_' + k]; if (0 == price || '' == item) continue; HumminBot.menu[price] = item; HumminBot.menu.items.push({item: item, price: price}); } if (1 < HumminBot.menu.items.length) HumminBot.menu.items.sort(function (l, r) { return l.price - r.price; }); var menu = '###### ROOM MENU ######'; for (var i = 0; i < 3; i++) { menu += '\n#'; for (var j = 1; j < 4; j++) menu += ' ' + HumminBot.settings['menu_item_' + (i * 3 + j)] + ' ' + HumminBot.settings['menu_price_' + (i * 3 + j)] + ' ' + (j < 3 ? ':beardancing' : '#'); } menu += '\n### ' + HumminBot.settings['menu_item_10'] + ' ' + HumminBot.settings['menu_price_10'] + ' ###'; menu += '\n###################'; HumminBot.settings.formatted_menu = menu; if (!HumminBot.timeouts.hasOwnProperty('menu') || !HumminBot.timeouts['menu']) HumminBot.utils.setTimeout('menu'); }; HumminBot.initNotice = function () { HumminBot.notices.base = []; HumminBot.notices.free = []; for (var i = 1; i < 6; i++) { var notice = HumminBot.settings['notice_' + i]; if (null == notice || "" == notice) continue; HumminBot.notices.base.push(notice); HumminBot.notices.free.push(notice); } if (!HumminBot.timeouts.hasOwnProperty('notice') || !HumminBot.timeouts['notice']) HumminBot.utils.setTimeout('notice'); }; HumminBot.initClub = function () { HumminBot.club.members = []; if (HumminBot.settings.club_members && HumminBot.settings.club_members != "") HumminBot.club.members = HumminBot.settings.club_members.split(HumminBot.consts.split_token) }; HumminBot.initLounge = function () { HumminBot.lounge.members = []; if (HumminBot.settings.lounge_members && HumminBot.settings.lounge_members != "") HumminBot.lounge.members = HumminBot.settings.lounge_members.split(HumminBot.consts.split_token) }; HumminBot.initLeaders = function () { if (!HumminBot.timeouts.hasOwnProperty('leaders') || !HumminBot.timeouts['leaders']) HumminBot.utils.setTimeout('leaders'); }; HumminBot.initKing = function () { if (!HumminBot.timeouts.hasOwnProperty('king') || !HumminBot.timeouts['king']) HumminBot.utils.setTimeout('king'); }; HumminBot.initMod = function () { if (HumminBot.settings.mod_silenced && HumminBot.settings.mod_silenced != "") HumminBot.mod.silenced = HumminBot.settings.mod_silenced.split(HumminBot.consts.split_token); var badWords = []; var badPhrases = []; if (!HumminBot.settings.mod_bad_words || HumminBot.settings.mod_bad_words == "") return; var split = HumminBot.settings.mod_bad_words.split(HumminBot.consts.split_token); for (var i in split) { var part = split[i]; if (HumminBot.mod.phraseReg.test(part)) { part.replace(HumminBot.mod.phraseReg, ' '); var parts = part.split(' ').join(HumminBot.mod.phraseRegToken); badPhrases.push(parts); } else badWords.push(part); } HumminBot.mod.bannedWordReg = new RegExp('(' + badWords.join('|') + ')'); HumminBot.mod.bannedPhraseReg = new RegExp('(' + badPhrases.join('|') + ')'); }; HumminBot.init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.