Apps Home
|
Create an App
tip_to_speak
Author:
slapsmcghee
Description
Source Code
Launch App
Current Users
Created by:
Slapsmcghee
// Bitch ass global variables var user_tips = {}; // Set them silly settings cb.settings_choices = [ { name : "amount_to_tip", type : "int", minValue : 0, maxValue : 100, defaultValue : 0, label : "Amount to tip in order to talk" }, { name : "broadcaster", type : "str", label : "Your username" }, { name : "allow_mods_no_tip", type : "choice", choice1 : "true", choice2 : "false" } ]; // Tip event foo cb.onTip(function (tip) { var user = tip['from_user']; var tip_amount = parseInt(tip['amount']); // The user tipped the right amount to speak if ( !(user in user_tips) && (tip_amount >= cb.settings.amount_to_tip) ) { // Slap the bitch ass user into the dict user_tips[user] = tip_amount; } }); /** * Returns true or false depending * on certain settings. * * @param user: the user sending a message * @param tip_setting: the tip value needed to speak * @param is_mod: is the user a mod or not * */ function check_settings(user, tip_setting, is_mod) { var broadcaster = cb.settings.broadcaster.toLowerCase(); var allow_mods = cb.settings.allow_mods_no_tip; if ( allow_mods == "true" ) { allow_mods = true; } if ( allow_mods == "false" ) { allow_mods = false; } if ( allow_mods && is_mod ) { return false; } else { return ( (tip_setting > 0) && (user != broadcaster) ); } } // Some weirdo is trying to talk in the pushy little chat box cb.onMessage(function (msg) { // Get some settings and message info var user = msg['user'].toLowerCase(); var tip_setting = cb.settings.amount_to_tip; var is_mod = msg['is_mod']; var settings_val = check_settings(user, tip_setting, is_mod); // The user hasn't tipped the proper amount to speak if ( !(user in user_tips) && settings_val ) { var tip_string = undefined; if ( tip_setting == 1 ) { tip_string = "".concat(tip_setting).concat(" token"); } else if ( tip_setting > 1 ) { tip_string = "".concat(tip_setting).concat(" tokens"); } cb.sendNotice( ( "You gotta tip: ".concat(tip_string) ).concat(" in order to speak in the chat, you silly little freak"), user); msg['X-Spam'] = true; } // If the user is allowed to speak then the message will be displayed return msg; });
© Copyright Chaturbate 2011- 2026. All Rights Reserved.