Bots Home
|
Create an App
weekend_dream_promote_private
Author:
weekend_dream
Description
Source Code
Launch Bot
Current Users
Created by:
Weekend_Dream
const sendToChoices = { everyone: 'Everyone', withTokens: 'Users with tokens' }; const choiceYes = 'yes'; const choiceNo = 'no'; cb.settings_choices = [{ name: 'font_color', type: 'choice', choice1: 'black', choice2: 'grey', choice3: 'purple', choice4: 'blue', choice5: 'green', defaultChoice: 'black', required: true, label: 'Font color of the chat messages' }, { name: 'send_messages_to', type: 'choice', choice1: sendToChoices.everyone, choice2: sendToChoices.withTokens, defaultValue: sendToChoices.everyone, required: true, label: 'Send bot messages to this user group only' }, { name: 'print_private_token_interval', type: 'int', minValue: 1, maxValue: 60, defaultValue: 15, required: true, label: 'Interval in minutes to print the token amount for a private in chat' }]; let fontColor = 'black'; const refreshMillis = 20 * 1000; let timeoutMillis = 0; let currentTimeoutMillis = 0; let canSpyPrivate = false; let cachedSpyTokenPerMinute = 0; function sendNotice(msg) { switch (cb.settings['send_messages_to']) { case sendToChoices.everyone: cb.sendNotice(msg, '', '', fontColor, 'bold'); break; case sendToChoices.withTokens: cb.sendNotice(msg, '', '', fontColor, 'bold', 'lightblue'); cb.sendNotice(msg, '', '', fontColor, 'bold', 'darkblue'); cb.sendNotice(msg, '', '', fontColor, 'bold', 'lightpurple'); cb.sendNotice(msg, '', '', fontColor, 'bold', 'darkpurple'); break; default: cb.log(`Undefined group ${cb.settings['send_messages_to']} in sendNotice() function.`); } } function printPrivateToken() { cb.getRoomOwnerData(ownerData => { if (ownerData.success) { const { room_status: status, allow_private_shows: privateEnabled, allow_private_show_recordings: recordingsEnabled, private_show_tokens_per_minute: tokenPerMinute, spy_on_private_show_tokens_per_minute: spyTokenPerMinute } = ownerData.data; if (currentTimeoutMillis <= 0 && privateEnabled && (status === 'public' || status === 'offline')) { if (recordingsEnabled) { sendNotice(`--- ${cb.room_slug}'s Private (Recording is Enabled) ---\n${tokenPerMinute} Token per Minute`); } else { sendNotice(`--- ${cb.room_slug}'s Private ---\n${tokenPerMinute} Token per Minute`); } currentTimeoutMillis = timeoutMillis; } else if (status === 'private' && spyTokenPerMinute > 0) { if (!canSpyPrivate) { sendNotice(`--- Spy on ${cb.room_slug}'s Private ---\n${spyTokenPerMinute}`); canSpyPrivate = true; } cachedSpyTokenPerMinute = spyTokenPerMinute; } else { currentTimeoutMillis -= refreshMillis; canSpyPrivate = false; } } else { cb.log(`Failed to get room owner data: ${ownerData.errorMessage}`); } cb.setTimeout(printPrivateToken, refreshMillis); }); } cb.onStart(function (user) { fontColor = cb.settings['font_color']; timeoutMillis = cb.settings['print_private_token_interval'] * 60 * 1000; printPrivateToken(); }); cb.onEnter(function (user) { if (canSpyPrivate) { const {user: username, has_tokens: hasTokens, in_fanclub: inFanclub} = user; let sendMsg = false; switch (cb.settings['send_messages_to']) { case sendToChoices.everyone: sendMsg = true; break; case sendToChoices.withTokens: sendMsg = hasTokens; break; default: cb.log(`Undefined group ${cb.settings['send_messages_to']} in cb.onEnter() callback.`); } if (sendMsg) { cb.sendNotice(`--- Spy on ${cb.room_slug}'s Private ---\n${spyTokenPerMinute}`, username, '', fontColor, 'bold'); } } });
© Copyright Chaturbate 2011- 2024. All Rights Reserved.