Bots Home
|
Create an App
JSModBot
Author:
crystalsopen2
Description
Source Code
Launch Bot
Current Users
Created by:
Crystalsopen2
/******************************************************* * Title: JSModBot * * * Author: 'CrystalSopen' * * Based on Jazbot by: 'Crazyware' * Based on a script by: 'badbadbubba' * Based on a Rotating Notifier by: 'badbadbubba' *******************************************************/ var app = { name: "'JSModBot'", type: 'Bot', version: '2.3.1', build: '.025', date: '2017.11.29' }; jsAdded = new Array(); regexStore = new Array(); userWarnCounts = new Array(); manuallyMuted = new Array(); tippers = new Array(); allPacks = new Array(); tipMenu = new Array(); var COLOR = { SYNTAX: '#995B00', RED: '#FF1407', AMBER: '#E56B00', MOD: '#DC0000', HVTEXT: '#D80A00', HVBACK: '#FFFFBF', NOTICE: '#6900CC', INFO: '#144D8C' // MAG : '#E509E5' }; var COMMAND = { JSTEST: 'jstest', /* do several tests */ JSLB: 'jslb', /* list all tippers */ JSLSMUTE: 'jslsmute', /* list all current mutes */ JSUNMUTE: 'jsunmute', /* unmute a specific user */ JSMUTE: 'jsmute', /* mute a specific user */ JSCMDS: 'jscmds', /* list supported commands */ JSADD: 'jsadd', /* add a string to block */ JSNOTIFY: 'jsnotify', /* Notify random message */ JSB: 'jsb', /* Notice broadcaster */ JSM: 'jsm', /* Notice mods as group */ JSV: 'jsv', /* Notice to viewer */ JSN: 'jsn', /* Notice to chat */ MON: 'mon' /* Enables monitoring for each mod */ }; var commandPrefix = '/'; var dashLine = "------------------------------------------------------------"; var ONLY_MODERATORS = "* Command is only available to moderators."; var roomHost = cb.room_slug; var monList = []; cb.settings.warnmsg = 'no'; // var monitorFlag = false; cb.settings_choices = [{ name: 'warnings', type: 'choice', choice1: 1, choice2: 0, choice3: 2, choice4: -1, defaultValue: -1, label: "How many warnings to give to using before silencing 0=autosilence, -1 never silence" }, { name: 'announceMutes', type: 'choice', choice1: 'public', choice2: 'user', choice3: 'none', defaultValue: 'user', label: "How to display that a message was muted: in 'public' chat, to the 'user' (and mods) or 'none'" }, { name: 'mutedemands', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Mute grey demands (open/show/zoom/etc & boobs/tits/ass/pussy/etc)?" }, { name: 'mutegreygraphics', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Mute grey graphics?" }, { name: 'mutestickykeys', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Mute grey sticky keys (4+ repeating characters eg. mmmm)?" }, { name: 'muteallcaps', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Mute grey all caps?" }, { name: 'mutevulgarwords', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Mute grey vulgar words (bitch,slut,whore,finger,fuck,etc)?" }, { name: 'muterudewords', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Mute grey rude words (bitch,slut,whore,ugly,fat,pee,poo,peeing,fist,etc)?" }, { name: 'mutebabywords', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Mute grey 'baby', 'bby', babe, etc?" }, { name: 'mutefeetwords', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Mute grey feet talk (feet,foot,soles,toes)?" }, { name: 'mutenonenglish', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Mute grey non-english characters (cyrillic,arabic,chinese,accented)?" }, { name: 'mutespamwords', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Mute advertising spam (streamingnaked,18f cam,18female,erotimo,etc)?" }, { name: 'disableRegex', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'no', label: "Disable the 'Black Magic' of regular expressions in user defined spam patterns" }, { name: 'UserSpamPattern1', type: 'str', required: false, default: " ", minLength: 1, maxLength: 255, label: "JS regex or plain text. ie: '(tap)|(click).*for' or 'free.*tkns'" }, { name: 'UserSpamPattern2', type: 'str', required: false, default: " ", minLength: 1, maxLength: 255, label: "JS regex or plain text. ie: '(tap)|(click).*for' or 'free.*tkns'" }, { name: 'UserSpamPattern3', type: 'str', required: false, default: " ", minLength: 1, maxLength: 255, label: "JS regex or plain text. ie: '(tap)|(click).*for' or 'free.*tkns'" }, { name: 'UserSpamPattern4', type: 'str', required: false, default: " ", minLength: 1, maxLength: 255, label: "JS regex or plain text. ie: '(tap)|(click).*for' or 'free.*tkns'" }, { name: 'UserSpamPattern5', type: 'str', required: false, default: " ", minLength: 1, maxLength: 255, label: "JS regex or plain text. ie: '(tap)|(click).*for' or 'free.*tkns'" }, { name: 'UserSpamPattern6', type: 'str', required: false, default: " ", minLength: 1, maxLength: 255, label: "JS regex or plain text. ie: '(tap)|(click).*for' or 'free.*tkns'" }, { name: 'UserSpamPattern7', type: 'str', required: false, default: " ", minLength: 1, maxLength: 255, label: "JS regex or plain text. ie: '(tap)|(click).*for' or 'free.*tkns'" }, { name: 'msg', type: 'str', required: true, label: 'Messages separate with ";"', defaultValue: 'Be nice; No demands; No spamming; No promoting; No rudeness', }, { name: 'noticecolor', type: 'str', label: 'Notice color (html code default purple #6900CC)', defaultValue: '#6900CC' }, { name: 'chat_ad', type: 'int', minValue: 1, maxValue: 999, defaultValue: 2, label: 'Delay in minutes between notices being displayed (minimum 1)' }, { name: 'minTipTY', type: 'int', minValue: 1, maxValue: 999, defaultValue: 25, label: 'Minumum tip for a thank you message' }, { name: 'tipTYMsg', type: 'str', required: true, label: 'What to say after a tip begins "username:"', defaultValue: '<3<3<3<3<3 Thank you! <3<3<3', }, { name: 'msgOnEnter', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'no', label: "Send message to new users on entry? (yes or no)" }, { name: 'entryMSG', type: 'str', required: false, default: "Welcome to my room. Automated moderator JSModBot works here.", minLength: 1, maxLength: 255, label: "Send this message to users as they join the room" }, { name: 'menuInUse', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'no', label: "Should we use the tip menu in this bot? (yes or no)" }, { name: 'menuStr', type: 'str', required: false, default: "10=show feet;20=show butt;50=dance", minLength: 1, maxLength: 1023, label: "list each item in the amount '=' then description then a ';'" }, { name: 'menuSep', type: 'str', required: false, default: "|", minLength: 1, maxLength: 1023, label: "print this between each menu item" }, { name: 'menu_ad', type: 'int', minValue: 1, maxValue: 999, defaultValue: 4, label: 'How often (in minutes) should this bot remind users of the tip menu?' }]; /** TOOLS for use */ function assert(condition, message) { if (!condition) { throw message || "Assertion failed"; } } Array.prototype.sample = function() { return this[Math.floor(Math.random() * this.length)]; } function sendPlaceSort(a, b) { return parseInt(b[1]) - parseInt(a[1]) } /*** the building blocks of functional design */ function myForEach(array, f) { return array.forEach(f); } function reduce(combine, seed, array) { var base = seed; assert(array instanceof Array, array + " - isn't an Array - 3rd argument must be an Array."); myForEach(array, function(element) { base = combine(base, element); }) return base; } function map(func, array) { var result = []; array.forEach(function(element) { result.push(func(element)); }); return result; } /** end of tools section */ function chatAd() { msg = cb.settings["msg"].split(";").sample(); cb.sendNotice(msg, '', '', cb.settings['noticecolor'], 'bold'); cb.setTimeout(chatAd, (cb.settings.chat_ad * 60000)); } function buildPacks() { /** builds the packs of label flag and regex list**/ // demands and demand words allPacks.push(['demands', cb.settings['mutedemands'] == 'yes', [ /\b(pm|c2c|private|pv|pvt|prvt|cam2cam)\b/i, /(my.*bio|my.*profile|my.*cam)/i, /(open|view|visit|see|check|look).*(me|girl|page|cam|bio)/i, /((?=.*ass)|(?=.*pussy)|(?=.*boobs?)|(?=.*bobs?)|(?=.*tits?)|(?=.*vagina)|(?=.*cunt)|(?=.*cock)|(?=.*nipples?)|(?=.*breasts?)|(?=.*anal))((?=.*plz)|(?=.*pls)|(?=.*please))/i, /((^ass.?.?$)|(^boobs?.?.?$)|(^pussy.?.?$)|(^doggy.?.?$)|(^anal.?.?$)|(^zoom.?.?$)|(^show.?.?$)|(^tits?.?.?$)|(?=.*stand up.?.?)|(?=.*watch my cam.?.?)|zoom|flash|open|see|show)/i, ]]) // graphics allPacks.push(['greyGraphics', cb.settings['mutegreygraphics'] == 'yes', [/:\b\w{2}/]]); // sticky keys allPacks.push(['stickyKeys', cb.settings['mutestickykeys'] == 'yes', [/(([:]*)[^\s]*([^\s])\3{8,})/ig]]); // all caps allPacks.push(['allCaps', cb.settings['muteallcaps'] == 'yes', [/[ABCDEFGHIJKLMNOPQRSTUVWXYZ]{4,}/]]); // vulgar words allPacks.push(['vulgar', cb.settings['mutevulgarwords'] == 'yes', [ /body|ass|nipples?|breasts?|bust|naked|nude|(fuck)|(?=.*whore)|clit|cock|boobs?|fuck|hard|slut/i ]]); // rude allPacks.push(['rude', cb.settings['muterudewords'] == 'yes', [ /bitch|cunt|ugly|pee|piss|poo[\Wp]|pee|fist|fag|sissy/i, /(?=.*\b(rape|eat|get|play|touch|suck|rub|eat|lick|spread|smell)\b)(?=.*\b(asshole|pussy|cunt|bobs?|tits?|toes?|armpits?|vagina|out|me|dog)\b)/i ]]); // bb allPacks.push(['myNameIsNotBB', cb.settings['mutebabywords'] == 'yes', [ /\b(bb|bby|babe|baby|bae|daddy|daughter|my.*girl)\b/i ]]); // feet allPacks.push(['feet', cb.settings['mutefeetwords'] == 'yes', [ /\b(ft|feet|foot|soles|toes)\b/i ]]); // non english allPacks.push(['non - English', cb.settings['mutenonenglish'] == 'yes', [ /[^\x00-\x7F]+/ ]]); // spam allPacks.push(['spam', cb.settings['mutespamwords'] == 'yes', [ /(((boy)((s+)|(z+)))|((guy)((s+)|(z+))))\b/i, /my pussy is so.*wet/i, /(.\s?(tk|ml)(\s|$))|(cumre\s?\.\s?site|pvts\s?\.\s?trade)/i, /generator/i, /p.?r.?i.?v.?a.?t.?e c.?a.?m.?s r.?e.?c.?o.?r.?d.?s/i, /((swipegirls)|(link.*(bio|profile))|(tap)|((click)|(open) my)|(token.*hack)|(token.*gen)|(free.*registration)|(free.*tokens)|(pornmeds)|(?=.*18f cam)|(?=.*streamingnaked)|(?=.*premiumcheat)|(?=.*amecam)|(?=.*18female)|(?=.*erotimo)|(?=.*freesecurecams)|(?=.*ellagocam))/i ]]); // UserSpamPattern if (cb.settings['disableRegex'] == 'no') { var myPatterns = new Array(); for (patternNumber = 1; patternNumber < 8; patternNumber++) { preregx = cb.settings['UserSpamPattern' + patternNumber].replace(/\s+$/, ''); if ((preregx.length) > 0) { try { myPatterns.push(new RegExp(preregx, "i")); } catch (err) { cb.log("invalid user spam pattern" + err.message); } } } allPacks.push([ 'userDefinedSpam', cb.settings['mutespamwords'] == 'yes', myPatterns ]); } } function fCheckmsg(msg) { var u = msg['user']; var tmpmsg = msg['m']; var mutemsg = false; var temp; cb.log("checking if user has beed muted"); if ((cb.settings['warnings'] != -1) && ((userWarnCounts[u] != undefined) && (userWarnCounts[u] > cb.settings['warnings']))) { mutemsg = true; cb.log(u + ": Has been silenced by JSModBot, but still sending messages!") } if ((manuallyMuted[u] != undefined) && (manuallyMuted[u] == 1)) { mutemsg = true; cb.log(u + ": Has been silenced by Admin, but still sending messages!") } if (mutemsg != true) { mutemsg = checkAllPacks(tmpmsg, u, allPacks); } cb.log("checking added phrases"); if ((mutemsg != true) && (cb.settings['disableRegex'] == 'no') && (jsAdded.length > 0)) { mutemsg = checkAllPacks(tmpmsg, u, [ ["addedSpamPattern", true, jsAdded] ]); } else { for (var phrase = 0; phrase < jsAdded.length; phrase++) { if ((mutemsg != true) && (-1 != tmpmsg.indexOf(jsAdded[phrase]))) { cb.log("muting by phrase"); mutemsg = true; doMute(u + ':Muted message for jsadd phrase', u); } } } if (cb.settings['disableRegex'] == 'yes') { cb.log("checking for user predefined spam"); for (patternNumber = 1; patternNumber < 8; patternNumber++) { pattern = cb.settings['UserSpamPattern' + patternNumber].replace(/\s+$/, ''); if ((!mutemsg) && (tmpmsg.indexOf(pattern) != -1)) { mutemsg = true; doMute(u + ':Muted message for user spam pattern:' + pattern + ":" + patternNumber, u); } } } if (mutemsg) msg['X-Spam'] = true; } function checkAllPacks(msg, username, packList) { /** check as many packs as needed */ superPackList = map(function(pack) { return [msg, username, pack] }, packList); return reduce(orCheckNextRule, false, superPackList); } function orCheckNextRule(myBool, superPack) { /** Process next check only if needed */ assert([true, false].indexOf(myBool) != -1, "myBool must be true, or false not " + myBool); if (myBool) { return true } return Boolean(checkMessage(superPack[0], superPack[1], superPack[2])) } function checkMessage(msg, username, checkPack) { /** checkPack is a list of label, flag and a list of regex patterns */ var label = checkPack[0]; var flag = checkPack[1]; var reList = checkPack[2]; if (flag == false) { return false } // do no work if we are supposed to skip this check cb.log("checking " + label); if (reduce(orCheckNextRE, false, map(function(zed) { return [zed, msg] }, reList))) { doMute(username + ':Muted message for ' + label, username); return true; } else { return false; } } function orCheckNextRE(myBool, reMsg) { reNext = reMsg[0]; msg = reMsg[1]; /** check the regex only if needed **/ assert([true, false].indexOf(myBool) != -1, "myBool must be true || false not " + myBool); if (myBool == true) { return true; } try { return Boolean(reNext.test(msg)); } catch (err) { cb.log(err.message + " in " + reNext); return false; } } cb.onMessage(function(msg) { var regexCommandSplit = '^' + commandPrefix + '(\\S+)(?:\\b\\s*)(.*)?'; var regexListSplit = /[,\s]+/; var reCmdSplit = new RegExp(regexCommandSplit); var cmdSplit = msg['m'].match(reCmdSplit); var cmd; var cmdval; var cmdValArray; if (cmdSplit) { cmd = cmdSplit[1]; cmdval = cmdSplit[2]; if (cmdval != null) { cmdval = cmdval.replace(/^\s+|\s+$/g, ''); } if (cmdval != null) { cmdValArray = cmdval.split(regexListSplit); } else { cmdValArray = ''; } } // for convenience var m = msg['m']; var u = msg['user']; var isMod = msg['is_mod']; var isRoomHost = (u == roomHost); var viewer, toViewer; switch (cmd) { /***** list commands *****/ case COMMAND.JSCMDS: if (isMod || isRoomHost) { cb.sendNotice("* Syntax: '/jslb' -- lists tippers in ranked order", u, '', COLOR.SYNTAX, 'bold'); cb.sendNotice("* Syntax: '/jslsmute' -- lists mute users", u, '', COLOR.SYNTAX, 'bold'); cb.sendNotice("* Syntax: '/jsmute username' -- mutes a user", u, '', COLOR.SYNTAX, 'bold'); cb.sendNotice("* Syntax: '/jsunmute username' -- unmutes a user", u, '', COLOR.SYNTAX, 'bold'); cb.sendNotice("* Syntax: '/jsadd phrase' blocks phrase", u, '', COLOR.SYNTAX, 'bold'); cb.sendNotice("* Syntax: '/jsn message' -- sends message to chat", u, '', COLOR.SYNTAX, 'bold'); cb.sendNotice("* Syntax: '/jsv viewername message' sends message to viewer", u, '', COLOR.SYNTAX, 'bold'); cb.sendNotice("* Syntax: '/jbc message' -- send message to broadcaster", u, '', COLOR.SYNTAX, 'bold'); cb.sendNotice("* Syntax: '/jbm message' sends message to all mods", u, '', COLOR.SYNTAX, 'bold'); } else { cb.sendNotice(ONLY_MODERATORS, u, '', cb.settings['noticecolor'], 'bold'); } break; /***** list blocked keys*****/ case COMMAND.JSLSMUTE: if (isMod || isRoomHost) { cb.log(u + " Has requested a list of manually muted users") for (var muteUser in manuallyMuted) { cb.log("checking:" + muteUser) if (manuallyMuted[muteUser] == 1) { cb.sendNotice("* Manually muted user: " + muteUser, '', '', COLOR.INFO, 'bold'); } } cb.log(u + ": Has requested a list of auto muted users") for (var muteUser in userWarnCounts) { cb.log("checking:" + muteUser) if ((cb.settings['warnings'] != -1) && (userWarnCounts[muteUser] > cb.settings['warnings'])) { cb.sendNotice("* Automaticaly muted user: " + muteUser, '', '', COLOR.INFO, 'bold'); } } } else { cb.sendNotice(ONLY_MODERATORS, u, '', cb.settings['noticecolor'], 'bold'); } break; /***** add block phrase *****/ case COMMAND.JSADD: if (isMod || isRoomHost) { if (cmdval) { cb.sendNotice("* now blocking: " + cmdval, '', '', cb.settings['noticecolor'], 'bold'); if (cb.settings['disableRegex'] == 'no') { jsAdded.push(new RegExp(cmdval.replace(/\s+$/, ""), "i")); } else { jsAdded.push(cmdval.replace(/\s+$/, "")); } cb.log(jsAdded.toString()); } else { cb.sendNotice("* Syntax: /jsadd phrase to be blocked", u, '', COLOR.SYNTAX, 'bold'); } } else { cb.sendNotice(ONLY_MODERATORS, u, '', cb.settings['noticecolor'], 'bold'); } break; /***** Public Display test of list of tippers *****/ case COMMAND.JSTEST: if (isMod || isRoomHost) { testMessages = ["open ass", "fffffffffffffff", ":hii", "HEAVY METAL", "pee for me", "ugly", "bby", "soles", "Кто вы звоните «грязный глядя»?", "18f" ] tippersInTest = new Array() possibleTips = new Array(); possibleNames = ["69Ast", "69derjoye", "69eboxp", "69Epi", "69Ghou", "69mpagn", "69tecsy", "69Zi", "BananaMonke", "BananaOrgan", "Bananav", "BitMonke", "Buttergxr", "ButtFee", "Butther", "Buttiel", "Buttinn", "ButtKaptai", "CrossedBanan", "Feet69Monke", "FeetBanan", "Feetenows", "Feetert", "Feettio", "MonkeyBanan", "Monkeyeri", "Monkeyerw", "MonkeyMuraFee", "Monkeyo", "MonkeyPha" ]; // create an array of numbers for the possible random tips cb.log("creating tip list") for (var x = 0; x < 1001; x++) { possibleTips.push(x); } // record the fake tips in the test array for (var nameID in possibleNames) { if (nameID != 'sample') { myTip = possibleTips.sample() cb.log("recording tip" + [nameID, myTip]) recordTip(myTip, possibleNames[nameID], tippersInTest); } } printTippers(0, topTippers(tippersInTest)); printTippers(3, topTippers(tippersInTest)); // test messages that should hit the spam blockers testMessages.forEach(function(msg) { checkAllPacks(msg, "0test0user0", allPacks) }); } else { cb.sendNotice(ONLY_MODERATORS, u, '', cb.settings['noticecolor'], 'bold'); } break; /***** Public Display top tippers *****/ case COMMAND.JSLB: if (isMod || isRoomHost) { printTippers(0, topTippers(tippers)); } else { cb.sendNotice(ONLY_MODERATORS, u, '', cb.settings['noticecolor'], 'bold'); } break; /***** Public Notice *****/ case COMMAND.JSNOTIFY: if (isMod || isRoomHost) { chatAd() } else { cb.sendNotice(ONLY_MODERATORS, u, '', cb.settings['noticecolor'], 'bold'); } break; /***** Public Notice *****/ case COMMAND.JSN: if (isMod || isRoomHost) { if (cmdval) { cb.sendNotice("* " + cmdval, '', '', cb.settings['noticecolor'], 'bold'); } else { cb.sendNotice("* Syntax: /jsn message", u, '', COLOR.SYNTAX, 'bold'); } } else { cb.sendNotice(ONLY_MODERATORS, u, '', cb.settings['noticecolor'], 'bold'); } break; /***** Private Notice *****/ case COMMAND.JSV: viewer = cmdValArray[0]; cbjs.arrayRemove(cmdValArray, cmdValArray[0]); toViewer = cbjs.arrayJoin(cmdValArray, " "); if (isMod || isRoomHost) { if (cmdval) { cb.sendNotice("*JSModBot* " + toViewer, viewer, '', COLOR.RED, 'bold'); } else { cb.sendNotice("* Syntax: /jsv viewername message", u, '', COLOR.SYNTAX, 'bold'); } } else { cb.sendNotice(ONLY_MODERATORS, u, '', cb.settings['noticecolor'], 'bold'); } break; /***** Message to Broadcaster *****/ case COMMAND.JSB: if (isMod) { if (cmdval) { cb.sendNotice("* " + u.toUpperCase() + ": " + cmdval, roomHost, COLOR.HVBACK, COLOR.HVTEXT, 'bold'); cb.sendNotice("* " + u.toUpperCase() + ": " + cmdval, u, COLOR.HVBACK, COLOR.HVTEXT, 'bold'); } else { cb.sendNotice("* Syntax: /jbc message", u, '', COLOR.SYNTAX, 'bold'); } } else { cb.sendNotice(ONLY_MODERATORS, u, '', cb.settings['noticecolor'], 'bold'); } break; /***** Message to user *****/ case COMMAND.JSM: if (isMod || isRoomHost) { if (cmdval) { cb.sendNotice("* " + u.toUpperCase() + ": " + cmdval, '', COLOR.HVBACK, COLOR.HVTEXT, 'bold', 'red'); } else { cb.sendNotice("* Syntax: /jbm message", u, '', COLOR.SYNTAX, 'bold'); } } else { cb.sendNotice(ONLY_MODERATORS, u, '', cb.settings['noticecolor'], 'bold'); } break; /***** Mute a user *****/ case COMMAND.JSMUTE: if (isMod || isRoomHost) { if (cmdval) { manuallyMuted[cmdval] = 1 cb.sendNotice("* now muting user: " + cmdval, '', '', cb.settings['noticecolor'], 'bold'); } else { cb.sendNotice("* Syntax: /jsmute username", u, '', COLOR.SYNTAX, 'bold'); } } else { cb.sendNotice(ONLY_MODERATORS, u, '', cb.settings['noticecolor'], 'bold'); } break; /***** unMute a user *****/ case COMMAND.JSUNMUTE: if (isMod || isRoomHost) { if (cmdval) { manuallyMuted[cmdval] = 0 userWarnCounts[u] = undefined cb.sendNotice("* now unmuting user: " + cmdval, '', '', cb.settings['noticecolor'], 'bold'); } else { cb.sendNotice("* Syntax: /jsunmute username", u, '', COLOR.SYNTAX, 'bold'); } } else { cb.sendNotice(ONLY_MODERATORS, u, '', cb.settings['noticecolor'], 'bold'); } break; /***** Message to Mods *****/ case COMMAND.MON: if (isMod || isRoomHost) { if (!cbjs.arrayContains(monList, u)) monList.push(u); else cbjs.arrayRemove(monList, u); } break; } //switch if (m[0] == commandPrefix) msg['X-Spam'] = true; //suppress all command echoing in chat if ((u != roomHost) && (!msg['is_mod']) && (!msg['has_tokens'])) { fCheckmsg(msg); } return msg; }); function doMute(msg, username) { //make an announcment about Muting a message if (cb.settings["announceMutes"] == 'public') { cb.sendNotice(msg, '', '', COLOR.RED, 'bold') } else if (cb.settings["announceMutes"] == 'user') { cb.sendNotice(msg, username, '', COLOR.RED, 'bold'); cb.sendNotice(msg, cb.room_slug, '', COLOR.INFO, 'bold'); cb.sendNotice("Hey mods: " + msg, '', '', COLOR.INFO, '', 'red'); } msg['X-Spam'] = true; monList.forEach(function(zed) { cb.sendNotice(temp + " - *JSModBot* " + msg['user'] + ": " + tmpmsg, zed, '', COLOR.INFO, 'bold') }); if (userWarnCounts[username] == undefined) { userWarnCounts[username] = 1 } else { userWarnCounts[username] += 1 } } /** Process tips for thank you and leaderboard from on tip trigger **/ cb.onTip(function(tip) { thankTip(tip.amount, tip.from_user); priorTop = topTippers(tippers) recordTip(tip.amount, tip.from_user, tippers); postTop = topTippers(tippers) // test for reprint reprint = false; if ((postTop.length != priorTop.length) && (priorTop.length < 3)) { cb.log("printing tip tippers for short list"); reprint = true; } for (rank = 0; rank < 3; rank++) { if ((priorTop[rank] != undefined) && (postTop[rank] != undefined)) { cb.log("testing for reprint on rank:" + rank) if (postTop[rank][0] != priorTop[rank][0]) { cb.log("printing tip tippers for re-ranking" + postTop[rank] + ": " + priorTop[rank][0]); reprint = true; } } } if (reprint) { printTippers(3, postTop) } if (tipMenu[tip.amount] != undefined) { cb.sendNotice("Menu item selected -> " + tipMenu[tip.amount], '', '', COLOR.NOTICE, 'bold'); } }); function thankTip(amount, user) { if (amount >= cb.settings["minTipTY"]) { cb.sendNotice(user + " : " + cb.settings["tipTYMsg"], '', '', COLOR.MOD, 'bold'); } } function recordTip(amount, user, myTippers) { // if this is a existing tipper cb.log("recordTip amount , user:" + [amount, user]) if (myTippers[user] != undefined) { myTippers[user] = myTippers[user] + amount; // if this is a new tippers } else { myTippers[user] = amount; } } function printTippers(howMany, tipperList) { locallySortedTippers = tipperList.sort(sendPlaceSort); if (howMany == 0) { howMany = locallySortedTippers.length; } cb.log("Records to print:" + howMany) cb.log("Indexes of sorted list:" + Object.keys(locallySortedTippers)); for (rank = 0; rank < howMany; rank++) { if (locallySortedTippers[rank] != undefined) { englishRank = rank + 1; cb.sendNotice("#" + (rank + 1) + " " + locallySortedTippers[rank][0] + " total tips: " + locallySortedTippers[rank][1], '', '', COLOR.INFO, 'bold'); } } } function topTippers(myTippers) { sortedTippers = new Array(); for (user in myTippers) { if (user != 'sample') { sortedTippers.push([user, myTippers[user]]); } } return sortedTippers.sort(sendPlaceSort); } /** make a message for new users on entrance*/ cb.onEnter(function(user) { cb.log("Entry message for " + user.user) if (cb.settings["msgOnEnter"] == 'yes') { cb.sendNotice(cb.settings.entryMSG, user.user, "", cb.settings['noticecolor'], ""); } }); /** functions used in tip menu **/ function parseMenu() { if (cb.settings["menuInUse"] == 'yes') { var line = cb.settings["menuStr"].split(";"); for (i=0; i < line.length; i++) { var lineItem = line[i]; if (lineItem.indexOf("=") != -1) { var lineItemKV = lineItem.split("="); tipMenu[parseInt(lineItemKV[0])] = lineItemKV[1]; } } } } function printMenu() { sep = " " + cb.settings["menuSep"] + " "; var menuMsg = new Array(); if (cb.settings["menuInUse"] == 'yes') { for (i in tipMenu) { if (i == "sample") { continue; } menuMsg.push(tipMenu[i] + "(" + i + ")"); } cb.sendNotice(menuMsg.join(sep), '', '', COLOR.NOTICE, 'bold'); cb.setTimeout(printMenu, (cb.settings.menu_ad * 60000)); } } function init() { buildPacks() cb.sendNotice("\n" + dashLine + "\n* " + app.name + " by CrystalSopen\n* Version: " + app.version + app.build + " (" + app.date + ")\n" + dashLine + "\n", roomHost, '', COLOR.INFO, 'bold'); cb.sendNotice("\n list commands with /jscmds"); cb.log parseMenu() printMenu() cb.setTimeout(chatAd, (cb.settings.chat_ad * 60000)); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.