Apps Home
|
Create an App
CockRating
Author:
rickblast
Description
Source Code
Launch App
Current Users
Created by:
Rickblast
/** Name: CockRating Author: Blastfuhler aka RickBlast Created: 2021-01-17 Version: 0.1 credits: chelsea2950 and the Dorothy's Ultra Fembot - i've learned a lot from you and took some snippets, thank you **/ cb.settings_choices = [ { name: 'prize', label: 'What the winner gets', type: 'str', }, { name: 'end', label: 'How does the rating ends', type: 'choice', choice1: 'after 10 ratings', choice2: 'after 60 minutes' }, { name: 'timeout', label: 'show results every X minutes', type: 'int', }, { name: 'showTopRatedCock', label: 'show top rated cock every X minutes', type: 'int' } ]; // vars const ratings = []; const cockOfTheDay = undefined; cb.onMessage(function (msg) { var message = msg['m']; var user = msg['user']; var username = undefined; regex = /\/rate ([a-zA-Z0-9-_]*):(\d)/i if(cb.room_slug === user && message.substring(0,5) === '/rate') { let matches = message.match(regex); username = matches[1]; const rating = matches[2]; ratings.push({user: username, rating: rating}); msg['X-Spam'] = true; } if(message === '/list cocks') { if(ratings.length === 0) { cb.chatNotice('there are no ratings yet - be my first'); } else { showResults(); } msg['X-Spam'] = true; } if(message === '/cock of the day') { getTopRatedCock(); msg['X-Spam'] = true; } return msg; }); function showResults() { let resultsArray = []; for(let i = 0; i < ratings.length; i++) { resultsArray.push(ratings[i].user + ' gets ' + ratings[i].rating + ' out of 10'); } const message = resultsArray.join('\n'); cb.sendNotice(message); handleShowResultsTimeout(); } function handleShowResultsTimeout() { const timeout = cb.settings['timeout']; if(timeout > 0) { const timeout_minutes = timeout * 1000 * 60; cb.setTimeout(showResults, timeout_minutes); } } function getTopRatedCock() { let sorted = ratings.sort((a, b) => a.rating - b.rating).reverse(); cb.sendNotice('top rated cock for now: ' + sorted[0].user); handleShowTopRatedCockTimeout(); } function handleShowTopRatedCockTimeout() { const timeout = cb.settings['showTopRatedCock']; if(timeout > 0) { const timeout_minutes = timeout * 1000 * 60; cb.setTimeout(getTopRatedCock, timeout_minutes); } } function getTheWinner() { let sorted = ratings.sort((a, b) => a.rating - b.rating).reverse(); const winner = sorted[0]; cb.chatNotice('... and the winner is: ' + winner.user + '! Your prize: ' + cb.settings['prize']); clearRatings(); } function clearRatings() { cb.chatNotice('all ratings are cleared, a new game starts - may the best cock win!'); ratings = []; handleEndOfRating(); } function handleEndOfRating() { if(cb.settings['end'] === 'after 60 minutes') { const timeout = 6 * 60 * 1000; cb.setTimeout(getTheWinner, timeout); } } handleShowResultsTimeout(); handleShowTopRatedCockTimeout(); handleEndOfRating();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.