Bots Home
|
Create an App
Donate Pot
Author:
brecht
Description
Source Code
Launch Bot
Current Users
Created by:
Brecht
// vars var total_tipped = 0; var subject_is_set_with_0 = false; cb.settings_choices = [ {name: 'tokens', type: 'int', minValue: 1, default: 100}, {name: 'donation_description', type: 'str', minLength: 1, maxLength: 255}, {name: 'token_value_for_donation', type: 'int', minValue: 1, default: 10}, {name: 'interval_seconds', type: 'int', minValue: 1, default: 600}, {name: 'message_color_back', type: 'str', minLength: 1, maxLength: 8, default: '#FFFFFF'}, {name: 'message_color_front', type: 'str', minLength: 1, maxLength: 8, default: '#008800'}, {name: 'thank_you_message', type: 'str', minLength: 1, maxLength: 255, default: 'Thank you so much :hearts'}, {name: 'goal_reached_message', type: 'str', minLength: 1, maxLength: 255, default: 'Donation Goal reached, many thanks to all who donated'} ]; // handlers cb.onTip(function(tip) { if (tips_remaining() != 0) { if (tip['amount'] == cb.settings.token_value_for_donation) { cb.sendNotice("$$$ " + tip['from_user'] + " donated! $$$, " + cb.settings.thank_you_message, '', cb.settings.message_color_back, cb.settings.message_color_front, 'bolder'); total_tipped += tip['amount'] if (total_tipped > cb.settings.tokens) { total_tipped = cb.settings.tokens; } write_message(); } } }); function write_interval_message() { write_message(); cb.setTimeout(write_interval_message, cb.settings.interval_seconds * 1000); } // helper functions function write_message() { if (tips_remaining() == 0) { if (subject_is_set_with_0) { return; } cb.sendNotice(cb.settings.goal_reached_message, '', cb.settings.message_color_back, cb.settings.message_color_front, 'bolder'); subject_is_set_with_0 = true; } else { subject_is_set_with_0 = false; var message = "If you want to donate for [" + cb.settings.donation_description + "],\n" + "please tip " + cb.settings.token_value_for_donation + " tks [" + tips_remaining() + " tokens remaining]"; cb.sendNotice(message, '', cb.settings.message_color_back, cb.settings.message_color_front, 'bolder'); } } function tips_remaining() { var r = cb.settings.tokens - total_tipped; if (r < 0) { return 0; } else { return r; } } write_interval_message();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.