Bots Home
|
Create an App
gift of voice
Author:
nikita1985
Description
Source Code
Launch Bot
Current Users
Created by:
Nikita1985
/* Author: Noddie82 Title: The Gift of Voice and Color Description: Silences all grays, except those that you decide should be allowed to talk. Moderators and people with tokens have voice by default, but can loose it. Change Log: v1.3 2013-05-06 Tell people they can tip for color every 120 seconds Really fix color through tipping v1.2.1-2013-05-04: Bugfix for color through tipping v1.2 - 2013-04-21: Added option screen to enable/disable voice control Added option to throttle gray talk to 1 message per X seconds Added option to allow users to tip for a color Added option to type /voicehelp to list available commands Added option to choose wheter or not moderators can use the slash-commands v1.1 - 2013-04-10: Added option to grant users special background-colors Added option to reset all background-colors Added toggle to disable/reenable voice control v1.0 - 2013-04-09: Initial Release. */ var voiceToggle = cb.settings.grays_can_talk == 'Yes' ? false : true; var broadcaster = cb.room_slug; var voicedUsers = new Array(); var coloredUsers = new Array(); var throttledUsers = new Array(); var colors = new Array(); colors['red'] = "FFCCCC"; colors['orange'] = "FFE0CC"; colors['yellow'] = 'F8FACD'; colors['green'] = "D2FACD"; colors['teal'] = "C4F0F4"; colors['blue'] = "C4DAFC"; colors['purple'] = "E1C4F4"; colors['pink'] = "F6C6E6"; colors['gray'] = "d6cdc8"; //todo - add more color choices cb.chatNotice("The Gift of Voice and Color activated"); cb.chatNotice("Write /voicehelp to show available commands"); viewHelpMessage(broadcaster,true); function viewHelpMessage(usr,isMod) { if(!isMod && cb.settings.color_by_tip == 0) { return; } if(isMod) { cb.chatNotice("/voice USER to give voice",usr); cb.chatNotice("/color USER COLOR to make a user have a special background-color",usr); cb.chatNotice("/unvoice USER to take voice away",usr); cb.chatNotice("/listvoices to list who has voice",usr); } else { cb.chatNotice("Tip a minimium of " + cb.settings.color_by_tip + " tokens to choose a special background colorr!",usr); } cb.chatNotice("- Possible colors: red, orange, yellow, green, teal, blue, purple, pink, gray. No color specified will reset the background",usr); if(isMod) { cb.chatNotice("/togglevoice - toggle the voice control on or off (Default On)",usr); cb.chatNotice("/resetcolors - reset all custom colors",usr); } } function setBackgroundColor(theUser,theColor,theColorer,allowSpecial) { if(!theColor) { return; } if(theColor.length == 0) { return; } if(theColor.trim() == "") { return; } if(colors[theColor] ) { cb.chatNotice("The Gift of the Color " + theColor + " has been granted to '" + theUser + "'!"); } else { if(theColor.substring(0,1) == "#" && allowSpecial) { //only mods can grant special colors - to avoid spam theColor = theColor.substring(1,7); colors[theColor] = theColor; //save the special color code cb.chatNotice("The Gift of the Color " + theColor + " has been granted to '" + theUser + "'!"); } else { if(allowSpecial) { cb.chatNotice("Unknown color - Possible colors: red, orange, yellow, green, teal, blue, purple, pink, gray.",theColorer); } theColor = coloredUsers[theUser]; } } coloredUsers[theUser] = theColor; } cb.onTip(function (tip) { if(cb.settings.color_by_tip > 0) { var x = parseInt(tip['amount']); if(x >= cb.settings.color_by_tip) { setBackgroundColor(tip['from_user'],tip['message'],tip['from_user'],false); } } }); cb.onMessage(function (msg) { var usr = msg['user']; if(coloredUsers[usr]) { msg['background'] = '#' + colors[coloredUsers[usr]]; ; //grant the gift of cool background colors } var isMod = usr == cb.room_slug || msg['is_mod']; var hasVoice = voicedUsers[usr] && true; if(isMod) { hasVoice = true; //mods always have voice and cannot be unvoiced } else if(msg['has_tokens'] || msg['in_fanclub'] ) { if(voicedUsers[usr] == null) { //if a user has tokens or is in fanclub, they must explicitly loose voice to be silenced hasVoice = true; } else { hasVoice = voicedUsers[usr]; } } if(!voiceToggle && !hasVoice && cb.settings.grays_throttle > 0 ) { //voice control is off, check if throttling of grays are on var last = throttledUsers[usr]; if(!last) { throttledUsers[usr] = new Date().getTime(); } else { var since = new Date().getTime() - last; if(since < cb.settings.grays_throttle * 1000) { //message is too soon, stop it msg['X-Spam'] = true; cb.chatNotice("*** Only Voiced users can talk more often than " + cb.settings.grays_throttle + " seconds!",usr); } else { throttledUsers[usr] = null; //null it for quicker fail check } } } if(!hasVoice && voiceToggle) { //only stop message if voice is toggled on msg['X-Spam'] = true; //tell the user his message cannot be read by anyone else cb.chatNotice("*** Your message was not delivered because you don't have voice ***",usr); return msg; } isMod = usr == cb.room_slug || (cb.settings.mod_admins == 'Yes' ? msg['is_mod'] : false); //rerun the isMod, but this time only mod Mods if setting is on if(msg['m'].substring(0,10) == "/voicehelp" ) { //check for this message first cause everyone can type this message viewHelpMessage(usr,isMod); msg['X-Spam'] = true; return msg; } if(isMod) { if(msg['m'].substring(0,11) == "/listvoices") { msg['X-Spam'] = true; cb.chatNotice("*** Voiced people ***",usr); for (var i in voicedUsers) { if(i && voicedUsers[i]) { cb.chatNotice(i,usr); } } } else if(msg['m'].substring(0,6) == "/voice") { var temp = msg['m'].split(" "); if(temp.length > 1) { voicedUsers[temp[1].trim()] = true; cb.chatNotice("The Gift of Voice has been granted to '" + temp[1].trim() + "'!"); } else { cb.chatNotice("Useage: /voice USER",usr); } msg['X-Spam'] = true; } else if(msg['m'].substring(0,8) == "/unvoice") { var temp = msg['m'].split(" "); if(temp.length > 1) { voicedUsers[temp[1].trim()] = false; cb.chatNotice("The Gift of Voice has been removed from '" + temp[1].trim() + "'!"); } else { cb.chatNotice("Useage: /unvoice USER",usr); } msg['X-Spam'] = true; } else if(msg['m'].substring(0,6) == "/color") { var temp = msg['m'].split(" "); if(temp.length == 1) { cb.chatNotice("Useage /color USER color",usr); cb.chatNotice("- Possible colors: red, orange, yellow, green, teal, blue, purple, pink, gray. No color specified will reset the background",usr); } else if(temp.length > 1) { var theColor = null; var theUser = temp[1].trim(); if(temp.length > 2) { theColor = temp[2].trim(); } else { cb.chatNotice("The Gift of Color has been removed from '" + theUser + "'!"); } setBackgroundColor(theUser,theColor,usr,true); } msg['X-Spam'] = true; } else if(msg['m'] == "/togglevoice") { if(voiceToggle) { voiceToggle = false; cb.chatNotice("Voice control disabled, everyone can talk!"); } else { cb.chatNotice("Voice control enabled, grays can no longer talk!"); voiceToggle = true; } msg['X-Spam'] = true; } else if(msg['m'] == "/resetcolors") { cb.chatNotice("All background colors have been reset!"); coloredUsers = new Array(); msg['X-Spam'] = true; } } return msg; }); cb.settings_choices = [ {name: 'mod_admins', type: 'choice', defaultValue: 'Yes' , label: "Allow moderators to use administrative commands", choice1 : 'No', choice2: 'Yes'}, {name: 'grays_can_talk', type: 'choice', defaultValue: 'No', label: "Allow grays limited chat abilities", choice1: 'No', choice2: 'Yes'}, {name: 'grays_throttle', type: 'int', minValue: 0, maxValue: 600, defaultValue: 120, label: "Number of seconds between each time a gray can talk"}, {name: 'color_by_tip', type: 'int', defaultValue: '0', label: 'Minimum tip to get a color of choice (0 = disabled)'} ]; function tipForColor() { if(cb.settings.color_by_tip > 0) { cb.chatNotice("Tip a minimum of " + cb.settings.color_by_tip + " tokens to get your custom background color! Name your color in tip note"); cb.setTimeout(tipForColor, 120000); } } cb.setTimeout(tipForColor, 30000);
© Copyright Chaturbate 2011- 2026. All Rights Reserved.