Bots Home
|
Create an App
Wheel of Fortune by real_ndrvdt
Author:
real_ndrvdt
Description
Source Code
Launch Bot
Current Users
Created by:
Real_Ndrvdt
/** * Bot: Wheel of Fortune! by real_ndrvdt * Based on zingknaat's Roll The Dice * Version: 0.0.5 * Author:real_ndrvdt * Date: 2019-02-24 */ cb.settings_choices = [ { name: 'tokens', type: 'int', minValue: 1, maxValue: 100, label: 'Price per spin', defaultValue: 20 }, { name: 'roomSubj', type: 'str', default: 'Play with me! Tip 20 tk to spin the #wheel !', label: 'Set room title ("-" for nothing)', }, { name: 'skip_prizes', type: 'int', minValue: 0, maxValue: 10, label: 'Avoids to repeat last X prizes for more randomness', defaultValue: 3 }, { name: 'notice_wait_time', type: 'choice', label: 'Show app advertisement every X minutes', choice1: 3, choice2: 5, choice3: 7, choice4: 10, choice5: 15, choice6: 20, choice7: 30, defaultValue: 10 }, { name: 'notice2_wait_time', type: 'choice', label: 'Show random notice every X minutes', choice1: 1, choice2: 2, choice3: 3, choice4: 5, choice5: 7, choice6: 10, choice7: 15, defaultValue: 3 }, { name: 'advertise1', type: 'str', default: ':ndrwhlfrtn_spin20', label: 'Random notice #1 ("-" for nothing)' }, { name: 'advertise2', type: 'str', default: 'Tip 20 tokens to spin the wheel and reveal a prize!', label: 'Random notice #2 ("-" for nothing)' }, { name: 'advertise3', type: 'str', default: '-', label: 'Random notice #3 ("-" for nothing)' }, { name: 'advertise4', type: 'str', default: '-', label: 'Random notice #4 ("-" for nothing)' }, { name: 'advertise5', type: 'str', default: '-', label: 'Random notice #5 ("-" for nothing)' }, {name: 'prize_1', type: 'str', default: 'Show pussy', label: 'Prize for #1'}, {name: 'prize_2', type: 'str', default: 'Topless for 2 minutes', label: 'Prize for #2'}, {name: 'prize_3', type: 'str', default: 'Spank my ass', label: 'Prize for #3'}, {name: 'prize_4', type: 'str', default: 'Air kiss for you!', label: 'Prize for #4'}, {name: 'prize_5', type: 'str', default: 'Play with nipples', label: 'Prize for #5'}, {name: 'prize_6', type: 'str', default: 'Dance', label: 'Prize for #6'}, {name: 'prize_7', type: 'str', default: 'Flash my tits', label: 'Prize for #7'}, {name: 'prize_8', type: 'str', default: 'Doggy pose with panties', label: 'Prize for #8'}, {name: 'prize_9', type: 'str', default: 'Smile for you!', label: 'Prize for #9'}, {name: 'prize_10', type: 'str', default: 'Suck my finger', label: 'Prize for #10'}, {name: 'prize_11', type: 'str', default: 'Flash my ass', label: 'Prize for #11'}, {name: 'prize_12', type: 'str', default: 'Show feet', label: 'Prize for #12'}, {name: 'prize_13', type: 'str', default: 'Striptease', label: 'Prize for #13'}, {name: 'prize_14', type: 'str', default: 'Yoga pose', label: 'Prize for #14'}, {name: 'prize_15', type: 'str', default: 'Stroke the kitty', label: 'Prize for #15'}, {name: 'prize_16', type: 'str', default: 'Spit on boobs', label: 'Prize for #16'}, {name: 'prize_17', type: 'str', default: '-', label: 'Prize for #17 ("-" for nothing)'}, {name: 'prize_18', type: 'str', default: '-', label: 'Prize for #18 ("-" for nothing)'}, { name: 'room_helper', type: 'str', default: 'real_ndrvdt', label: 'Name of the room helper who can use additional commands ("-" for nobody)', }, ]; var winners = []; var prizes = []; var players = {}; var prizeImagePrefix = ':ndrwhlfrtn_'; var lastLuckyNumbers = []; var skipLastPrizes = parseInt(cb.settings.skip_prizes) * -1; var shortAdvertises = []; var bgColorPrize = '#ffe6e6'; var textColorPrize = '#660000'; var bgColorPrizeList = '#FFF0DE'; var textColorPrizeList = '#8A4900'; var bgColorWonList = '#FFF0DE'; var textColorWonList = '#8A4900'; var bgColorAdv = '#FFF0DE'; var textColorAdv = '#8A4900'; var langTokens = (cb.settings.tokens == 1) ? 'token' : 'tokens'; var lastPlayer = ''; var lastPrizeWon = ''; var rollCounter = 0; var tipCounter = 0; var backgroundImage = '279cd2cc-fcf5-4730-97d5-e157ca753bbd'; var textColorLastPrize = '#ff00de'; var textColorLastPlayer = '#0a5aee'; cb.onTip(function (tip) { var currentTip = parseInt(tip['amount']); tipCounter += currentTip; if (currentTip === cb.settings.tokens) { lastPlayer = tip['from_user']; roll(lastPlayer); } }); cb.onEnter(function (user) { showAppAd(user['user']); }); cb.onMessage(function (msg) { if (msg['m'].match(/^\s*\/winners/i)) { msg['X-Spam'] = true; showPrizesWon(msg['user']); } else if (msg['m'].match(/^\s*\/prizes/i)) { msg['X-Spam'] = true; if (msg['m'].match(/all/i) && ((msg['is_mod'] == true) || (msg['user'] == cb.room_slug))) { showPrizes(); } else { showPrizes(msg['user']); } } else if (msg['m'].match(/^\s*\/spin/i) && ((msg['user'] == 'real_ndrvdt') || (msg['user'] == cb.room_slug))) { msg['X-Spam'] = true; // DEBUG tipCounter += cb.settings.tokens; lastPlayer = msg['user']; roll(lastPlayer); } else if (msg['m'].match(/^\s*\/say/i) && isAllowedToUseAdditionalCommands(msg)) { msg['X-Spam'] = true; cb.sendNotice(msg['m'].replace(/^\s*\/say/i, ''), '', '', textColorLastPrize, 'bold'); } else if (msg['m'].match(/^\s*\/bc/i) && isAllowedToUseAdditionalCommands(msg)) { msg['X-Spam'] = true; var noticeText = msg['user'] + ": " + msg['m'].replace(/^\s*\/bc/i, ''); cb.sendNotice(noticeText, cb.room_slug, '', "#cc0000", 'bold'); cb.sendNotice(noticeText, msg['user'], '', "#cc0000", 'bold'); } else if (msg['m'].match(/^\s*\/more/i)) { msg['X-Spam'] = true; var hasAdditionalRights = isAllowedToUseAdditionalCommands(msg); showAppHelp(hasAdditionalRights, msg['user']); } return msg; }); function isAllowedToUseAdditionalCommands(msg) { return msg['is_mod'] == true || msg['user'] == cb.room_slug || (cb.settings.room_helper !== "-" && msg['user'] == cb.settings.room_helper); } function roll(player) { rollCounter++; if (players[player] === undefined) { players[player] = 1; } else { players[player]++; } var rollResult = getRandomNumber(); if (rollResult >= 1 && rollResult <= 18) { var prize = cb.settings['prize_' + rollResult]; } else { var prize = 'A Thank You!'; } var prizeIndex = prizes.indexOf(prize); if (prizeIndex < 0) { prize = 'A Thank You!'; rollResult = 0; // DEBUG // cb.sendNotice('Index of: ' + prizeIndex); } var msg = prizeImagePrefix + rollResult + "\n"; if (player === 'real_ndrvdt') { msg += ":yk_king1 real_ndrvdt's prize is " + "\n"; } else { msg += player + "'s prize is " + '\n'; } msg += '#' + rollResult + ' - ' + prize; cb.sendNotice(msg, '', bgColorPrize, textColorPrize, 'bold'); lastPrizeWon = prize; winners.push(rollCounter + '. ' + player + ' won #' + rollResult + ' - ' + prize); } function getRandomNumber() { var last5numbers = lastLuckyNumbers.slice(skipLastPrizes); var i = 0; var luckyNumber = 0; while (i >= 0 || luckyNumber === 0) { luckyNumber = Math.floor(Math.random() * (prizes.length + 1)); i = last5numbers.indexOf(luckyNumber); } // DEBUG // cb.sendNotice('Lucky number: ' + luckyNumber + '; last prizes: ' + last5numbers.join()); lastLuckyNumbers.push(luckyNumber); return luckyNumber; } function setPrizes() { for (var i = 1; i <= 18; i++) { if (cb.settings['prize_' + i] !== '-') { prizes.push(cb.settings['prize_' + i]); } } } function showPrizes(username) { if (prizes.length) { var msg = "##### POSSIBLE PRIZES #####"; for (var i = 1; i <= 18; i++) { if (prizes.indexOf(cb.settings['prize_' + i]) >= 0) msg += "\n#" + i + ": " + cb.settings['prize_' + i]; } } else { var msg = "SORRY! There are no prizes left in the list, but thank you for the tip. :thumbsup"; } cb.sendNotice(msg, username, bgColorPrizeList, textColorPrizeList, 'bold'); } function showPrizesWon(username) { var msg = "##### LAST 20 WINNERS #####"; if (winners.length == 0) { cb.sendNotice('No one has won anything yet. Spin the wheel to win a prize!', username, '', '', 'bold'); } else { var recentWinners = winners.slice(-20); for (var i = 0; i < recentWinners.length; i++) msg += "\n" + recentWinners[i]; cb.sendNotice(msg, username, bgColorWonList, textColorWonList, 'bold'); } } function advertise() { showAppAd(); cb.setTimeout(advertise, parseInt(cb.settings.notice_wait_time) * 60000); } function showAppAd(username) { var msg = ""; if (username != undefined) { msg += ":ndrwhlfrtn_wheel Welcome, " + username + "! We are playing Wheel of Fortune! \n"; } else { msg += ":ndrwhlfrtn_wheel We are playing Wheel of Fortune! \n"; username = ''; } msg += "Tip " + cb.settings.tokens + " " + langTokens + " to spin the wheel. \n"; msg += "Each spin reveals a prize. There are " + prizes.length + " possible prizes. \n"; msg += "Type \"/prizes\" to see the list of prizes. \n"; msg += "Type \"/winners\" to see a list of the last 20 winners.\n"; msg += "Type \"/more\" to see a list of additional commands."; cb.sendNotice(msg, username, bgColorAdv, textColorAdv, 'bold'); } function showAppHelp(hasAdditionalRights, username) { var msg = "##### Wheel of Fortune! help menu #####\n"; msg += "Type \"/prizes\" to see the list of prizes. \n"; msg += "Type \"/winners\" to see a list of the last 20 winners. \n"; msg += "Type \"/more\" to see a list of additional commands."; if (hasAdditionalRights === true) { msg += "\nType \"/prizes all\" to send the list to all viewers if you're the broadcaster, a mod or the room helper.\n"; msg += "Type \"/say\" to send a notice to all viewers if you're the broadcaster, a mod or the room helper.\n"; msg += "Type \"/bc\" to send a private message to to the broadcaster, if you are a mod or the room helper."; } cb.sendNotice(msg, username, bgColorAdv, textColorAdv, 'bold'); } function advertiseShort(firstCall) { if (shortAdvertises.length === 0) { return; } if (firstCall !== 1) { var randomNumber = Math.floor(Math.random() * (shortAdvertises.length)); var msg = shortAdvertises[randomNumber]; cb.sendNotice(msg, '', '', textColorAdv, 'bold'); } cb.setTimeout(advertiseShort, parseInt(cb.settings.notice2_wait_time) * 60000); } function setShortAdvertises() { for (var i = 1; i <= 5; i++) { if (cb.settings['advertise' + i] !== '-') { shortAdvertises.push(cb.settings['advertise' + i]); } } } function init() { setPrizes(); setShortAdvertises(); advertise(); advertiseShort(1); if (cb.settings.roomSubj != '' && cb.settings.roomSubj != '-') cb.changeRoomSubject(cb.settings.roomSubj); } init();
© Copyright Freesexcam 2011- 2024. All Rights Reserved.