Bots Home
|
Create an App
Aryll's greens are green
Author:
staringatstars
Description
Source Code
Launch Bot
Current Users
Created by:
Staringatstars
// cb settings cb.settings_choices = [ {name: 'tipTitles', label: '----------------------------------ROOM_CONTROLS----------------------------------- ------------------------------------------------------------------------------------------------- Do you want to display users\' tip totals as titles', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'capsToggle', label: 'Convert ALL CAPS to lowercase', type: 'choice', choice1: 'Yes', choice2: 'No', choice3: 'Only for greys', defaultValue: 'Yes', required: false}, {name: 'stickyToggle', label: 'Prevent sticky keyyyyyyyyyyyyys', type: 'choice', choice1: 'Yes', choice2: 'No', choice3: 'Only for greys', defaultValue: 'Yes', required: false}, {name: 'defaultGraphicLevel', label: 'Default Graphic Level (Who can use graphics?)', type: 'choice', choice1: '0 - (Everyone)', choice2: '1 - (Color names only)', choice3: '2 - (Greens only)', defaultValue: '2 - (Greens only)', required: false}, {name: 'defaultSilenceLevel', label: 'Default Silence Level (Who can talk in chat?)', type: 'choice', choice1: '0 - (Everyone)', choice2: '1 - (Color names only)', choice3: '2 - (Greens only)', defaultValue: '0 - (Everyone)', required: false}, {name: 'niceTalkList', label: 'Nice Talk List (Users who can always talk) separated by commas', type: 'str', minLength: 1, maxLength: 1000, required: false}, {name: 'NiceGraphicsList', label: 'Nice Graphics List (Users who can always use graphics) separated by commas', type: 'str', minLength: 1, maxLength: 1000, required: false}, {name: 'gifsOn', type: 'choice', choice1: 'on', choice2: 'off', defaultValue: 'on', label: "-----------------------------------GREEN_CONTROLS---------------------------------- ------------------------------------------------------------------------------------------------- Display leading gif." }, {name:'dGif', type:'str', required: false, label:"Defult gif for the Greens",}, {name:'Nonfan', type:'str', required: false, label:"Non Fanclub users too add to greens, separated by commas and NO spaces (and they need to be the CB username exactly)",}, {name:'group1Mem', type:'str', required: false, label:"Group 1, separated by commas and NO spaces (and they need to be the CB username exactly)",}, {name:'group1Gif', type:'str', required: false, label:"The Gif for group 1",}, {name:'group2Mem', type:'str', required: false, label:"Group 2, separated by commas and NO spaces (and they need to be the CB username exactly)",}, {name:'group2Gif', type:'str', required: false, label:"The Gif for group 2",}, {name:'group3Mem', type:'str', required: false, label:"Group 3, separated by commas and NO spaces (and they need to be the CB username exactly)",}, {name:'group3Gif', type:'str', required: false, label:"The Gif for group 3",}, {name: 'pmOn', type: 'choice', choice1: 'on', choice2: 'off', defaultValue: 'on', label: "In chat PM's on for greens"}, {name:'WMsg', type:'str', required: false, label:"--------------------------------ROOM_ENTRY_MSG'S--------------------------------- ------------------------------------------------------------------------------------------------- The Grey and Anon room welcome Msg. (if blank no msg sent)", }, {name:'bWMsg', type:'str', required: false, label:"The Blue room welcome Msg (if blank, the grey msg will be sent, if that is blank no msg sent)",}, {name:'pWMsg', type:'str', required: false, label:"The Purple room welcome Msg. (if blank, the grey msg will be sent, if that is blank no msg sent)",}, {name:'gWMsg', type:'str', required: false, label:"The Green room welcome Msg (this includes added fanclub users) (if blank, the grey msg will be sent, if that is blank no msg sent)",}, {name:'wMsgTextCol', type:'str', required: false, label:"The room welcome Msg text colour",}, {name:'wMsgbackCol', type:'str', required: false, label:"The room welcome Msg background colour",}, {name: 'wMsgWeight', type: 'choice', choice1: 'normal', choice2: 'bold', choice3: 'bolder', defaultValue: 'normal', label: "The boldness of the welcome msg text"}, {name: 'tipMsgOn', type: 'choice', choice1: 'on', choice2: 'off', defaultValue: 'off', label: "---------------------------------TIP_MSG_CONTROLS--------------------------------- ------------------------------------------------------------------------------------------------- Tip msg's on"}, {name:'tipMsgTextcolour', type:'str', label:'Tip msg text color (html code)', required: false}, {name:'tipMsgNoticecolour', type:'str', required: false, label:'Tip msg background color (html code)'}, {name:'tipMsg', type:'str', required: false, label:'Messages or Gifs to be displayed on tip, followed by the min amount to display that msg, seperated by commas, groups seperated by / eg: Thank you,25/:gif,50 - would display the msg Thank you when tipped 25-49 and :gif when tipped 50 or more, you can enter as many groups as you want',}, {name: 'tipOn', type: 'choice', choice1: 'on', choice2: 'off', defaultValue: 'off', label: "--------------------------------TIP_MENU_SETTINGS--------------------------------- ------------------------------------------------------------------------------------------------- Tip menu on"}, {name: 'tipMessageTime', label: 'Enter the frequency with you would like the msg displayed in mins', type: 'int', minValue: 1, maxValue: 1000000, defaultValue: 5}, {name:'tipTextcolour', type:'str', label:'Notice text color (html code)', required: false}, {name:'tipNoticecolour', type:'str', required: false, label:'Notice background color (html code)'}, {name:'tipSeparator', type:'str', defaultValue: '/', label:"The separator symbol for the tip menu, can be a symbol, some text or a gif"}, {name:'mainTip', type:'str', required: false, label:"Tip items to be displayed in rotating tip menu. Should be entered as - text,tip,green tip,gif (the gif is optional) each group should be seperated by / example:- boobs,30,20/booty,50,35,:booty ",}, {name:'otherTip', type:'str', required: false, label:"Other tip items. Should be entered as - text,tip,green tip,gif (the gif is optional) each group should be seperated by / example:- boobs,30,20/booty,50,35,:booty ",}, {name: 'rnOn', type: 'choice', choice1: 'on', choice2: 'off', defaultValue: 'off', label: "----------------------------------NOTIFIER_SETTINGS--------------------------------- ------------------------------------------------------------------------------------------------- Notifier on or off",}, {name:'rtc1', type:'str', required: false, label:'1st Notice Text colour in html code eg: #494949'}, {name:'rnc1', type:'str', required: false, label:'1st Notice background colour in html code eg: #494949'}, {name:'rMsg1', type:'str', required: false, label:"1st rotating notice text.",}, {name: 'rmt1', label: 'The time in mins before the next notice is displayed, if this is the last populated notice this is the time before the first msg is displayed again.', type: 'int', minValue: 0, maxValue: 1000000, defaultValue: 1}, {name:'rtc2', type:'str', required: false, label:'2nd Notice Text colour in html code eg: #494949'}, {name:'rnc2', type:'str', required: false, label:'2nd Notice background colour in html code eg: #494949'}, {name:'rMsg2', type:'str', required: false, label:"2nd rotating notice text. ",}, {name: 'rmt2', label: 'The time in mins before the next notice is displayed, if this is the last populated notice this is the time before the first msg is displayed again.', type: 'int', minValue: 0, maxValue: 1000000, defaultValue: 1}, {name:'rtc3', type:'str', required: false, label:'3rd Notice Text colour in html code eg: #494949'}, {name:'rnc3', type:'str', required: false, label:'3rd Notice background colour in html code eg: #494949'}, {name:'rMsg3', type:'str', required: false, label:"3rd rotating notice text.",}, {name: 'rmt3', label: 'The time in mins before the next notice is displayed, if this is the last populated notice this is the time before the first msg is displayed again.', type: 'int', minValue: 0, maxValue: 1000000, defaultValue: 1}, {name:'rtc4', type:'str', required: false, label:'4th Notice Text colour in html code eg: #494949'}, {name:'rnc4', type:'str', required: false, label:'4th Notice background colour in html code eg: #494949'}, {name:'rMsg4', type:'str', required: false, label:"4th rotating notice text.",}, {name: 'rmt4', label: 'The time in mins before the next notice is displayed, if this is the last populated notice this is the time before the first msg is displayed again.', type: 'int', minValue: 0, maxValue: 1000000, defaultValue: 1}, {name:'rtc5', type:'str', required: false, label:'5th Notice Text colour in html code eg: #494949'}, {name:'rnc5', type:'str', required: false, label:'5th Notice background colour in html code eg: #494949'}, {name:'rMsg5', type:'str', required: false, label:"5th rotating notice text.",}, {name: 'rmt5', label: 'The time in mins before the next notice is displayed, if this is the last populated notice this is the time before the first msg is displayed again.', type: 'int', minValue: 0, maxValue: 1000000, defaultValue: 1}, {name:'rtc6', type:'str', required: false, label:'6th Notice Text colour in html code eg: #494949'}, {name:'rnc6', type:'str', required: false, label:'6th Notice background colour in html code eg: #494949'}, {name:'rMsg6', type:'str', required: false, label:"6th rotating notice text.",}, {name: 'rmt6', label: 'The time in mins before the next notice is displayed, if this is the last populated notice this is the time before the first msg is displayed again.', type: 'int', minValue: 0, maxValue: 1000000, defaultValue: 1}, {name:'rtc7', type:'str', required: false, label:'7th Notice Text colour in html code eg: #494949'}, {name:'rnc7', type:'str', required: false, label:'7th Notice background colour in html code eg: #494949'}, {name:'rMsg7', type:'str', required: false, label:"7th rotating notice text. ",}, {name: 'rmt7', label: 'The time in mins before the next notice is displayed, if this is the last populated notice this is the time before the first msg is displayed again.', type: 'int', minValue: 0, maxValue: 1000000, defaultValue: 1}, {name:'rtc8', type:'str', required: false, label:'8th Notice Text colour in html code eg: #494949'}, {name:'rnc8', type:'str', required: false, label:'8th Notice background colour in html code eg: #494949'}, {name:'rMsg8', type:'str', required: false, label:"8th rotating notice text.",}, {name: 'rmt8', label: 'The time in mins before the next notice is displayed, if this is the last populated notice this is the time before the first msg is displayed again.', type: 'int', minValue: 0, maxValue: 1000000, defaultValue: 1}, {name:'rtc9', type:'str', required: false, label:'9th Notice Text colour in html code eg: #494949'}, {name:'rnc9', type:'str', required: false, label:'9th Notice background colour in html code eg: #494949'}, {name:'rMsg9', type:'str', required: false, label:"9th rotating notice text.",}, {name: 'rmt9', label: 'The time in mins before the next notice is displayed, if this is the last populated notice this is the time before the first msg is displayed again.', type: 'int', minValue: 0, maxValue: 1000000, defaultValue: 1}, {name:'rtc10', type:'str', required: false, label:'10th Notice Text colour in html code eg: #494949'}, {name:'rnc10', type:'str', required: false, label:'10th Notice background colour in html code eg: #494949'}, {name:'rMsg10', type:'str', required: false, label:"10th rotating notice text.",}, {name: 'rmt10', label: 'The time in mins before the next notice is displayed, if this is the last populated notice this is the time before the first msg is displayed again.', type: 'int', minValue: 0, maxValue: 1000000, defaultValue: 1} //{name: 'notifierTip', label: 'Would you like to display a message when a user tips?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, //{name: 'tipMessage', label: 'Enter the message you would like to display.', type: 'str', minLength: 1, maxLength: 1000, defaultValue: 'Thank you!'}, //{name: 'tipMessageMin', label: 'Enter the minimum tip amount that you would like to trigger the message', type: 'int', minValue: 1, maxValue: 1000000, defaultValue: 10}, ]; // vars var repList = []; var mainTipList = []; var tipMOn = 'on'; var tipTime = 1000; var fulTipList = []; var otherTipList = []; var tmo = ''; var tipMsgs = []; var dm = false; var tippersList = [[]]; var welMsgWeight = ''; var wm = ''; var bwm = ''; var pwm = ''; var gwm = ''; var welMsgText = '#494949'; var welMsgback = ''; var niceTalk = []; var niceGraph = []; var group1Members = {}; var group2Members = {}; var group3Members = {}; var nonMembers = {}; var tempGif = []; var silenceLevel = 0; var graphicLevel = 2; var symbolString = '~`!@#$%^&*()_-+={[}]|\\:;"\'<,>.?/'; var noticeOn = ''; var rotatinc = 1; var maxItems = 10; // Decides if user is green function isGreen(msg) { return ((msg['in_fanclub']) || (isNon(msg['user']))); } function isGreenTip(tip) { return ((tip['from_user_in_fanclub']) || (isNon(tip['from_user']))); } // Is functions function isNTalk(name) { var tempstr = name.toLowerCase(); var retval = cbjs.arrayContains(niceTalk, tempstr); return retval; } function isNGraph(name) { var tempstr = name.toLowerCase(); var retval = cbjs.arrayContains(niceGraph, tempstr); return retval; } function isTg(name) { var tempstr = name.toLowerCase(); var retval = cbjs.arrayContains(tempGif, tempstr); return retval; } function isG1(name) { var tempstr = name.toLowerCase(); var retval = cbjs.arrayContains(group1Members, tempstr); return retval; } function isG2(name) { var tempstr = name.toLowerCase(); var retval = cbjs.arrayContains(group2Members, tempstr); return retval; } function isG3(name) { var tempstr = name.toLowerCase(); var retval = cbjs.arrayContains(group3Members, tempstr); return retval; } function isNon(name) { var tempstr = name.toLowerCase(); var retval = cbjs.arrayContains(nonMembers, tempstr); return retval; } function isColour(msg) { return (((msg['has_tokens']) || (msg['tipped_alot_recently']) || (msg['tipped_recently']) || (msg['tipped_tons_recently'])) && !((isGreen(msg)) || (msg['is_mod']) || (msg['user'] == cb.room_slug))); } function isGrey(msg) { return (!(isColour(msg) || isGreen(msg) || msg['is_mod'] || (msg['user'] == cb.room_slug))); } function isDev(name) { var a = (name == 'staringatstars') return a; } //find the index of the user in an array, returns -1 if not in group function inGroup(name,arr) { var cmId = -1; for (var i = 0; i < arr.length; i++) { if (arr[i] == name) { cmId = i; break; } } return cmId; } // PM function function pm(arr,u) { var a = arr.shift(); var b = arr.shift(); if (cb.settings['pmOn'] == 'on') { cb.sendNotice(("PM from " + u + ": " + (arr.join(" ")) + " ."),b, "#009900","") } else { cb.sendNotice("PM's are turned off, your message was not sent." ,u, "#009900","") } } // function to add user to tempgif function addTempGif(user,Gif) { if (isTg(user)) { removeTempGif(user); } tempGif.push(user); tempGif.push(Gif); } function removeTempGif(user) { a = inGroup(user, tempGif); tempGif.splice(a, 2); } function getGif(user) { a = inGroup(user, tempGif); return tempGif[(a + 1)]; } function modelHelpText(name) { var addGifHelp = "#addgif username gif :- puts the specified gif infront of the usersname in chat for the rest of the session, overides settings and previous #addgif."; var removeGifHelp = "#removegif username :- removes inchat set gif from specified user."; var silence0Help = "#silence0 :- sets silence level to 0 (anyone chats) :- #unsilence also does this."; var silence1Help = "#silence1 :- sets silence level to 1 (greys silenced) :- #silencegrey also does this. "; var silence2Help = "#silence2 :- sets silence level to 2 (all but greens silenced)."; var graphic0Help = "#graphics0 :- sets graphics level to 0 (anyone posts gifs)."; var graphic1Help = "#graphics1 :- sets graphics level to 1 (greys can't post gifs)."; var graphic2Help = "#graphics2 :- sets graphics level to 2 (only greens can post gifs)."; var addgniceHelp = "#addgnice username :- adds the named user to the can always post graphics list (will only work for the session)."; var removegniceHelp = "#removegnice username :- removes the named user from the can always post graphics list (will only work for the session)."; var addtniceHelp = "#addtnice username :- adds a the named user to the can always chat list (will only work for the session)."; var removetniceHelp = "#removetnice username :- removes the named user from the can always chat list (will only work for the session)."; var help1 = [addGifHelp,removeGifHelp,silence0Help,silence1Help,silence2Help,graphic0Help,graphic1Help,graphic2Help,addgniceHelp,removegniceHelp,addtniceHelp,removetniceHelp]; var helptext = ''; for(var i = 0; i < help1.length; i++) { var a = helptext + "\n" + help1[i]; helptext = a; } cb.sendNotice("Help menu" + helptext, name, '',"#3b3b3b"); } function inrepList (name) { for(var i = 0; i < repList.length; i++) { if (repList[i][0] == name) { return i; } } return -1; } // parses msg's for commands and runs them function msgParse(msg) { var msgArray = msg['m'].split(' '); //turn the message into an array var name = msg['user']; var modelName = cb.room_slug; var isModel = (name == cb.room_slug); var green = isGreen(msg); if (isModel || isDev(name)) { if (msgArray[0].charAt(0) == '#') { switch (msgArray[0]) { case '#addgif': msg['X-Spam'] = true; addTempGif(msgArray[1], msgArray[2]); break; case '#replace': msg['X-spam'] =true; var z = []; x=repList.length; z[0]=msgArray[1]; z[1]=msgArray[2]; if (msgArray.length > 2){ for (i=3;i < msgArray.length;i++){ z[1]=z[1] + ' ' + msgArray[i]; } } repList[x]=z; break; case '#removegif': msg['X-Spam'] = true; removeTempGif(msgArray[1]); break; case '#help': msg['X-Spam'] = true; modelHelpText(name); break; case '#silence0': msg['X-Spam'] = true; silenceLevel = 0; break; case '#silence1': msg['X-Spam'] = true; silenceLevel = 1; break; case '#silence2': msg['X-Spam'] = true; silenceLevel = 2; break; case '#unsilence': msg['X-Spam'] = true; graphicLevel = 0; break; case '#silencegrey': msg['X-Spam'] = true; silenceLevel = 1; break; case '#graphics0': msg['X-Spam'] = true; graphicLevel = 0; break; case '#graphics1': msg['X-Spam'] = true; graphicLevel = 1; break; case '#graphics2': msg['X-Spam'] = true; graphicLevel = 2; break; case '#addgnice': msg['X-Spam'] = true; if (!(isNGraph(msgArray[1]))) { niceGraph.push(msgArray[1]); } break; case '#addtnice': msg['X-Spam'] = true; if (!(isNTalk(msgArray[1]))) { niceTalk.push(msgArray[1]); } break; case '#removegnice': msg['X-Spam'] = true; if (isNGraph(msgArray[1])) { a = inGroup(msgArray[1], niceGraph); niceGraph.splice(a, 1); } break; case '#removetnice': msg['X-Spam'] = true; if (isNTalk(msgArray[1])) { a = inGroup(msgArray[1], niceTalk); niceTalk.splice(a, 1); } break; case '#checknotice': msg['X-Spam'] = true; notices(); break; case '#addtipmenu': msg['X-Spam'] = true; if ((msgArray.length > 3) || (msgArray.length < 6)) { fulTipList = []; addtipListItemMain(msgArray[1],msgArray[2],msgArray[3],msgArray[4]); mainTipList.sort(function(a, b) { var x = a[1]; var y = b[1]; return x - y; }); mergeLists(); } else { cb.sendNotice('request in wrong form',name); } break; case '#addtipother': msg['X-Spam'] = true; if ((msgArray.length > 3) || (msgArray.length < 6)) { fulTipList = []; addtipListItemOther(msgArray[1],msgArray[2],msgArray[3],msgArray[4]); otherTipList.sort(function(a, b) { var x = a[1]; var y = b[1]; return x - y; }); mergeLists(); } else { cb.sendNotice('request in wrong form',name); } break; } } } if (green || isModel) { if (msgArray[0].charAt(0) == '#') { switch (msgArray[0] ) { case '#pm': msg['X-Spam'] = true; pm(msgArray,name); break; } } } if (msgArray[0].charAt(0) == '#') { switch (msgArray[0]) { case '#menu': msg['X-Spam'] = true; if (green) { fullListNotice(2,name); } else { fullListNotice(1,name); } break; } } } function notifyError(message, u) { cb.sendNotice(message,u,"#C2DCEB","#FFCCCC","#BB2222"); } function notices(){ for (var i = 1; i < (maxItems +1);i++) { if (cb.settings['rMsg' + i]) { cb.chatNotice((cb.settings['rMsg' + i]),'',(cb.settings['rnc' + i]),(cb.settings['rtc' + i]),'bold'); } } } function rotatingNotices() { if (noticeOn == 'on') { if (cb.settings['rMsg' + rotatinc]) { cb.chatNotice((cb.settings['rMsg' + rotatinc]),'',(cb.settings['rnc' + rotatinc]),(cb.settings['rtc' + rotatinc]),'bold'); rotatinc++; if (rotatinc > (maxItems)) {rotatinc = 1;} cb.setTimeout(rotatingNotices,(cb.settings['rmt' + (rotatinc - 1)] * 60000)); } else { rotatinc++; if (rotatinc > (maxItems)) {rotatinc = 1;} rotatingNotices(); } } } function grabSettings() { cb.log("starting grabbing settings"); if (cb.settings.group1Mem) { group1Members = cb.settings.group1Mem.toLowerCase().split(','); } if (cb.settings.group2Mem) { group2Members = cb.settings.group2Mem.toLowerCase().split(','); } if (cb.settings.group3Mem) { group3Members = cb.settings.group3Mem.toLowerCase().split(','); } if (cb.settings.Nonfan) { nonMembers = cb.settings.Nonfan.toLowerCase().split(','); } if(cb.settings.defaultGraphicLevel) { graphicLevel = parseInt(cb.settings.defaultGraphicLevel.charAt(0)); } if(cb.settings.defaultSilenceLevel) { silenceLevel = parseInt(cb.settings.defaultSilenceLevel.charAt(0)); } if (cb.settings.NiceGraphicsList) { niceGraph = cb.settings.NiceGraphicsList.toLowerCase().split(','); } if (cb.settings.WMsg) { wm = cb.settings['WMsg']; } if (cb.settings.bWMsg) { bwm = cb.settings['bWMsg']; } else {bwm = cb.settings['WMsg'];} if (cb.settings.pWMsg) { pwm = cb.settings['pWMsg']; } else {pwm = cb.settings['WMsg'];} if (cb.settings.gWMsg) { gwm = cb.settings['gWMsg']; } else {gwm = cb.settings['WMsg'];} if (cb.settings.wMsgTextCol) { welMsgText = cb.settings['wMsgTextCol']; } if (cb.settings.wMsgbackCol) { welMsgback = cb.settings['wMsgbackCol']; } if (cb.settings.wMsgWeight) { welMsgWeight = cb.settings['wMsgWeight']; } if (cb.settings.niceTalkList) { niceTalk = cb.settings.niceTalkList.toLowerCase().split(','); } switch(cb.settings.capsToggle) { case 'Yes': capsGrey = true; capsCol = true; break; case 'No': capsGrey = false; capsCol = false; break; default: capsGrey = true; capsCol = false; } switch(cb.settings.stickyToggle) { case 'Yes': stickGrey = true; stickCol = true; break; case 'No': stickGrey = false; stickCol = false; break; default: stickGrey = true; stickCol = false; } sTog = cb.settings.stickyToggle; cTog = cb.settings.capsToggle; noticeOn = (cb.settings['rnOn']); tmo = cb.settings['tipMsgOn']; if (cb.settings.tipMsg) { var tempList = cb.settings.tipMsg.split('/'); for (var i = 0; i < tempList.length; i++) { var tempList2 = tempList[i].split(',') if (tempList2.length < 2) { errorMsg(("list too short, you need to check your tip msg settings, tip msg's are now off " + String(tempList2.length) + ' ' + tempList2)); tmo = 'off'; break; } if (tempList2.length > 2) { errorMsg(("list too long, you need to check your tip msg settings, tip msg's are now off " + String(i) + String(tempList2.length) + ' ' + tempList2)); tmo = 'off'; break; } var a = tempList2[0]; var b = tempList2[1]; addtipMsgsnotice(a,b); } tipMsgs.sort(function(a, b) { var x = a[1]; var y = b[1]; return x - y; }); } if (cb.settings.mainTip) { var tempList = cb.settings.mainTip.split('/'); for (var i = 0; i < tempList.length; i++) { tempList2 = tempList[i].split(',') if (tempList2.length < 3) { errorMsg(("list too short " + String(tempList2.length) + ' ' + tempList2)); break; } if (tempList2.length > 4) { errorMsg(("list too long " + String(i) + String(tempList2.length) + ' ' + tempList2)); break; } var a = tempList2[0]; var b = tempList2[1]; var c = tempList2[2]; var d = ''; if (tempList2.length == 4) { d = tempList2[3]; } addtipListItemMain(a,b,c,d); } mainTipList.sort(function(a, b) { var x = a[1]; var y = b[1]; return x - y; }); } if (cb.settings.otherTip) { var tempList = cb.settings.otherTip.split('/'); for (var i = 0; i < tempList.length; i++) { tempList2 = tempList[i].split(',') if (tempList2.length < 3) { errorMsg(("list too short " + String(tempList2.length) + ' ' + tempList2)); break; } if (tempList2.length > 4) { errorMsg(("list too long " + String(i) + String(tempList2.length) + ' ' + tempList2)); break; } var a = tempList2[0]; var b = tempList2[1]; var c = tempList2[2]; var d = ''; if (tempList2.length == 4) { d = tempList2[3]; } addtipListItemOther(a,b,c,d); } otherTipList.sort(function(a, b) { var x = a[1]; var y = b[1]; return x - y; }); } if (cb.settings.tipOn) { tipMOn = cb.settings['tipOn']; } if (cb.settings.tipMessageTime) { tipTime = ((cb.settings['tipMessageTime']) * 60000); } cb.log("finished grabbing settings"); } grabSettings(); cb.setTimeout(rotatingNotices,(cb.settings['rmt1'] * 60000)); // On enter functions cb.onEnter(function(user) { var u = user['user']; var m = ''; if (isGreen(user)) { m = gwm; } else { if (user['tipped_tons_recently'] || user['tipped_alot_recently']) { m = pwm; } else { if (user['tipped_recently'] || user['has_tokens']) { m = bwm; } else { m = wm; } } } if (m != '') { cb.chatNotice(m,u,welMsgback,welMsgText,welMsgWeight); } }); // on tip functions //tip menu functions function in2DList (name) { for(var i = 0; i < tippersList.length; i++) { if (tippersList[i][0] == name) { return i; } } return -1; } function errorMsg (msg) { cb.sendNotice(msg); } function addtipListItemMain (name,mPrice,gPrice,gif) { mainTipList.push([name,mPrice,gPrice,gif]); } function addtipListItemOther (name,mPrice,gPrice,gif) { otherTipList.push([name,mPrice,gPrice,gif]); } function menuBuild(arr,x) { arr.sort(function(a, b) { var z = a[x]; var y = b[x]; return z - y; }); var newArr = []; for (var i = 0; i < arr.length; i++) { var a = '' + arr[i][0] + ' for ' + arr[i][x] + 'tks '; newArr.push(a); } return newArr; } function tipNotifier() { if (cb.settings['tipOn'] == 'on') { var arr = menuBuild(mainTipList,1); a = ' ' + arr[0]; for(var i = 1; i < arr.length; i++) { a = a + cb.settings['tipSeparator'] + arr[i]; } cb.chatNotice('Tip Menu: ' + a + ' Or, Type #menu to see the full menu.','',cb.settings['tipNoticecolour'],cb.settings['tipTextcolour'],'bold'); } } function msgBuild(arr) { var m = arr[0]; for (i=1; i<arr.length;i++) { m = m + ' \n ' + arr[i]; } return m; } function fullListNotice(x,user) { var arr = menuBuild(fulTipList,x); cb.chatNotice(msgBuild(arr),user,cb.settings['tipNoticecolour'],cb.settings['tipTextcolour'],'bold'); } function amountInTipList(tipAmount,position) { for (var i = 0; i < fulTipList.length; i++) { if (fulTipList[i][position] == parseInt(tipAmount)) { return i; } } return -1; } function callme() { if (tipMOn == 'on') { tipNotifier(); cb.setTimeout(callme,tipTime); } } function mergeLists() { var a = []; for (var i =0; i < otherTipList.length; i++) { a.push(otherTipList[i]); } for (var i =0; i < mainTipList.length; i++) { a.push(mainTipList[i]); } a.sort(function(a, b) { var x = a[1]; var y = b[1]; return x - y; }); fulTipList = a; } // show tip functions function addtipMsgsnotice (notice,tip) { tipMsgs.push([notice,tip]); } function addTipper (name) { tippersList.push([name,0]); } function hasTipped (name) { for(var i = 0; i < tippersList.length; i++) { if (tippersList[i][0] == name) { return i; } } return -1; } function addTip (value,tip) { tippersList[value][1] += tip; } function tiplist (tip) { var msg = ''; var ht = hasTipped(tip['from_user']); var tv = parseInt(tip['amount']); if (ht == -1) { addTipper(tip['from_user']); } addTip(hasTipped(tip['from_user']),tv); } function showTip (msg) { var x = hasTipped(msg['user']); if (x != -1) { var s = '|' + tippersList[x][1] + '| ' + msg['m']; return s; }else { return msg['m']; } } // tip msg functions function runTipMsg(tip) { var a = getTipMsg(tip['amount']); if (a != 'na') { cb.chatNotice(a,'',cb.settings['tipMsgNoticecolour'],cb.settings['tipMsgTextcolour'],'bold'); } } function getTipMsg(tip) { for (var i = 0; i < tipMsgs.length; i++) { if (parseInt(tipMsgs[i][1]) <= parseInt(tip)) { if (i+1 == tipMsgs.length) { return tipMsgs[i][0]; } if (parseInt(tipMsgs[i+1][1]) > parseInt(tip)) { return tipMsgs[i][0]; } } } return 'na'; } // start ops mergeLists(); cb.setTimeout(callme(),tipTime); cb.onTip(function (tip) { var s = 1; if (isGreenTip(tip)) { s = 2; } var a = amountInTipList(tip['amount'],s); if (a != -1) { var msg = tip['from_user'] + ' tipped for ' + fulTipList[a][0]; cb.chatNotice(msg,'',cb.settings['tipNoticecolour'],cb.settings['tipTextcolour'],'bold'); } runTipMsg(tip); tiplist(tip); }); // runs onMessage functions cb.onMessage(function (msg) { var u = msg['user']; msgParse(msg); if (isGreen(msg)){ msg['c'] = '#009900'; } if( isColour(msg) || isGrey(msg) ) { //stop people from sending messages in all caps if (cTog == 'Yes' || (cTog == 'Only for greys' && (isGrey(msg) ))) { if(msg['m'] == msg['m'].toUpperCase() && msg['m'].toUpperCase() != msg['m'].toLowerCase()) { for(var i = 0; i < msg['m'].length; i++) { if(symbolString.indexOf(msg['m'].charAt(i)) == -1) { msg['m'] = msg['m'].replace(/[^\s]+/g, function (match) { return match.indexOf(':') === 0 ? match : match.toLowerCase(); }); } } } } } if( isColour(msg) || isGrey(msg) ) { if (sTog == 'Yes' || (sTog == 'Only for greys' && (isGrey(msg) ))) { if(msg['m'].match(/(.)\1{3,}/ig)) { message = msg['m'].trim().split(/\s+/g); // make sure we're working with the current version of our message var m = ''; for(var i = 0; i < message.length; i++) { if(i >= 0) { m += ' '; } if ((message[i].charAt(0) == ':')) { m += message[i]; } else { m += message[i].replace(/(.)\1{3,}/ig, '$1$1$1'); } } msg['m'] = m; } } } function doSilenceLevel(level) { var silenceNotice = 'I\'m sorry, but the silence level has been set to ' + level + '. Your message was not sent.\n'; msg['X-Spam'] = true; cb.sendNotice(silenceNotice,u,"#FFCCCC","#BB2222"); } if ((silenceLevel > 0) && ( isColour(msg) || isGrey(msg) ) && !(isNTalk(msg['user']))) { switch(silenceLevel) { case 1: if(isGrey(msg) ) { doSilenceLevel(graphicLevel); } break; case 2: doSilenceLevel(graphicLevel); break; } } var msgString = msg['m'].trim(); var message = msgString.split(/\s+/g); //turn the message into an array // Graphic Levels function doGraphicLevel(level) { var graphicNotice = 'I\'m sorry, but the graphic level has been set to ' + level + '. Your message was not sent.\n'; if (replaceImage()) { cb.sendNotice(graphicNotice,u,"#FFCCCC","#BB2222"); } } function replaceImage() { for(var i = 0; i < message.length; i++) { if(message[i].charAt(0) == ':') { if(!message[i].match(/^(:(-?|o?)(\)|\(|}|{|P|D|3|b|O|0|S|X|\$|\/|\\|\||\*))$/ig)) { // common emoticons that begin with a ":" character //replace images msg['m'] = msg['m'].replace(/:[^\s]+/g, function (match) { return '[IMG: ' + match.slice(1) + ']'; }); msg['X-Spam'] = true; return true; } else { return false; } } } } if ((graphicLevel > 0) && ( isColour(msg) || isGrey(msg) ) && !(isNGraph(msg['user']))) { switch(graphicLevel) { case 1: if(isGrey(msg) ) { doGraphicLevel(graphicLevel); } break; case 2: doGraphicLevel(graphicLevel); break; } } if (cb.settings['tipTitles'] == 'Yes') { msg['m'] = showTip(msg); } if (isTg(u)){ msg['m'] = " " + getGif(u) + " " + msg['m']; } else { if ((cb.settings['gifsOn'] == 'on') && (isGreen(msg))) { if (isG1(u)){ msg['m'] = " " + cb.settings['group1Gif'] + " " + msg['m']; } else { if(isG2(u)){ msg['m'] = " " + cb.settings['group2Gif'] + " " + msg['m']; } else { if(isG3(u)){ msg['m'] = " " + cb.settings['group3Gif'] + " " + msg['m']; } else { msg['m'] = " " + cb.settings['dGif'] + " " + msg['m']; } } } } } return msg; });
© Copyright Chaturbate 2011- 2024. All Rights Reserved.