Apps Home
|
Create an App
KING M BLOCK
Author:
megastarweedim
Description
Source Code
Launch App
Current Users
Created by:
Megastarweedim
// JavaScript Document // vars var total_tipped = 0; var tip_boss_username = null; var tip_boss_amount = 25; var high_tip_total_username = null; var high_tip_total_amount = 0; var high_tip_username = null; var high_tip_amount = 0; var last_tip_username = null; var last_tip_amount = 0; var tip_round = 1; var mode = "1"; var subject_is_set_with_0 = false; var imena = new Array(); var tipovi = new Array(); var niz=[]; var nizphrase=[]; var nizphrasesplitatwords=[]; var antispam=false; var spamshow=false; var antiemoticonflag=false; var antishoutflag=false; var antistickyflag=false; var antispamflag=false; var brpobanih=0; var blapped_users=[]; var blappon=false; var blapshow=false; var vips=[]; var vipslist = ""; var importedvips = false; var ghosts=[]; var voicemode = false; var voicelist=[]; var monitorvoice = true; var denyvoice = true; var repeat_time = 120000; var repeat_text = ""; var repeat = false; var highest_tip_total_color_code = '#3FEFEF'; var highest_tip_color_code = '#9F9'; var color = ""; cb.settings_choices = [ {name: 'tokens', type: 'int', minValue: 1, default: 100}, {name: 'goal_description', type: 'str', minLength: 1, maxLength: 1000}, {name: 'vip_users', type: 'str', minLength: 1, maxLength: 1000, label: "VIP users (separated by a space)", required: false}, {name: 'anti_emoticon', type:'choice',choice1:'yes',choice2:'no', default: 'no'}, {name: 'anti_shouting', type:'choice',choice1:'yes',choice2:'no', default: 'no'}, {name: 'anti_sticky', type:'choice',choice1:'yes',choice2:'no', default: 'no'}, {name: 'anti_spam', type:'choice',choice1:'yes',choice2:'no', default: 'no'}, {name: 'spam_words', type: 'str', minLength: 1, maxLength: 1000 ,default: "bb fuck cunt bitch whore", label: "Spam words (separated by a space)",required: false}, {name: 'spam_phrases', type: 'str', minLength: 1, maxLength: 1000 ,default: "show as:show boo:show pus:open bob:open boo", label: "Spam phrases (separate phrases ONLY by a ':'. Part phrases work better.)",required: false}, {name: 'blapp_option', type:'choice',choice1:'yes',choice2:'no', default: 'no'}, {name: 'mode', type:'choice', choice1:'tip boss', choice2:'highest total / highest tip', choice3:'highest tip / last tip', choice4:'highest total / last tip', choice5:'show no panel / stealth mode', default: 'tip boss'}, {name: 'background_color_1', type:'choice', choice1:'cyan', choice2:'green', choice3:'yellow', choice4:'purple', choice5:'white', choice6:'gray', default: 'yellow', label: "Background color 1 (assigned to Tip Boss and Highest Tip Total user messages)"}, {name: 'background_color_2', type:'choice', choice1:'cyan', choice2:'green', choice3:'yellow', choice4:'purple', choice5:'white', choice6:'gray', default: 'green', label: "Background color 2 (assigned to Highest Tip user messages)"} ]; // handlers cb.onTip(function(tip) { total_tipped += tip['amount'] if (total_tipped > cb.settings.tokens) { total_tipped = cb.settings.tokens; } ontipvoiceuser(tip['from_user']); najvisi(tip['from_user'],tip['amount']); update_subject(); last_tip_amount = tip['amount'] last_tip_username = tip['from_user'] if (tip['amount'] > high_tip_amount) { high_tip_amount = tip['amount'] high_tip_username = tip['from_user'] } if (tip['amount'] >= tip_boss_amount) { if (tip_boss_username != tip['from_user']) { tip_boss_username = tip['from_user']; if (mode == "1") { cb.chatNotice ('**** The new Tip Boss is '+tip_boss_username+' !!!! ****'); } } } cb.drawPanel(); }); cb.onDrawPanel(function(user) { if (cb.settings.mode == "tip boss") { mode = "1"; } else if (cb.settings.mode == "highest total / highest tip") { mode = "2"; } else if (cb.settings.mode == "highest tip / last tip") { mode = "3"; } else if (cb.settings.mode == "highest total / last tip") { mode = "4"; } else { // no panel mode mode = "0"; } if (mode == "1") { // tip boss return { 'template': '3_rows_12_22_31', 'row1_label': 'Game #' + tip_round + '. Tips: ', 'row1_value': '' + total_tipped + ' / ' + cb.settings.tokens, 'row2_label': 'Tip Boss: ', 'row2_value': format_username(tip_boss_username), 'row3_value': 'Tip ' + tip_boss_amount + ' to become Tip Boss' }; } else if (mode == "2") { // highest total / highest tip return { 'template': '3_rows_of_labels', 'row1_label': 'Game #' + tip_round + '. Tips: ', 'row1_value': '' + total_tipped + ' / ' + cb.settings.tokens, 'row2_label': 'Highest Total:', 'row2_value': format_username(high_tip_total_username) + ' (' + high_tip_total_amount + ')', 'row3_label': 'Highest Tip:', 'row3_value': format_username(high_tip_username) + ' (' + high_tip_amount + ')' }; } else if (mode == "3") // highest tip / last tip { return { 'template': '3_rows_of_labels', 'row1_label': 'Game #' + tip_round + '. Tips: ', 'row1_value': '' + total_tipped + ' / ' + cb.settings.tokens, 'row2_label': 'Highest Tip:', 'row2_value': format_username(high_tip_username) + ' (' + high_tip_amount + ')', 'row3_label': 'Last Tip:', 'row3_value': format_username(last_tip_username) + ' (' + last_tip_amount + ')' }; } else if (mode == "4") // highest total / last tip { return { 'template': '3_rows_of_labels', 'row1_label': 'Game #' + tip_round + '. Tips: ', 'row1_value': '' + total_tipped + ' / ' + cb.settings.tokens, 'row2_label': 'Highest Total:', 'row2_value': format_username(high_tip_total_username) + ' (' + high_tip_total_amount + ')', 'row3_label': 'Last Tip:', 'row3_value': format_username(last_tip_username) + ' (' + last_tip_amount + ')' }; } else { mode = "0"; // shows no panel at all (stealth mode) return {}; } }); cb.onMessage(function (msg) { var string=msg['m']; var text = string; // is voicemode active? if (voicemode == true) { // assume all denied denyvoice = true; if ( (msg['user'] == cb.room_slug) || (msg['is_mod']) ) { cb.log("user is host or moderator"); denyvoice = false; } if (vips.indexOf(msg['user'])!=-1) { cb.log("user is in vip list"); denyvoice = false; } if (voicelist.indexOf(msg['user'])!=-1) { cb.log("user is in voicelist"); denyvoice = false; } if (msg['has_tokens'] == true) { cb.log("user has tokens"); denyvoice = false; } cb.log("denyvoice = "+denyvoice); if (denyvoice == true) { cb.chatNotice("Your message has not been posted. You do not have voice permission in this room.\nIf you wish to talk here, you need tokens or need to be granted voice by the broadcaster.", msg['user']); msg['X-Spam'] = true; if (monitorvoice == true) { cb.chatNotice("Non-voiced user ("+msg['user']+") said: "+msg['m'], cb.room_slug); } // return msg; } } // end of voice block // remember the original color, might need it later color = msg['c']; // treat vip users as fan club members if (importedvips == false) { viplist=vipslist.split(" "); for(var i=0;i<viplist.length;i++) { vips.push(viplist[i]); } importedvips = true; } if (importedvips == true) { if (vips.indexOf(msg['user'])!=-1) { msg['in_fanclub'] = true; } } // only the host may turn on and off settings if ( msg['user'] == cb.room_slug ) { if ( string.substring(0,12) == "/REPEATTIME " || string.substring(0,12) == "/repeattime ") { msg['X-Spam'] = true; string = string.replace("/REPEATTIME ",""); string = string.replace("/repeattime ",""); var pattern = new RegExp("^[1-9][0-9]*$"); var testresult = pattern.test(string); cb.chatNotice("testresult ="+testresult, msg['user']); if (string != "" && testresult == true) { var number = parseInt(string); repeat_time = number; cb.chatNotice("Repeat Time is updated. Interval = "+repeat_time ,msg['user']); } else { cb.chatNotice("Repeat Time not update. Error in usage. /REPEATTIME [integer] (1000 per second)", msg['user']); } } // check for command "VOICEMODE" if (string.toUpperCase() == "/VOICEMODE ON") { voicemode = true; cb.chatNotice("Voice Mode is ENABLED." ,msg['user']); } else if (string.toUpperCase() == "/VOICEMODE OFF") { voicemode = false; cb.chatNotice("Voice Mode is DISABLED." ,msg['user']); } else if (string.toUpperCase() == "/VOICEMODE") { var spamstatus = "Voice Mode Active: " + voicemode; cb.chatNotice(spamstatus ,msg['user']); } // check for command "REPEAT" if ( string.substring(0,8) == "/REPEAT " || string.substring(0,8) == "/repeat ") { msg['X-Spam'] = true; string = string.replace("/REPEAT ",""); string = string.replace("/repeat ",""); if (string != "") { repeat_text = string; repeat = true; cb.chatNotice("Repeat Text is ENABLED. Interval = "+repeat_time ,msg['user']); cb.chatNotice(repeat_text); } else { repeat_text = ""; repeat = false; cb.chatNotice("Repeat Text is DISABLED." ,msg['user']); } } // check for command "NOTICE" if ( string.substring(0,8) == "/NOTICE " || string.substring(0,8) == "/notice ") { msg['X-Spam'] = true; string = string.replace("/NOTICE ",""); string = string.replace("/notice ",""); if (string != "") { cb.chatNotice(string); } } // check for command "SPAM" if (string.toUpperCase() == "/SPAM ON") { cb.settings.anti_spam = "yes"; antispam = true; cb.chatNotice("Anti Spam is ENABLED." ,msg['user']); } else if (string.toUpperCase() == "/SPAM OFF") { cb.settings.anti_spam = "no"; antispam = false; cb.chatNotice("Anti Spam is DISABLED." ,msg['user']); } else if (string.toUpperCase() == "/SPAM SHOW") { spamshow = true; cb.chatNotice("SPAM MESSAGES now VISIBLE to Broadcaster." ,msg['user']); } else if (string.toUpperCase() == "/SPAM HIDE") { spamshow = false; cb.chatNotice("SPAM MESSAGES now HIDDEN to Broadcaster." ,msg['user']); } else if (string.toUpperCase() == "/SPAM") { var spamstatus = "Anti Spam Active: " + cb.settings.anti_spam; cb.chatNotice(spamstatus ,msg['user']); } // check for command "EMOTE" if (string.toUpperCase() == "/EMOTE ON") { cb.settings.anti_emoticon = "yes"; cb.chatNotice("Anti Emoticon is ENABLED." ,msg['user']); } else if (string.toUpperCase() == "/EMOTE OFF") { cb.settings.anti_emoticon = "no"; cb.chatNotice("Anti Emoticon is DISABLED." ,msg['user']); } else if (string.toUpperCase() == "/EMOTE") { var emotestatus = "Anti Emoticon Active: " + cb.settings.anti_emoticon; cb.chatNotice(emotestatus ,msg['user']); } // check for command "SHOUT" if (string.toUpperCase() == "/SHOUT ON") { cb.settings.anti_shouting = "yes"; cb.chatNotice("Anti Shouting is ENABLED." ,msg['user']); } else if (string.toUpperCase() == "/SHOUT OFF") { cb.settings.anti_shouting = "no"; cb.chatNotice("Anti Shouting is DISABLED." ,msg['user']); } else if (string.toUpperCase() == "/SHOUT") { var shoutstatus = "Anti Shout Active: " + cb.settings.anti_shouting; cb.chatNotice(emotestatus ,msg['user']); } // check for command "STICKY" if (string.toUpperCase() == "/STICKY ON") { cb.settings.anti_sticky = "yes"; cb.chatNotice("Anti Sticky Keys is ENABLED." ,msg['user']); } else if (string.toUpperCase() == "/STICKY OFF") { cb.settings.anti_sticky = "no"; cb.chatNotice("Anti Sticky Keys is DISABLED." ,msg['user']); } else if (string.toUpperCase() == "/STICKY") { var stickystatus = "Anti Sticky Keys Active: " + cb.settings.anti_sticky; cb.chatNotice(stickystatus ,msg['user']); } // check for command "BLA" if (string.toUpperCase() == "/BLA ON") { cb.settings.blapp_option = "yes"; blappon = true; cb.chatNotice("BLAPP is ENABLED." ,msg['user']); } else if (string.toUpperCase() == "/BLA OFF") { cb.settings.blapp_option = "no"; blappon = false; cb.chatNotice("BLAPP is DISABLED." ,msg['user']); } else if (string.toUpperCase() == "/BLA SHOW") { blapshow = true; cb.chatNotice("BLAPPED MESSAGES now VISIBLE to Broadcaster." ,msg['user']); } else if (string.toUpperCase() == "/BLA HIDE") { blapshow = false; cb.chatNotice("BLAPPED MESSAGES now HIDDEN to Broadcaster." ,msg['user']); } else if (string.toUpperCase() == "/BLA") { var blapstatus = "BLAPP Active: " + cb.settings.blapp_option; cb.chatNotice(blapstatus ,msg['user']); } // check for command "MODE" (tip goal mode) if (string.toUpperCase() == "/MODE 1") { cb.settings.mode = "tip boss"; cb.drawPanel(); cb.chatNotice("Tip Goal Mode is now [option 1] 'Tip Boss'" ,msg['user']); } else if (string.toUpperCase() == "/MODE 2") { cb.settings.mode = "highest total / highest tip"; cb.drawPanel(); cb.chatNotice("Tip Goal Mode is now [option 2] 'Highest Total / Highest Tip'" ,msg['user']); } else if (string.toUpperCase() == "/MODE 3") { cb.settings.mode = "highest tip / last tip"; cb.drawPanel(); cb.chatNotice("Tip Goal Mode is now [option 3] 'Highest Tip / Last Tip'" ,msg['user']); } else if (string.toUpperCase() == "/MODE 4") { cb.settings.mode = "highest total / last tip"; cb.drawPanel(); cb.chatNotice("Tip Goal Mode is now [option 4] 'Highest Total / Last Tip'" ,msg['user']); } else if (string.toUpperCase() == "/MODE 0") { cb.settings.mode = ""; cb.drawPanel(); cb.chatNotice("Tip Goal Mode is now [option 0] 'No Panel / Stealth Mode'" ,msg['user']); } else if (string.toUpperCase() == "/MODE") { cb.chatNotice("Current Tip Goal Mode is: "+cb.settings.mode+" USAGE: /mode [0-3]" ,msg['user']); } // check for command "COLOR FOR TOP ROW" if (string.toUpperCase() == "/COLOR1 CYAN") { cb.settings.background_color_1 = "cyan"; cb.chatNotice("Background Color is now cyan." ,msg['user']); } else if (string.toUpperCase() == "/COLOR1 GREEN") { cb.settings.background_color_1 = "green"; cb.chatNotice("Background Color is now green." ,msg['user']); } else if (string.toUpperCase() == "/COLOR1 YELLOW") { cb.settings.background_color_1 = "yellow"; cb.chatNotice("Background Color is now yellow." ,msg['user']); } else if (string.toUpperCase() == "/COLOR1 PURPLE") { cb.settings.background_color_1 = "purple"; cb.chatNotice("Background Color is now purple." ,msg['user']); } else if (string.toUpperCase() == "/COLOR1 WHITE") { cb.settings.background_color_1 = "white"; cb.chatNotice("Background Color is now white." ,msg['user']); } else if (string.toUpperCase() == "/COLOR1 GRAY") { cb.settings.background_color_1 = "gray"; cb.chatNotice("Highest Tip Total Color is now gray." ,msg['user']); } else if (string.toUpperCase() == "/COLOR1") { var totalcolorstatus = "Current Background Total Color: " + cb.settings.background_color_1 + " (Choices are: cyan, green, yellow, purple, white, gray)"; cb.chatNotice(totalcolorstatus ,msg['user']); } // check for command "COLOR FOR 2ND ROW" if (string.toUpperCase() == "/COLOR2 CYAN") { cb.settings.background_color_2 = "cyan"; cb.chatNotice("Background Color 2 is now cyan." ,msg['user']); } else if (string.toUpperCase() == "/COLOR2 GREEN") { cb.settings.background_color_2 = "green"; cb.chatNotice("Background Color 2 is now green." ,msg['user']); } else if (string.toUpperCase() == "/COLOR2 YELLOW") { cb.settings.background_color_2 = "yellow"; cb.chatNotice("Background Color 2 is now yellow." ,msg['user']); } else if (string.toUpperCase() == "/COLOR2 PURPLE") { cb.settings.background_color_2 = "purple"; cb.chatNotice("Background Color 2 is now purple." ,msg['user']); } else if (string.toUpperCase() == "/COLOR2 WHITE") { cb.settings.background_color_2 = "white"; cb.chatNotice("Background Color 2 is now white." ,msg['user']); } else if (string.toUpperCase() == "/COLOR2 GRAY") { cb.settings.background_color_2 = "gray"; cb.chatNotice("Background Color 2 is now gray." ,msg['user']); } else if (string.toUpperCase() == "/COLOR2") { var tipcolorstatus = "Current Background Color 2: " + cb.settings.background_color_2 + " (Choices are: cyan, green, yellow, purple, white, gray)"; cb.chatNotice(tipcolorstatus ,msg['user']); } // check for command "ROUND" if (string.toUpperCase() == "/ROUND GOAL RESET") { total_tipped = 0; cb.drawPanel(); cb.chatNotice("Total Tips Received has been reset to 0. Highest Tip Total and Highest Tip users retain their rank." ,cb.room_slug); } if (string.toUpperCase() == "/ROUND TIP RESET") { total_tipped = 0; high_tip_total_username = ""; high_tip_total_amount = 0; high_tip_username = ""; high_tip_amount = 0; cb.drawPanel(); cb.chatNotice("Total Tips Received has been reset to 0. Highest Tip Total and Highest Tip users also reset." ,cb.room_slug); } if (string.toUpperCase() == "/ROUND NEXT") { tip_round = tip_round + 1; total_tipped = 0; cb.drawPanel(); var noticetext = "Beginning Game #" + tip_round + ". Tips Received Amount has been reset to 0. Good Luck!"; cb.chatNotice(noticetext); } if (string.toUpperCase() == "/ROUND RESET ALL") { tip_round = 0; total_tipped = 0; high_tip_total_username = ""; high_tip_total_amount = 0; high_tip_username = ""; high_tip_amount = 0; cb.drawPanel(); cb.chatNotice("Tip Goal App restarting..." ,cb.room_slug); } if(string.substring(0,8)=="/tipgoal" && msg['user'] == cb.room_slug) tipgoal(msg); // END OF HOST CHAT COMMANDS } var applyfilters = true; // show ghost user text if (ghosts.indexOf(msg['user'])!=-1) { applyfilters = false; msg['X-Spam'] = true; var ghostnotice = "Ghost User ("+msg['user']+") moans: '"+msg['m']+"'"; cb.chatNotice(ghostnotice); } // filter settings are applied to all regular users if (msg['is_mod'] || msg['user'] == cb.room_slug || msg['in_fanclub']) { applyfilters = false; } if (applyfilters == true) { if(cb.settings.anti_emoticon=="yes") { // var emote = new RegExp('^:[a-zA-Z0-9_]{3,}\w*','gi') //var emote = new RegExp('(?<=:)[a-zA-Z0-9_]{3,}\w*\b','gi') var emote = new RegExp('[ ]:[a-zA-Z0-9_]{3,}\w*','gi') var emote2 = new RegExp('^:[a-zA-Z0-9_]{3,}\w*','gi') var emote_results = emote.test(text); var emote_results2 = emote2.test(text); if (emote_results == true || emote_results2 == true) { var n = text.replace(emote, ""); n = n.replace(emote2, ""); // We are just going to remove image code from now on... // msg['m'] = "[Images Disallowed] "+n; cb.chatNotice("Greys and Blues do not have permission to post images in this room." ,msg['user']); // If the message is blank after stripping images, set as spam if (n == "") { msg['X-Spam'] = true; cb.chatNotice("Your message is not displayed in chat." ,msg['user']); } else if (n != "") { msg['X-Spam'] = false; cb.chatNotice("Images have been stripped from your message prior to it posting." ,msg['user']); msg['m'] = n; } } } if(cb.settings.anti_shouting=="yes") { var countLower = 0; var countUpper = 0; var str = text; for(var i = 0, len = str.length, count=0, ch; i < len; ++i) { ch = str.charAt(i); if(ch >= 'a' && ch <= 'z') ++count; } countLower = count; for(var i = 0, len = str.length, count=0, ch; i < len; ++i) { ch = str.charAt(i); if(ch >= 'A' && ch <= 'Z') ++count; } countUpper = count; if (countUpper > countLower && text.length > 3) { antishoutflag = true; } } if(cb.settings.anti_sticky=="yes") { var repeattext = text.toUpperCase(); var repeats=/([A-Z])\1\1\1/; var results = repeats.test(repeattext); if (results == true) { antistickyflag = true; } } } cb.log("Anti spam: " + antispam); if(string.charAt(0)=="/") { msg['X-Spam'] = true; if(blappon) { // hosts or mods may modify the blapp user list if(string.substring(0,6)=="/blapp" && (msg['is_mod'] || msg['user'] == cb.room_slug)) blapuser(msg); if(string.substring(0,8)=="/unblapp" && (msg['is_mod'] || msg['user'] == cb.room_slug)) unblapuser(msg); if( (string.substring(0,12)=="/usrblapped" || string.substring(0,13)=="/listblapped") && (msg['is_mod'] || msg['user'] == cb.room_slug)) listblappedusers(msg); } // only the host may modify the vip user list if(string.substring(0,4)=="/vip" && msg['user'] == cb.room_slug) vipuser(msg); if(string.substring(0,6)=="/unvip" && msg['user'] == cb.room_slug) unvipuser(msg); if( (string.substring(0,8)=="/listvip") && msg['user'] == cb.room_slug) listvipusers(msg); // hosts or mods may modify the ghost user list if(string.substring(0,6)=="/ghost" && (msg['is_mod'] || msg['user'] == cb.room_slug)) ghostuser(msg); if(string.substring(0,8)=="/unghost" && (msg['is_mod'] || msg['user'] == cb.room_slug)) unghostuser(msg); if( (string.substring(0,10)=="/listghost") && (msg['is_mod'] || msg['user'] == cb.room_slug)) listghostusers(msg); // hosts or mods may modify the voice user list if(string.substring(0,7)=="/voice " && (msg['is_mod'] || msg['user'] == cb.room_slug)) voiceuser(msg); if(string.substring(0,9)=="/unvoice " && (msg['is_mod'] || msg['user'] == cb.room_slug)) unvoiceuser(msg); if( (string.substring(0,10)=="/listvoice") && (msg['is_mod'] || msg['user'] == cb.room_slug)) listvoiceusers(msg); } // assign background colors for tippers background_color_1 = cb.settings.background_color_1; if (background_color_1 == "cyan") { highest_tip_total_color_code = "#3FEFEF"; } else if (background_color_1 == "green") { highest_tip_total_color_code = "#9F9"; } else if (background_color_1 == "yellow") { highest_tip_total_color_code = "#ffff2e"; } else if (background_color_1 == "purple") { highest_tip_total_color_code = "#EEBBF0"; } else if (background_color_1 == "white") { highest_tip_total_color_code = "#FFFFFF"; } else if (background_color_1 == "gray") { highest_tip_total_color_code = "#7F7F7F"; } background_color_2 = cb.settings.background_color_2; if (background_color_2 == "cyan") { highest_tip_color_code = "#3FEFEF"; } else if (background_color_2 == "green") { highest_tip_color_code = "#9F9"; } else if (background_color_2 == "yellow") { highest_tip_color_code = "#ffff2e"; } else if (background_color_2 == "purple") { highest_tip_color_code = "#EEBBF0"; } else if (background_color_2 == "white") { highest_tip_color_code = "#FFFFFF"; } else if (background_color_2 == "gray") { highest_tip_color_code = "#7F7F7F"; } if ( (msg['user'] == tip_boss_username) && (mode == "1") ) { msg['background'] = highest_tip_total_color_code; if (msg['background'] == "#7F7F7F") { msg['c'] = "#FFFFFF"; } else { msg['c'] = color; } } if ( (msg['user'] == high_tip_username) && (mode == "2" || mode == "3") ) { msg['background'] = highest_tip_color_code; if (msg['background'] == "#7F7F7F") { msg['c'] = "#FFFFFF"; } else { msg['c'] = color; } } if ( (msg['user'] == high_tip_total_username) && (mode == "2" || mode == "4") ) { msg['background'] = highest_tip_total_color_code; if (msg['background'] == "#7F7F7F") { msg['c'] = "#FFFFFF"; } else { msg['c'] = color; } } // if (msg['is_mod']){ // msg['background'] = '#FFFB4F'; // } if(blappon) { msg['m']=blabla(msg); } if(antispam && !msg['is_mod'] && msg['user'] != cb.room_slug) { cb.log("in antispam"); if(antispam) { for (var i=0;i<niz.length;i++) { var reg=new RegExp('\\b'+niz[i]+'\\b','gi') if(string.match(reg)!=null){ antispamflag = true; break; } } if (string.match(" ") !=-1) { // if string is only a single word, check all spam phrase words for (var j=0;j<nizphrase.length;j++) { if (string.indexOf(nizphrase[j]) !=-1){ // if(string.match(regp) !=null){ antispamflag = true; break; } } } else { // spam phrase based on regular method for (var j=0;j<nizphrasesplitatwords.length;j++) { if (string.indexOf(nizphrasesplitatwords[j]) !=-1){ // if(string.match(regp) !=null){ antispamflag = true; break; } } } } } if (applyfilters == true) { if (antispamflag == true || antistickyflag == true || antishoutflag == true) { msg['X-Spam'] = true; cb.chatNotice("\"Your message is not displayed in chat for the following reason(s):\"",msg['user']); } if (antispamflag == true) { cb.chatNotice("- Your message contains disallowed words.",msg['user']); if (spamshow==true) { var noticemessage = "Spam Blocked Post from " + msg['user'] + ": '" + msg['m'] + "'"; cb.chatNotice(noticemessage, cb.room_slug); } } if (antishoutflag == true) { cb.chatNotice("- Your sentence contains too many capital letters. Please do not shout.",msg['user']); } if (antistickyflag == true) { cb.chatNotice("- Your keyboard appears to be sticky. You may wish to clean it.",msg['user']); } if (antispamflag == true && antistickyflag == true && antishoutflag == true) { cb.chatNotice("**********\n\"If you continue to submit messages like this one, you'll soon be silenced and/or banned. Thank you for your attention.\"\n**********",msg['user']); } } antiemoticonflag = false; antispamflag = false; antistickyflag = false; antishoutflag = false; return msg; }); // helper functions function update_subject() { if (tips_remaining() == 0) { if (subject_is_set_with_0) { return; } subject_is_set_with_0 = true; } else { subject_is_set_with_0 = false; } if(high_tip_total_username!=null) var new_subject = cb.settings.goal_description + " [" + tips_remaining() + " tokens remaining"+" Highest Total: "+high_tip_total_username+"("+high_tip_total_amount+")]"; else var new_subject = cb.settings.goal_description + " [" + tips_remaining() + " tokens remaining)]"; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } function tips_remaining() { var r = cb.settings.tokens - total_tipped; if (r < 0) { return 0; } else { return r; } } function format_username(val) { if (val === null) { return "--"; } else { // return val.substring(0, 12); return val; } } function najvisi(ime, tip) { var index=imena.indexOf(ime); if(index==-1) { cb.log("new"); imena[imena.length]=ime; tipovi[tipovi.length]=tip; if(high_tip_total_amount==0 || high_tip_total_amount<tip) { high_tip_total_amount=tip; high_tip_total_username=ime; } } else { cb.log("old"); tipovi[index]+=tip; if (tipovi[index]>high_tip_total_amount) { high_tip_total_amount=tipovi[index]; high_tip_total_username=imena[index]; } } } // tip goal (adjust tip goal value) function tipgoal(poruka) { cb.log("at tipgoal adjust"); var pom=poruka['m'].split(" "); if(pom.length!=2) { cb.chatNotice ("error in usage!! usage /tipgoal new_goal_amount",poruka['user']); return; } var n = parseInt(pom[1]); // TO-DO add code to verify that n is a real number greater than zero // currently will let strings through as NaN value. if(n < 1) { cb.log(n); cb.chatNotice ("error in usage!! new goal amount invalid value!",poruka['user']); return; } else { cb.settings.tokens = n; cb.chatNotice ("tip goal amount has been updated!",poruka['user']); cb.drawPanel(); } } // voice user functions function voiceuser(poruka) { cb.log("at voiceuser"); var pom=poruka['m'].split(" "); if(pom.length!=2) { cb.chatNotice ("error in usage!! usage /voice user_to_voice",poruka['user']); return; } if(pom[1]==cb.room_slug) { cb.chatNotice ("Broadcasters cannot be voiced.",poruka['user']); return; } if(pom[1]==poruka['user']) { cb.chatNotice ("You cannot voice yourself.",poruka['user']); return; } if(voicelist.indexOf(pom[1])==-1) { cb.log("at voiceuser: push"); voicelist.push(pom[1]); cb.chatNotice ("User "+pom[1]+" is now voiced.",poruka['user']); // notify the user that they have been given voice cb.chatNotice ("You have been granted voice. You may now talk in this room.", pom[1]); } else { cb.chatNotice ("User "+pom[1]+" was already voiced.",poruka['user']); } } function ontipvoiceuser(tipuser) { // This function only exists to add users to the voicelist if // they tip the host. This ensures that users who tip to grey // stay on the voicelist and aren't suddenly post blocked when // the app detects them as a user without tokens. cb.log("at ontipvoiceuser"); if(voicelist.indexOf(tipuser)==-1) { cb.log("at voiceuser: push"); voicelist.push(tipuser); // Ideally, we would notify the user that they have voice // however, if they went from blue to grey it doesn't matter // This would change if we required tip to talk requirements } else { // do nothing user was already on the list for voiced. } } function listvoiceusers(poruka) { voicelist.sort(); var listvoice = ""; for (var i=0;i<voicelist.length;i++) { listvoice = listvoice + voicelist[i]; if (i != voicelist.length) {listvoice = listvoice + " "} } cb.chatNotice ("Voiced users: ("+voicelist.length+") "+listvoice,poruka['user']); } function unvoiceuser(poruka) { var pom=poruka['m'].split(" "); if(pom.length!=2) { cb.chatNotice ("error in usage!! usage /unvoice user_to_unvoice",poruka['user']); return; } if(voicelist.indexOf(pom[1])==-1) { cb.chatNotice ("User " +pom[1]+ " is not voiced.",poruka['user']); return; } voicelist.splice(voicelist.indexOf(pom[1]),1); cb.chatNotice ("User "+pom[1]+" is unvoiced.",poruka['user']); } // vip user functions function vipuser(poruka) { cb.log("at vipuser"); var pom=poruka['m'].split(" "); if(pom.length!=2) { cb.chatNotice ("error in usage!! usage /vip user_to_blapp",poruka['user']); return; } if(pom[1]==cb.room_slug) { cb.chatNotice ("Broadcasters cannot be a VIP",poruka['user']); return; } if(pom[1]==poruka['user']) { cb.chatNotice ("You cannot VIP yourself",poruka['user']); return; } if(vips.indexOf(pom[1])==-1) { cb.log("at vipuser: push"); vips.push(pom[1]); cb.chatNotice ("User "+pom[1]+" is now a VIP",poruka['user']); } else { cb.chatNotice ("User "+pom[1]+" was already a VIP",poruka['user']); } } function listvipusers(poruka) { vips.sort(); var listvips = ""; for (var i=0;i<vips.length;i++) { listvips = listvips + vips[i]; if (i != vips.length) {listvips = listvips + " "} } cb.chatNotice ("VIP users: ("+vips.length+") "+listvips,poruka['user']); } function unvipuser(poruka) { var pom=poruka['m'].split(" "); if(pom.length!=2) { cb.chatNotice ("error in usage!! usage /unvip user_to_unvip",poruka['user']); return; } if(vips.indexOf(pom[1])==-1) { cb.chatNotice ("User " +pom[1]+ " is not viped",poruka['user']); return; } vips.splice(vips.indexOf(pom[1]),1); cb.chatNotice ("User "+pom[1]+" is unviped",poruka['user']); } // ghost user functions function ghostuser(poruka) { cb.log("at ghostuser"); var pom=poruka['m'].split(" "); if(pom.length!=2) { cb.chatNotice ("error in usage!! usage /ghost user_to_ghost",poruka['user']); return; } if(pom[1]==cb.room_slug) { cb.chatNotice ("Broadcasters cannot be a ghost",poruka['user']); return; } if(pom[1]==poruka['user']) { cb.chatNotice ("You cannot ghost yourself",poruka['user']); return; } if(ghosts.indexOf(pom[1])==-1) { cb.log("at ghostuser: push"); ghosts.push(pom[1]); cb.chatNotice ("User "+pom[1]+" is now a ghost",poruka['user']); } else { cb.chatNotice ("User "+pom[1]+" was already a ghost",poruka['user']); } } function listghostusers(poruka) { ghosts.sort(); var listghosts = ""; for (var i=0;i<ghosts.length;i++) { listghosts = listghosts + ghosts[i]; if (i != ghosts.length) {listghosts = listghosts + " "} } cb.chatNotice ("GHOST users: ("+ghosts.length+") "+listghosts,poruka['user']); } function unghostuser(poruka) { var pom=poruka['m'].split(" "); if(pom.length!=2) { cb.chatNotice ("error in usage!! usage /unghost user_to_unghost",poruka['user']); return; } if(ghosts.indexOf(pom[1])==-1) { cb.chatNotice ("User " +pom[1]+ " is not a ghost",poruka['user']); return; } ghosts.splice(ghosts.indexOf(pom[1]),1); cb.chatNotice ("User "+pom[1]+" is not longer a ghost",poruka['user']); } // blapp user functions function blapuser(poruka) { var pom=poruka['m'].split(" "); if(pom.length!=2) { cb.chatNotice ("error in usage!! usage /blapp user_to_blapp",poruka['user']); return; } if(pom[1]==cb.room_slug) { cb.chatNotice ("Broadcasters cannot be blapped",poruka['user']); return; } if(pom[1]==poruka['user']) { cb.chatNotice ("You cannot blapp yourself",poruka['user']); return; } if(blapped_users.indexOf(pom[1])==-1) { blapped_users.push(pom[1]); cb.chatNotice ("User "+pom[1]+" is blapped",poruka['user']); cb.chatNotice ("User "+pom[1]+" has been blapped by "+poruka['user'], cb.room_slug); } else { cb.chatNotice ("User "+pom[1]+" was already blapped",poruka['user']); } } function listblappedusers(poruka) { var n = blapped_users.length; cb.chatNotice ("Blapped users: ("+n+") "+blapped_users,poruka['user']); } function unblapuser(poruka) { var pom=poruka['m'].split(" "); if(pom.length!=2) { cb.chatNotice ("error in usage!! usage /unblapp user_to_blapp",poruka['user']); return; } if(blapped_users.indexOf(pom[1])==-1) { cb.chatNotice ("User " +pom[1]+ " is not blapped",poruka['user']); return; } blapped_users.splice(blapped_users.indexOf(pom[1]),1); cb.chatNotice ("User "+pom[1]+" is unblapped",poruka['user']); cb.chatNotice ("User "+pom[1]+" has been unblapped by "+poruka['user'], cb.room_slug); } function blabla(poruka) { if(!(blapped_users.indexOf(poruka['user'])==-1)) { var pom=poruka['m'].split(" "); var rmes=""; for(var i=0;i<pom.length;i++) { var blar=Math.round(pom[i].length/3); if(blar==0) blar=1; for(var j=0;j<blar;j++) rmes+="bla"; rmes+=" "; } if (blapshow == true) { // show blapped message to host if /bla [show] var noticemessage = "Blapped User (" + poruka['user'] + ") said: '" + poruka['m'] + "'"; cb.chatNotice(noticemessage, cb.room_slug); } return rmes; } else return poruka['m'] } function init() { cb.log("Begin Init"); if(cb.settings.blapp_option=="yes") blappon=true; cb.log(cb.settings.anti_spam); if(cb.settings.anti_spam=="yes") { antispam=true; spamws=cb.settings.spam_words; niz=spamws.split(" "); spamphr=cb.settings.spam_phrases; nizphrase=spamphr.split(":"); var spamphrsplit = spamphr.replace(":"," "); nizphrasesplitatwords=spamphrsplit.split(" "); cb.log("Anti spam on"); } if (cb.settings.vip_users != "") { cb.log("begin vip init"); cb.log("my field = "+cb.settings.vip_users); vipslist = cb.settings.vip_users; cb.log("end vip init"); } cb.log(cb.settings.anti_spam); update_subject(); } function callme() { if (repeat == true && repeat_text != "") { cb.chatNotice(repeat_text); } cb.setTimeout(callme, repeat_time) } init(); cb.setTimeout(callme, repeat_time)
© Copyright Chaturbate 2011- 2026. All Rights Reserved.