C2C for Tokens
Author: pageants
Description Source Code Launch App Current Users

Short Description:

Update your C2C and apply cost for activating users cameras for a selected amount of time.

Full Description

/**
* ==============================================================================
* 🚀 APP NAME: C2C Metered Access - Vibrant Edition (C2C For Tokens)
* ==============================================================================
* 📖 FULL APP DESCRIPTION & FUNCTIONALITY:
*
* ⏱️ 1. METERED ACCESS & TIME CONTROL:
* • Automatically locks room C2C behind a configurable token-per-minute rate.
* • Flexible 0-60 minute minimum initial entry fee configuration.
* • Maximum session time safety capping (5 to 360 minutes) to ensure renewal.
* • Immediate fee application upon tip acceptance.
*
* 💰 2. TIPPING & VIBRANT FORMATTING:
* • Dynamic tip tier calculations (0%, 10%, 15%, 20%) highlighting support.
* • Vibrant neon notice styling with custom deep-background formatting.
*
* 🔗 3. AFFILIATE & CREATOR INTEGRATION:
* • Automatically intercepts anonymous or unregistered room visitors.
* • Bounces guests to an exclusive affiliate signup link:
* https://chaturbate.com/in/?tour=LQps&cam paign=1M0my&track=default&room=pageants
* • Directs secondary support tips and app creation funding to @pageants:
* https://chaturbate.com/pageants
*
* 🤝 4. TERMS, DISCLOSURES & USER AGREEMENT:
* • By installing, activating, and utilizing this app, the broadcaster
* explicitly accepts affiliation with the developer profile `pageants`.
* • Referrals, traffic, and affiliate rewards are routed to @pageants.
* • For technical questions, custom mods, or support, message @pageants directly.
* ==============================================================================
*/

// 1. Broadcaster settings menu choices
cb.settings_choices = [
{
name: 'tokens_per_minute',
type: 'int',
minValue: 1,
maxValue: 1000,
defaultValue: 5,
label: 'Token Price Per Minute (1 - 1000)'
},
{
name: 'minimum_minutes',
type: 'int',
minValue: 0,
maxValue: 60,
defaultValue: 10,
label: 'Minimum Initial Stream Time in Minutes (0 - 60)'
},
{
name: 'max_session_minutes',
type: 'int',
minValue: 5,
maxValue: 360,
defaultValue: 60,
label: 'Maximum Continuous C2C Time Before Renewal (Minutes)'
},
{
name: 'c2c_message',
type: 'str',
minLength: 1,
maxLength: 256,
defaultValue: 'C2C is locked! Tip tokens to unlock timed viewing access.',
label: 'Message Displayed When C2C is Locked'
}
];

// Tracking variables & Affiliate configuration
var userTimeouts = {};
var userExpirations = {};
var devProfileLink = 'https://www.chaturbate.com/pageants';
var devUsername = 'pageants';
var affiliateLink = 'https://chaturbate.com/in/?tour=LQps&campaign=1M0my&track=default&room=pageants';

/**
* 2. Monitor tips, handle guest/anonymous validation, enforce minimum entry fees, and display vibrant tip tiers
*/
cb.onTip(function(tip) {
var username = tip['from_user'];
var isAnonTip = tip['is_anon_tip'] || !username || username === '';

if (isAnonTip) {
cb.sendNotice('✨ C2C access requires a registered account! Please sign up using our exclusive affiliate link: ' + affiliateLink, '', '#330000', '#FF5555', 'bold');
return;
}

var tipAmount = parseInt(tip['amount'], 10);
var tokenRate = cb.settings.tokens_per_minute;
var minMinutes = cb.settings.minimum_minutes;
var minRequiredTokens = tokenRate * minMinutes;
var maxSessionMs = (cb.settings.max_session_minutes || 60) * 60 * 1000;

if (cb.limitCam_isRunning()) {
var hasAccess = cb.limitCam_userHasAccess(username);

// Enforce minimum entry fee if configured (> 0 mins)
if (!hasAccess && minMinutes > 0 && tipAmount < minRequiredTokens) {
cb.sendNotice('⚠️ @' + username + ', the minimum entry fee for C2C is ' + minRequiredTokens + ' tokens (' + minMinutes + ' mins at ' + tokenRate + 't/min). Your tip of ' + tipAmount + 't was applied immediately, but you need ' + (minRequiredTokens - tipAmount) + ' more tokens to unlock access.', username, '#330000', '#FF5555', 'bold');
return;
}

// Calculate time purchased immediately upon tip acceptance
var minutesPurchased = tipAmount / tokenRate;
var msPurchased = minutesPurchased * 60 * 1000;

var now = Date.now();
var currentExpiry = userExpirations[username] || now;
var newExpiry = (currentExpiry > now ? currentExpiry : now) + msPurchased;

// Enforce maximum continuous session time limit
var potentialTotalDuration = newExpiry - now;
if (potentialTotalDuration > maxSessionMs) {
newExpiry = now + maxSessionMs;
cb.sendNotice('ℹ️ @' + username + ', time capped at the maximum continuous limit of ' + cb.settings.max_session_minutes + ' minutes.', username, '#120024', '#FFA500', 'normal');
}

userExpirations[username] = newExpiry;
var totalMsRemaining = newExpiry - now;

// Grant access immediately
if (!hasAccess) {
cb.limitCam_addUsers([username]);
}

// Clear existing timer if present
if (userTimeouts[username]) {
cb.cancelTimeout(userTimeouts[username]);
}

// Set expiration timer to close access when time runs out
userTimeouts[username] = cb.setTimeout(function() {
if (cb.limitCam_userHasAccess(username)) {
cb.limitCam_removeUsers([username]);
}
delete userTimeouts[username];
delete userExpirations[username];
var renewalText = minMinutes > 0 ? 'Please tip ' + minRequiredTokens + '+ tokens to add more minutes and resume access.' : 'Please tip to add more minutes and resume access.';
cb.sendNotice('🔒 @' + username + ', your C2C paid time has fully expired and the camera has been shut. ' + renewalText, username, '#2A0013', '#FF3366', 'bold');
}, totalMsRemaining);

var totalMinutesLeft = (totalMsRemaining / 60000).toFixed(1);

// Dynamically calculate optional tip tiers including 0% ("Maybe next time") pointing to pageants
var tier0Text = '"Maybe next time 0% tip"';
var tier10 = Math.round(tipAmount * 0.10);
var tier15 = Math.round(tipAmount * 0.15);
var tier20 = Math.round(tipAmount * 0.20);

var noticeText = '✨ @' + username + ' unlocked ' + minutesPurchased.toFixed(1) + 'm C2C (' + totalMinutesLeft + 'm left)! ✨\n' +
'💡 Support creator app development (' + devProfileLink + ' / @' + devUsername + '):\n' +
'• 0%: ' + tier0Text + '\n' +
'• 10% (' + tier10 + 't) | 15% (' + tier15 + 't) | 20% (' + tier20 + 't) -> `/tip ' + devUsername + ' [amount]`';

cb.sendNotice(noticeText, '', '#120024', '#00FFCC', 'bold');
}
});

