Bots Home
|
Create an App
AutumnVonDoe Password Bot
Author:
fickufertig_de6
Description
Source Code
Launch Bot
Current Users
Created by:
Fickufertig_De6
/* * Title: AutumnVonDoe Password Bot * Author: fickufertig_de6 * Version: 1.2 (10/07/2015) * Title: Password Room by Atreyue8 * Author: Atreyue8 * Version: 1.1 (11/14/2013) * Title: Passwoom Room By theknight2000 * Author: TheKnight2000 (Original) * Version: 1.0 (08/27/13) Updates: 1.2 - Runs super silent. - remove goal and timer 1.1 - Removed auto inserted author credit in the room subject heading. Credit still given to author(s) in chat window ;) - Changed helper functions sendPasswordToUsers() and sendPasswordToUser() to 'bold' text to help stand out in chat window - Allow for cumulative tips from users to get password -functions updated: cb.onTip(), trackTips() . Once user tips cumulative >= ticket cost, send user pass - Additional mod command [!alltippers] to display all tipper names and their total tips (for troubleshooting of course haha) Summary: Set a goal for a password show. Viewers must buy a ticket to watch. Empowers trusted moderators with commands to help manage and setup the show. Tracks first and second place high tippers. Description: When goal is reached, send out the password to the tippers using the commands provided. Exceptions can be made by moderators with the ability to add users manually. Cool when you need to include your regulars in the show. The app also keeps track of and highlights first and second place highest tipper messages. List of commands: !tippers = See the current list of users that have tipped enough for the show !alltippers = See the current list of all users that have tipped and their total tip amounts (broadcaster only) !sendpw <user> = Sends password out to a user or all tippers via chat message (mods only) !adduser <user> = Allows user list to be manually adjusted (mods only) !changepw = Allows the pw to be changed as needed (broadcaster only) !starttimer = Set a count down to reach goal or buy tickets (broadcaster only) !time = Time left on the clock if timer is set (mods only) !cmds = See list of commands (mods only) Status: ------------------------- TODO: * When chatNotice supports styles, stress mods vs. users in tip list for clarity * When PMs are possible, send pw via PM so it stays available to user (lost in chat) */ // vars var total_tipped = 0; var firstTimeInit = true; var password_override = null; var description = "\nTicket to the Show running (v1.1)!\n\n"; var authors = "v1.2 - fickufertig_de6\n + v1.1 - Atreyue8\n" + "v1.0 - TheKnight2000\n"; var COMMAND_SEND_PASSWORD = '!sendpw'; var COMMAND_ADD_USER = '!adduser'; var COMMAND_TIPPER_LIST = '!tippers'; var COMMAND_ALLTIPPER_LIST = '!alltippers'; var COMMAND_CHANGE_PASSWORD = '!changepw'; var COMMAND_SEE_COMMANDS = '!cmds'; function getCommandList() { return nl + '\n' + COMMAND_SEND_PASSWORD + " <user> (no user sends to all)\n" + COMMAND_ADD_USER + " <user> (no user adds you if allowed)\n" + COMMAND_ALLTIPPER_LIST + " (display a list of all tippers and their total tips)\n" + COMMAND_CHANGE_PASSWORD + " Change the show password\n" + nl; } var CONFIG_COLOR_FIRST_PLACE = '#FFF700'; var CONFIG_COLOR_SECOND_PLACE = '#B0FAFF'; var nl = '--------------------------------------------'; cb.settings_choices = [ {name: 'buyin', type: 'int', minValue: 1, defaultValue: 25, label: "Token amount required to buy into password show"}, {name: 'password', type: 'str', minLength: 1, maxLength: 255, defaultValue: "", label: "Password (no spaces)"}, {name:'include_mods', type:'choice', choice1:'yes', choice2:'no', defaultValue:'yes', label: "Moderators can add users (and themselves)?"} ]; var userList = new Array(); var userTipCnt = []; var userTipTotals = {}; // handlers cb.onTip(function(tip) { // track total tips total_tipped += tip['amount']; if (total_tipped > cb.settings.goal) total_tipped = cb.settings.goal; // track users for password show for (var i = 0; i<userTipCnt.length; i++) { if (userTipCnt[i].value >= cb.settings.buyin) { addUser(tip['from_user']); } } }); cb.onMessage(function (msg) { // user commands if (msg['m'].indexOf(COMMAND_TIPPER_LIST) > -1) { cb.log('cmd received: ' + COMMAND_TIPPER_LIST); cb.chatNotice(nl+'\nTicket holders are: ' + getUserList() + '\n'+nl); } // mod commands (don't know if is_mod includes broadcaster) if (msg['m'].indexOf(COMMAND_SEND_PASSWORD) > -1) { cb.log('cmd received: ' + COMMAND_SEND_PASSWORD); if (msg['is_mod'] || msg['user'] == cb.room_slug) { var cmdval = getCommandValue(msg['m']); if (cmdval) { sendPasswordToUser(cmdval); cb.chatNotice('** Password sent to ' + cmdval,msg['user']); } else { cb.chatNotice('** ' + msg['user'] + ' sent password to ticket holders'); sendPasswordToUsers(); } } } if (msg['m'].indexOf(COMMAND_ADD_USER) > -1) { cb.log('cmd received: ' + COMMAND_ADD_USER); if ((msg['is_mod'] && cb.settings.include_mods == 'yes') || msg['user'] == cb.room_slug) { var cmdval = getCommandValue(msg['m']); if (cmdval) { addUser(cmdval); cb.chatNotice('** Password sent to ' + cmdval,msg['user']); cb.chatNotice('** Password sent to ' + cmdval + ' by ' + msg['user'],cb.room_slug); // inform broadcaster } else { addUser(msg['user']); // mods can add themselves if no cmd value cb.chatNotice('** ' + msg['user'] + ' self added to list',cb.room_slug); // inform broadcaster } } } if (msg['m'].indexOf(COMMAND_CHANGE_PASSWORD) > -1) { cb.log('cmd received: ' + COMMAND_CHANGE_PASSWORD); if (msg['user'] == cb.room_slug) { var cmdval = getCommandValue(msg['m']); if (cmdval) { setPassword(cmdval); cb.chatNotice('** Password changed to ' + cmdval + '.\nInform moderators and ticket holders with !sendpw',msg['user']); msg['m'] = COMMAND_CHANGE_PASSWORD + ' ******'; } } else { cb.chatNotice('** Command only available to broadcaster',msg['user']); } } if (msg['m'].indexOf(COMMAND_ALLTIPPER_LIST) > -1) { cb.log('cmd received: ' + COMMAND_ALLTIPPER_LIST); if (msg['user'] == cb.room_slug) { cb.chatNotice(nl + '\nTipper List:\n' + nl,msg['user']); if (userTipCnt.length === 0) { cb.chatNotice('** No tippers yet :(\n' + nl,msg['user']); } else { userTipCnt.sort(function(a,b){ return a[1] - b[1]; }); } for (var i = 0; i<userTipCnt.length; i++) { cb.chatNotice(userTipCnt[i].name + '\t\t- ' + userTipCnt[i].value + '\n',msg['user']); } } else { cb.chatNotice('** Command only available to broadcaster',msg['user']); } } if (msg['m'].indexOf(COMMAND_SEE_COMMANDS) > -1) { cb.log('cmd received: ' + COMMAND_SEE_COMMANDS); if (msg['is_mod'] || msg['user'] == cb.room_slug) { cb.chatNotice(getCommandList(),msg['user']); } } return msg; }); function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } function addUser(user) { if (userList.indexOf(user) < 0) { userList.push(user); sendPasswordToUser(user); } } function removeUser(user) { if (userList.indexOf(user) > -1) { userList.splice(indexOf(user), 1); } } function getUserList() { if (userList.length < 1) return 'No tickets sold!'; else return userList.toString(); } function isTicketed(user) { if (userList.indexOf(user) > -1) return true; return false; } function sendPasswordToUsers() { for (var i=0; i<userList.length; i++) { cb.log('sent pw to ' + userList[i]); cb.chatNotice(getPasswordMessage(),userList[i],'#ffff00','#000000','bold'); } } function sendPasswordToUser(u) { cb.chatNotice(getPasswordMessage(),u,'#ffff00','#000000','bold'); } function getPasswordMessage() { return nl+'\nYour tip allows you to join the password show!\nPassword is between brackets [' + getPassword() + '] \nShow will begin when goal is met or time expires.\nDO NOT give the password to others.\n'+nl; } function getCommandValue(cmd) { var value = null; try { if (cmd.indexOf(' ') > -1) { var cmda = cmd.split(" ",2); value = cmda[1]; } } catch (err) { cb.log('issue getting command value for ' + msg['m']); } return value; } function setPassword(pw) { password_override = pw; } function getPassword() { if (password_override) return password_override; return cb.settings.password; } function init() { //Give author(s) credit :) cb.chatNotice(nl + description + 'Author(s) credit:\n' + authors + nl); cb.chatNotice(getCommandList(),cb.room_slug); } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.