Bots Home
|
Create an App
Lexy's Gift of voice
Author:
lexy2305
Description
Source Code
Launch Bot
Current Users
Created by:
Lexy2305
/* 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.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['blue'] = "3399FF"; colors['orange'] = "FF9933"; colors['pink'] = "FF6699"; colors['steedjgreen'] = "90EE90"; colors['teal'] = "00FFFF"; colors['gray'] = "D3D3D3"; colors['aqua'] = "00FFFF"; colors['violet'] = "EE82EE"; colors['tan'] = "D2B48C"; colors['yellow'] = "FFFF00"; colors['sky'] = "87CEEB"; colors['fuschia'] = "FF00FF"; colors['forest'] = "228B22"; colors['gold'] = "FFD700"; colors['crimson'] = "DC143C"; colors['red'] = "FF8080"; colors['inf'] = "a2e3e8"; colors['elleloverscolor'] = "000000"; colors['indianred'] = "FF6A6A"; colors['peachpuff'] = "EECBAD"; colors['nectarine'] = "FF3300"; colors['hotpink'] = "FF69B4"; colors['aquamarine'] = "7FFFD4"; colors['cadetblue'] = "5F9EA0"; colors['cornflower'] = "6495ED"; colors['deepsky'] = "00BFFF"; colors['plum'] = "DDA0DD"; colors['silver'] = "C0C0C0"; colors['slate'] = "736AFF"; colors['textgray'] = "3B3B3B"; colors['royalblue'] = "4169E1"; 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: aqua, aquamarine, blue, cadetblue, cornflower (blue), crimson, forest (green), fuschia, gold, gray, hotpink, indianred, orange, peachpuff, pink, plum, red, royalblue, silver, sky (blue), tan, teal, violet, yellow. No color specified will reset the background"); 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(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 { cb.chatNotice("Unknown color - Possible colors: blue, orange, pink, green, teal, 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)'} ];
© Copyright Chaturbate 2011- 2026. All Rights Reserved.