/**
* 3. Broadcaster Chat Controls
*/
cb.onMessage(function(msg) {
var message = msg['m'].trim();
var user = msg['user'];

if (user === cb.room_slug) {
if (message === '/startc2c') {
if (!cb.limitCam_isRunning()) {
cb.limitCam_start(cb.settings.c2c_message);
var minMins = cb.settings.minimum_minutes;
var feeDesc = minMins > 0 ? ' (Min Fee: ' + (cb.settings.tokens_per_minute * minMins) + 't)' : ' (No Min Fee)';
cb.sendNotice('🚀 C2C Metered Access ACTIVE & LOCKED! Rate: ' + cb.settings.tokens_per_minute + ' tokens/min' + feeDesc + '. | Questions? Message @' + devUsername + ' via ' + devProfileLink, '', '#2E0854', '#00FF99', 'bold');
} else {
cb.sendNotice('C2C Metered Access is already running.', user, '', '#FFA500', 'normal');
}
} else if (message === '/stopc2c') {
if (cb.limitCam_isRunning()) {
for (var u in userTimeouts) {
cb.cancelTimeout(userTimeouts[u]);
}
userTimeouts = {};
userExpirations = {};

cb.limitCam_stop();
cb.sendNotice('🛑 C2C Metered Access has been stopped. Cam is public again.', '', '#330000', '#FF5555', 'bold');
} else {
cb.sendNotice('C2C Metered Access is not currently running.', user, '', '#FFA500', 'normal');
}
}
}
return msg;
});

/**
* 4. Notify joining users (Bouncing anonymous/guests to the affiliate sign-up link)
*/
cb.onEnter(function(user) {
var username = user['user'];
var isAnonymous = (!username || username === '');

if (cb.limitCam_isRunning()) {
if (isAnonymous) {
cb.sendNotice('✨ C2C is locked! To unlock C2C and join the show, please sign up using our exclusive affiliate link: ' + affiliateLink, '', '#120024', '#FF70A6', 'bold');
} else {
var minMins = cb.settings.minimum_minutes;
var entryDesc = minMins > 0 ? ' (Minimum entry fee: ' + (cb.settings.tokens_per_minute * minMins) + ' tokens for ' + minMins + 'm)' : '';
cb.sendNotice('🔒 C2C is locked behind a metered rate of ' + cb.settings.tokens_per_minute + ' tokens/min' + entryDesc + '! Tip tokens to purchase viewing time.', username, '#120024', '#FF70A6', 'normal');
}
}
});

/**
* 5. App Panel display rendering tailored unique views for registered vs anonymous users
*/
cb.onDrawPanel(function(user) {
var username = user['user'];
var isAnonymous = (!username || username === '');

if (isAnonymous) {
return {
'template': '3_rows_of_labels',
'row1_label': 'C2C Locked:',
'row1_value': 'Sign Up Required',
'row2_label': 'Affiliate Link:',
'row2_value': 'chaturbate.com/in/?tour=LQps...',
'row3_label': 'Creator Support:',
'row3_value': devUsername
};
} else {
return {
'template': '3_rows_of_labels',
'row1_label': 'C2C Rate:',
'row1_value': cb.settings.tokens_per_minute + 't/min',
'row2_label': 'Questions / Dev:',
'row2_value': 'Message @' + devUsername,
'row3_label': 'Tip App Creator:',
'row3_value': '/tip ' + devUsername + ' [amt]'
};
}
});

© Copyright Chaturbate 2011- 2026. All Rights Reserved.