Bots Home
|
Create an App
Password Game Bot
Author:
butter_my_toast
Description
Source Code
Launch Bot
Current Users
Created by:
Butter_My_Toast
/** Name: Dorothy's Password Game Bot Author: butter_my_toast **/ {cb.settings_choices = [ {name: 'dummyIntro', label: ' ******************* Introduction ********************* Latest Updt: 3/27/2020 (version 1.1) ', type: 'choice',required: false}, {name: 'dummyPassword', label: 'Welcome! To play Password, the viewers can tip to have the broadcaster(s) act out (Password) or draw (Pictionary) a word or phrase, and then the tipper or the audience attempts to guess what they are acting out or drawing. There are three modes - Broadcaster against Broadcaster (usually for couples/multiple performer shows), and two levels of viewer against room (usually for solo shows) - single games and a goal race.', type: 'choice',required: false}, {name: 'passwordMode', label: 'Game Format -- Based on the mode selected here, set up ONE of the sections below for that mode. For Broadcaster against Broadcaster, the broadcasters take turns, and accumulate points when the room guesses correctly on their turn. This can one round or multiple rounds until one broadcaster reaches the specified point total, up to 5 broadcasters can play. This mode can either be run with or without a tip requirement. For viewer against the room, the person who tips is trying to guess correctly before anyone else in the room to win a prize, and this goes 1 round for each tip.',required: false, type: 'choice', choice1: 'Mode 1 - Broadcaster against Broadcaster', choice2: 'Mode 2 - Viewer against Room (One Game)', choice3: 'Mode 3 - Viewer against Room (Goal Race)', defaultValue: 'Mode 2 - Viewer against Room (One Game)'}, {name: 'passwordSource', label: 'Source of Word List',required: false, type: 'choice', choice1: 'Bot Default List', choice2: 'Broadcaster Defined List', choice3: 'Added During Game', defaultValue: 'Bot Default List'}, {name: 'passwordList', label: 'Word List -- If selecting "Broadcaster Defined List" above, list the words and phrases you want to use below. Use a ":" to separate the words and phrases from each other, in a format such as "Superman:Airplane Pilot:Reading a book". The actual word or phrase for each game will be randomly chosen from this list. The matching to the viewer guesses is not case sensitive, so it does not matter if they are capitalized or not',required: false,type: 'str',minLength: 1, maxLength: 2000}, {name: 'passwordRandom', label: 'Randomize Words? -- Should the next password word or phrase be drawn at random from the list, or go in order of the entries in the list?', type: 'choice', choice1: 'Random', choice2: 'In Order', defaultValue: 'Random'}, {name: 'freePlayStarts', label: 'Free Play Immediate start -- When using the "/pwfree" command to simulate a tip to start a game, immediately start the game, or wait until "/pwplay" initiates the timer?', type: 'choice', choice1: 'Immediate Start', choice2: 'Require Command', defaultValue: 'Require Command'}, {name: 'allowModsAuthority', label: 'Moderator Authority -- Allow moderators to have authority to broadcaster commands?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'passwordModsKnowWord', label: 'Moderators Play? -- Do the moderators have visiblity to the Password Word or Phrase (they don\'t play the game), and are able to add words to the list?',required: false, type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'silenceLevel', label: 'Allow silenced users -- If you have silenced certain user groups and do not want gray users or light blue users to guess, make the appropriate selection here',required: false, type: 'choice', choice1: 'All Users Can Guess', choice2: 'Gray Users Cannot Guess', choice3: 'Gray & Light Blue Users Cannot Guess', defaultValue: 'All Users Can Guess'}, {name: 'passwordNoticeInterval', label: 'Notice Interval -- Decimals like "3.2" are ok as long as they are greater than 1, setting is in minutes.',required: false,type: 'str',defaultValue: 2.6}, {name: 'passwordNoticeTextColor', label: 'Notice Text Color',type: 'choice',choice1: 'White/No Color',choice2: 'Black',choice3: 'Dark Grey',choice4: 'Dark Red',choice5: 'Dark Orange',choice6: 'Dark Green',choice7: 'Dark Aqua',choice8: 'Dark Blue',choice9: 'Dark Purple',choice10: 'Dark Pink',choice11: 'Dark Gold',choice12: 'Dark Teal',choice13: 'Dark Brown',choice14: 'Dark Bronze',choice15: 'Dark Periwinkle',choice16: 'Dark Fuschia',choice17: 'Dark Lime',choice18: 'Dark Plum',choice19: 'Custom',defaultValue: 'Dark Plum'}, {name: 'passwordNoticeBgColor', label: 'Notice Background/Highlight Color',required: false,type: 'choice', choice1: 'White/No Color',choice2: 'Light Yellow',choice3: 'Light Blue',choice4: 'Light Pink',choice5: 'Light Red',choice6: 'Light Green',choice7: 'Light Purple',choice8: 'Light Orange',choice9: 'Light Grey',choice10: 'Light Aqua',choice11: 'Light Teal',choice12: 'Cream',choice13: 'Light Bronze',choice14: 'Light Periwinkle',choice15: 'Light Fuschia',choice16: 'Light Lime',choice17: 'Light Plum',choice18: 'Custom',defaultValue: 'Light Pink'}, {name: 'dummyPassword1', label: ' ************** Password Mode 1 Setup *************', type: 'choice',required: false}, {name: 'passwordBABPlayer1', label: 'Mode 1 - Player 1 Name',type: 'str',minLength: 1, maxLength: 25,defaultValue: 'Player 1 Name'}, {name: 'passwordBABPlayer2', label: 'Mode 1 - Player 2 Name',type: 'str',minLength: 1, maxLength: 25,defaultValue: 'Player 2 Name'}, {name: 'passwordBABPrice', label: 'Mode 1 - Price -- Tip amount required to start each game. Leave this as "0" to play without tips required and start all games with the /pwfree command.',type: 'int',minValue: 0,maxValue: 1000, defaultValue: 0}, {name: 'passwordBABGoal', label: 'Mode 1 - Point Goal -- Winning Broadcaster is the first one to this many correct guesses by the room',type: 'int',minValue: 1,maxValue: 100, defaultValue: 5}, {name: 'passwordBABPrize', label: 'Mode 1 - Prize for winning broadcaster -- Any text value can be entered, such as "Winner Receives oral from Loser" or "Winner Spanks Loser"',required: false,type: 'str'}, {name: 'dummyPassword2', label: ' ************** Password Mode 2 Setup **************', type: 'choice',required: false}, {name: 'passwordVARPrice', label: 'Mode 2 - Price -- Tip amount required to start each game. Leave this as "0" to play without tips required and start all games with the /pwfree command.',type: 'int',minValue: 1,maxValue: 1000, defaultValue: 39}, {name: 'passwordVARPrize', label: 'Mode 2 - Prize - Any text value can be entered',required: false,type: 'str',minLength: 1, maxLength: 50}, {name: 'dummyPassword3', label: ' ************** Password Mode 3 Setup ***************', type: 'choice',required: false}, {name: 'passwordVAR2Goal', label: 'Mode 3 - Set the total point goal at which the winner gets the prize. Tippers who win their own game get 3 points, correct guesses from the rest of the room win 1 point.',type: 'int',minValue: 1,maxValue: 100, defaultValue: 8}, {name: 'passwordVAR2Price', label: 'Mode 3 - Price -- Tip amount required to start each game. Leave this as "0" to play without tips required and start all games with the /pwfree command.',type: 'int',minValue: 1,maxValue: 1000, defaultValue: 59}, {name: 'passwordVAR2Prize', label: 'Mode 3 - Prize - Any text value can be entered',required: false,type: 'str',minLength: 1, maxLength: 50} ]; } // *********************************** Variables and Arrays ************************************** { var initialize = 0; var dashLine60 = new Array(60).join('-'); var dashLine70 = new Array(70).join('-'); var dashLine80 = new Array(80).join('-'); var dashLine90 = new Array(90).join('-'); var appNoticeColor = '#4dd2ff'; // blue for general chat notices var appWarningColor = '#f4d599'; // yellow for general chat warnings (invalid prizes, invalid timer, etc) var appWarningTextColor = '#ff0000'; // red for general chat warnings (invalid prizes, etc) var yellow = '#f4d599'; // Used for clock countdown var red = '#f4c1bc'; // Used for last 2 minutes of clock countdown // ************ Variables for Password Game var passwordToggle = 0; var passwordPrize = ''; var passwordVARPlayer = ''; var passwordGuessing = false; var passwordWaiting = false; var passwordEndWarning = false; var passwordActive = false; var passwordRound = 0; var passwordPrice = 0; var passwordGamesThisRound = 0; var passwordSource = cb.settings.passwordSource; var passwordMinsRemain = 0; var passwordSecsRemain = 0; var passwordMode = cb.settings.passwordMode; // ************ Arrays var VIPListArray = []; var extFanListArray = []; var passwordList = []; var passwordWinners = []; var passwordDefaultList = ['star wars','elephant','lord of the rings','harry potter','madonna','little drummer boy','halloween','mermaid','titanic','full moon','volcano','kangaroo','lovense lush','babe ruth','goat','google','road trip','orange juice','spaghetti','Pacific Ocean', 'sex on the beach','bounce','alice in wonderland','koala','pyramid','south pole','queen','tarzan','captain america','flossy','dolphin','surfboard','farmer','tanlines','batman','superman','spiderman','jumper cables','sombrero','blue balls','bukkake','gangbang','orgy','threesome', 'butt plug','jeep','convertible','vacation','pineapple','cruise','short bus','winnie the pooh','puzzle','nutsack','mr bill','deep throat','polar bear','picasso','big ben','amazon','high school','leopard','edible panties','eiffel tower','gag reflex','dominatrix','peter pan', 'tinkerbelle','my precious','playboy bunny','jungle','gymnast','sailing','fuck buddy','telescope','saturn','thermometer','cucumber','balls deep','chef','great white shark','cello','jello','mexican jumping beans','bumblebee','rice crispies','igloo','carpet muncher','oreos', 'tarantula','iron man','jester','top gun','pac man','space invaders','asteroid','comet','black hole','dust bunny','tumbleweed','cartwheel','brown starfish','cornhole','alexa','casino','bartender','parallel','lumberjack','lawyer','scientist','chia pet','chemistry','siren', 'fireman','witch','mummy','frozen','snowman','queen of hearts','sudden death','homework','island','contract','hole in one','strip poker','nun','lucky charms','ping pong','pinball wizard','earthquake','seesaw','skateboard','snowball','pajamas','seashell','rhinoceros','saddle', 'hippopotamus','banana peel','frankenstein','cheerleader','captain','shopping cart','dentist','hair dryer','pizza','owl','gingerbread man','mouse trap','windmill','tuba','knot','quicksand','python','spider web','eraser','swordfish','flamingo','huddle','cumberbund', 'horse','door','song','trip','backbone','bomb','round','treasure','garbage','park','pirate','ski','state','whistle','palace','baseball','coal','queen','dominoes','photograph','computer','hockey','aircraft','hot dog','salt and pepper','key','iPad','whisk','frog','lawnmower', 'mattress','pinwheel','cake','circus','battery','mailman','cowboy','password','bicycle','skate','electricity','lightsaber','thief','teapot','deep','spring','nature','shallow','toast','outside','roller blading','gingerbread man','bowtie','half','spare','wax','light bulb','platypus', 'music','bobsled','cast','sculpture','early bird special','granola bar','prick','bbc','cavity search','mug shot','monopoly','pearl necklace','nipple ring','circle jerk','quickie','sex doll','viking','Will Smith','defect','standing ovation','flag','retaliate','mascot','shipwreck', 'jet lag','comfort zone','application','college','lifestyle','level','invitation','applesauce','crumb','loyalty','corduroy','fizz','shrink','ray','game plan','déjà vu','Olympic Games','oil','procrastinate','criticize','ergonomic','teenager','organize','baby monitor','Beethoven', 'streamline','satellite','gratitude','journal','a cappella','beanstalk','explore','mineshaft','dismantle','weed killer','tachometer','unemployed','port','peck','windmill','party theme','dentist','softball','wig','stain','cuff','sunburn','funniest','sheet','hair dryer','nightmare', 'shadow','fog','sip','bathroom scale','taxi','pizza','sand','cowboy','ticket','doghouse','stiff','president','wrench','wench','story','whisk','quicksand','spine','chess','artist','invest','spider web','bobsled','lung','washing machine','boar','torch','eraser','mini blinds', 'mouse trap','jar','cramp','cast','honk','mirror','business trip','chalk','gym','volcano','folio','evolution','apathy','advertise','roundabout','sandbox','conversation','conservation','negotiate','silhouette','aisle','pendulum','sorcerer','wizard']; var passwordPlayers = []; var passwordScores = [0]; var passwordLevelPrizes = []; var passwordNextPlayer = []; var passwordResults = []; var passwordVAR2Scores = {user: [], score: [0]}; var passwordBABScores = {user: [], score: [0]}; } // *********************************** Functions ************************************** { // Generic functions to set the color or separator characters function checkTextColor(color) { switch (color) { case 'White/No Color': return '#FFFFFF'; case 'Black': return '#000000'; case 'Dark Blue': return '#0629AC'; case 'Dark Pink': return '#FF6680'; case 'Dark Green': return '#006600'; case 'Dark Red': return '#cc0000'; case 'Dark Purple': return '#3d003d'; case 'Dark Grey': return '#737373'; case 'Dark Orange': return '#e77400'; case 'Dark Aqua': return '#006767'; case 'Dark Gold': return '#998100'; case 'Dark Teal': return '#003f1f'; case 'Dark Brown': return '#582c00'; case 'Dark Bronze': return '#a56728'; case 'Dark Periwinkle': return '#155bd7'; case 'Dark Fuschia': return '#d6155c'; case 'Dark Lime': return '#6b790c'; case 'Dark Plum': return '#7f13bf'; default: if (/^#[0-9A-F]{6}$/i.test(color)) { return color; } else if (/^[0-9A-F]{6}$/i.test(color)) { return ('#' + color); } else { return ('default'); } } } function checkBgColor(color) { switch (color) { case 'White/No Color': return '#FFFFFF'; case 'Light Aqua': return '#adeaea'; case 'Light Pink': return '#FFE6EA'; case 'Light Green': return '#94e594'; case 'Light Red': return '#ff9a9a'; case 'Light Purple': return '#f2cdff'; case 'Light Orange': return '#ffd9b3'; case 'Light Grey': return '#e6e6e6'; case 'Light Blue': return '#d1eaee'; case 'Light Yellow': return '#ffff94'; case 'Cream': return '#f9f6ed'; case 'Light Bronze': return '#ebccad'; case 'Light Periwinkle': return '#d7e4fb'; case 'Light Teal': return '#d7fbee'; case 'Light Fuschia': return '#fbd7e4'; case 'Light Lime': return '#ecf6a7'; case 'Light Plum': return '#e3c0f9'; default: if (/^#[0-9A-F]{6}$/i.test(color)) { return color; } else if (/^[0-9A-F]{6}$/i.test(color)) { return ('#' + color); } else { return ('default'); } } } // ************** User List Functions ************ function findTipper(user) { for (var i = 0; i < kenoTipCountArray.name.length; i++) { if (kenoTipCountArray.name[i] == user) { break; } } return i; } // *********************************** Password Functions ************************************** function passwordSetToggle(option, mod) { if (option == 'on') { if (passwordToggle == 1) { cb.sendNotice('The Password Game is already enabled.', mod, appNoticeColor); } else { passwordInit(); if (validPassword == true) { passwordToggle = 1; passwordInitNoticeTimer(); cb.sendNotice('You have enabled the Password Game.', mod, appNoticeColor); } else { cb.sendNotice('Invalid setting, the Password Game could not be started.', mod, appWarningColor, appWarningTextColor, 'bold'); } } } else if (option == 'off') { if (passwordToggle == 0) { cb.sendNotice('The Password Game is already disabled.', mod, appNoticeColor); } else { passwordToggle = 0; cb.sendNotice('You have disabled the Password Game.', mod, appNoticeColor); cb.sendNotice('The Password game has been disabled, tips will no longer start a Password game.', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } } } function passwordInit() { passwordNoticeTextColor = checkTextColor(cb.settings.passwordNoticeTextColor); passwordNoticeBgColor = checkBgColor(cb.settings.passwordNoticeBgColor); passwordNumberofPlayers = 1; passwordActive = false; validPassword = true; passwordWordSelected = false; passwordLoadList(); if (validPassword = true) { if (passwordMode == 'M1') { passwordLoadBABPlayers(); } else { passwordTipper = ''; } } if (validPassword = true) { passwordLoadPrizes(); } passwordRound = 1; passwordGamesThisRound = 0; passwordGamesPerRound = passwordNumberofPlayers; passwordCurrentPlayerIndex = 0; passwordCurrentPlayer = passwordPlayers[passwordCurrentPlayerIndex]; passwordGamesGoalRace = 0; passwordWaiting = false; setPasswordWaitingTimer(); } function passwordLoadList() { if (passwordList.length > 0) { cb.sendNotice( 'Password Game Setup Notice - Existing word list kept on restart. \nYou can use the command /pwclearlist to clear the existing wordlist.', cb.room_slug, appWarningColor, '', 'bold'); } else { if (passwordSource == 'Bot Default List') { passwordList = passwordDefaultList; if (passwordList.length == 0 || passwordList[0] == ' ' || passwordList[0] == '' || passwordList[0] == null) { validPassword = false; cb.sendNotice( 'Password Game Setup Error - Password Default Word/Phrase list not populated.', cb.room_slug, appWarningColor, '', 'bold'); return; } } else if (passwordSource == 'Broadcaster Defined List') { var n = cb.settings.passwordList; passwordList = n.split(':'); if (passwordList.length == 0 || passwordList[0] == ' ' || passwordList[0] == '' || passwordList[0] == null) { validPassword = false; passwordList.length = 0; cb.sendNotice( 'Password Game Setup Notice - Word/Phrase list configured for "Broadcaster Defined List" but no list entered on launch page. \nPlease use the command "/pwword xxxxx" to add words and phrases to the word list for the game, where "xxxxx" is the word or phrase you would like to add. \nWords must be spelled exactly the same for a match, but are not case sensitive.', cb.room_slug, appNoticeColor, '', 'bold'); return; } } } } function passwordLoadBABPlayers() { if (cb.settings.passwordBABPlayer1) { passwordPlayers[0] = cb.settings.passwordBABPlayer1; passwordScores[0] = 0; } else { validPassword = false; cb.sendNotice( 'Password Game Setup Error - Configured for "Mode 1 - Broadcaster against Broadcaster" but Player 1 is not defined.', cb.room_slug, appWarningColor, '', 'bold'); return; } if (cb.settings.passwordBABPlayer2) { passwordPlayers[1] = cb.settings.passwordBABPlayer2; passwordScores[1] = 0; } else { validPassword = false; cb.sendNotice('Password Game Setup Error - Configured for "Mode 1 - Broadcaster against Broadcaster" but Player 2 is not defined.', cb.room_slug, appWarningColor, '', 'bold'); return; } passwordNumberofPlayers = passwordPlayers.length; } function passwordLoadPrizes() { if (passwordMode == 'M1') { if (cb.settings.passwordBABPrize) { passwordPrize = cb.settings.passwordBABPrize; cb.sendNotice('Password Game Setup Notice - Mode 1, Prize: ' + passwordPrize, cb.room_slug, appNoticeColor) } else { cb.sendNotice('Password Game Setup Error - Mode 1, No Prize is defined.', cb.room_slug, appWarningColor, '', 'bold'); validPassword = false; return; } } else if (passwordMode == 'M2') { if (cb.settings.passwordVARPrize) { passwordPrize = cb.settings.passwordVARPrize; cb.sendNotice('Password Game Setup Notice - Mode 2, Prize: ' + passwordPrize, cb.room_slug, appNoticeColor) } else { cb.sendNotice('Password Game Setup Error - Mode 2, No Prize is defined.', cb.room_slug, appWarningColor, '', 'bold'); validPassword = false; return; } } else if (passwordMode == 'M3') { if (cb.settings.passwordVAR2Prize) { passwordPrize = cb.settings.passwordVAR2Prize; cb.sendNotice('Password Game Setup Notice - Mode 3, Prize: ' + passwordPrize, cb.room_slug, appNoticeColor) } else { cb.sendNotice('Password Game Setup Error - Mode 3, No Prize is defined.', cb.room_slug, appWarningColor, '', 'bold'); validPassword = false; return; } } } function passwordInitNoticeTimer() { if (cb.settings.passwordNoticeInterval == '' || cb.settings.passwordNoticeInterval == null) { cb.sendNotice('Password Game Warning - Chat Notice Interval was not set. Using default value of 2.6 minutes.', cb.room_slug, appWarningColor, '', 'bold'); passwordInt = 2.6; } else { passwordInt = parseFloat(cb.settings.passwordNoticeInterval); } if (passwordInt < 1) { cb.sendNotice('Password Game Warning - Chat Notice Interval setting is too short, must be at least 1 minute. Using default value of 2.6 minutes.', cb.room_slug, appWarningColor, '', 'bold'); passwordInt = 2.6; } passwordInt *= 60000; passwordInt = parseInt(passwordInt); passwordNoticeTimer(); } function passwordSetNoticeTimeout() { cb.setTimeout(passwordNoticeTimer, passwordInt); } function passwordNoticeTimer() { if (passwordToggle == 1) { passwordShowNotice(''); passwordSetNoticeTimeout(); } } function passwordShowNotice(sendto) { var msg = 'The "Password" Game is active and set to ' + cb.settings.passwordMode + '. '; if (passwordMode == 'M1') { if (passwordPrice > 0) { msg += '\nTip ' + passwordPrice + ' tokens to play to next game/round.'; } else { msg += '\nNo tips required, guess the Password word/phrase to win the current performer/drawer a point'; } msg += '\nFirst performer/drawer to the goal score of ' + cb.settings.passwordBABGoal + ' points wins the prize: ' + passwordPrize + '.'; } else if (passwordMode == 'M2') { msg += '\nTip ' + passwordPrice + ' tokens to play and try to guess the Password word/phrase before anyone else in the room to win!'; msg += '\nThe single game prize is: ' + passwordPrize + '.'; } else if (passwordMode == 'M3') { msg += '\nTip ' + passwordPrice + ' tokens to play and try to guess the Password word/phrase before anyone else in the room to score points!'; msg += '\nFirst viewer to the score of ' + cb.settings.passwordVAR2Goal + ' points wins the grand prize.'; msg += '\nThe grand prize for this game is: ' + passwordPrize + '.'; } msg += '\nUse the command "/pwi" to see more info on the game modes, game format, commands and possible prizes.'; cb.sendNotice(msg, sendto, passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } function passwordInfo(sendto,usertype) { var msg = 'The "Password" Game is active and set to ' + cb.settings.passwordMode + '. '; if (passwordMode == 'M1') { if (passwordPrice > 0) { msg += '\nYou can tip ' + passwordPrice + ' tokens to have the broadcaster play the next game/round.'; } else { msg += '\nNo tips are required, the broadcaster will start each round.'; } msg += '\nOnce started, guess the Password word/phrase to win the current performer a point'; msg += '\nFirst performer to the score of ' + cb.settings.passwordBABGoal + ' points wins the prize: ' + passwordPrize + '.'; } else if (passwordMode == 'M2') { msg += '\nTip ' + passwordPrice + ' tokens to play and try to guess the Password word/phrase before anyone else in the room to win!'; msg += '\nThe single game prize is: ' + passwordPrize + '.'; } else if (passwordMode == 'M3') { msg += '\nTip ' + passwordPrice + ' tokens to play and try to guess the Password word/phrase before anyone else in the room to score points!'; msg += '\nFirst viewer to the score of ' + cb.settings.passwordVAR2Goal + ' points wins the grand prize.'; msg += '\nThe grand prize for this game is: ' + passwordPrize + '.'; } msg += '\nWhen tipping to start a game, if a game is already started, your name will go into the queue.'; msg += '\nAs each game is finished, the next player in the queue automatically starts the next game.'; msg += '\nOnce the broadcaster starts a game, all viewers in the room can attempt to guess the word/phrase.'; msg += '\nThe bot will monitor for the correct answer and announce the winner and stop the timer when a correct guess is made.'; msg += '\nNote that the answer must be spelled correctly, but case does not matter.'; msg += '\nUse the command "/pwh" to see the history of the Password games that have been played so far this session.'; msg += '\nUse the command "/pwq" to see the list of people who have tipped to play Password and are currently in line waiting to play.'; msg += '\nUse the command "/pwsb" to display the Password scoreboard for modes 1 and 3.'; if (usertype == 'BC') { msg += '\nFor Broadcasters (and moderators with authority):'; msg += '\nThe Password game can be turned on or off with the command "/password on" or "/password off". '; msg += '\nUse the command "/pwprice xx" to update the price for playing Password to the new value of xx.'; msg += '\nUse the command "/pwwin username" to manually assign a correct guess to someone who may have come close but misspelled the word. The game will behave as if they had guessed correctly'; msg += '\nUse the command "/pwfree" to initiate a free game to play the next turn or round, or to override the tip requirement and play a round for free as if someone had tipped'; msg += '\nUse the command "/pwplay" once a word is selected to show the word to the broadcaster and start the timer.'; msg += '\nUse the command "/pwword xxxxx" to add words and phrases to the word list used for the game, where "xxxxx" is the word or phrase to be added. You can add multiple words separated by a colon ":".'; msg += '\nUse the command "/pwrmv xxxxx" to remove words or phrases from the word list used for the game, where "xxxxx" is the word or phrase to be removed (must exactly match spelling and case).'; msg += '\nThis can be done in any play mode at any time, and will only add to the existing list.'; msg += '\nIf the word list source is configured as "Added During Game", the list will be empty to start and must be added before a game can be played.'; msg += '\nOtherwise, it will be populated from the default list or the broadcaster defined list on the launch page (and you can still add to the list in either case).'; msg += '\nNOTE: Try not to use words that are hard to spell or long phrases, the spelling must match exactly (but is not case sensitive)'; msg += '\nUse the command "/pwsave" to display the current remaining word list in a form that can be copied and pasted into the Broadcaster Managed word list upon restart of the bot to save your remaining words.'; msg += '\nUse the command "/pwskip" to skip a word/phrase if you do not know what it is. Skipping a word will reset the timer, and you must use /pwplay to start again after word selection.'; msg += '\nUse the command "/pwend" to end the current game if you decide not to finish it. Does not end the Password feature, just the current game/word being guessed, and will be ready for the next game. If a game has been tipped for in the queue it will be started.'; msg += '\nUse the command "/pwclearlist" to clear the wordlist. The wordlist is kept intact if the game is ended and restarted without restarting the bot.'; } cb.sendNotice(msg, sendto, passwordNoticeBgColor, passwordNoticeTextColor); } function passwordNewGame() { passwordActive = false; if (passwordNextPlayer.length > 0 && passwordActive == false) { passwordActive = true; nextPasswordPlayer = passwordNextPlayer[0]; passwordNextPlayer.splice(0, 1); cb.sendNotice(nextPasswordPlayer + ' is next in line and is about to Play Password. Ready to play...', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordPlay('tip',nextPasswordPlayer,true); } } function passwordPlay(mode,tippedby,passwordfromnext) { passwordTipper = tippedby; if (passwordActive == true && passwordfromnext != true) { passwordNextPlayer.push(tippedby); cb.sendNotice(tippedby + ' has tipped to play Password and been added to the player queue since a game is already being played. Their game will start once it reaches their place in line (current number of players in line : ' + passwordNextPlayer.length + '). \n You can use the command "/pwq" to see the queue of players waiting to play.', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } else { passwordActive = true; playmessage = ''; if (passwordMode == 'M1') { playmessage += 'Current Player: \n \u21D2 ' + passwordCurrentPlayer + ' \u21D0 \n'; } if (mode == 'tip') { if (passwordfromnext == false) { playmessage += tippedby + ' has tipped to play the Password Game! Selecting word or phrase...'; } else { playmessage += 'Selecting word or phrase...'; } } else if (mode == 'bc') { playmessage += 'The broadcaster is starting the next game of Password! Selecting word or phrase...'; } else if (mode == 'free') { playmessage += 'A free game of Password has been started by ' + tippedby + '! Selecting word or phrase...'; } cb.sendNotice(playmessage, '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); selectWord(); } } function selectWord() { passwordWaiting = true; passwordWordSelected = false; if (passwordList.length == 0) { cb.sendNotice('WORD LIST IS EMPTY! Waiting on word or phrase to be added using the command "/pwword xxxxx", where "xxxxx" is the word or phrase that should be added to the list and used next.', cb.room_slug, appNoticeColor); if (cb.settings.passwordModsKnowWord == 'Yes') { cb.sendNotice('WORD LIST IS EMPTY! Waiting on word or phrase to be added using the command "/pwword xxxxx", where "xxxxx" is the word or phrase that should be added to the list and used next.', '', appNoticeColor, '', '', 'red'); } } else { if (passwordList.length == 1 || cb.settings.passwordRandom == 'In Order') { passwordWord = passwordList[0].toLowerCase(); passwordList.splice(0,1); } else { numberOfEntries = passwordList.length; indexOfEntry = Math.floor(Math.random() * numberOfEntries); passwordWord = passwordList[indexOfEntry].toLowerCase(); passwordList.splice(indexOfEntry,1); } passwordWordSelected = true; if (cb.settings.freePlayStarts == 'Immediate Start') { passwordStartPlay(); } else { cb.sendNotice('Word selected, ready to start. \nYou can start the game with the /pwplay command.', cb.room_slug, appNoticeColor, '', ''); if (cb.settings.passwordModsKnowWord == 'Yes') { cb.sendNotice('Word selected, ready to start. \nModerators can start the game with the /pwplay command.', '', appNoticeColor, '', '', 'red'); } cb.sendNotice('Word is selected, Password will start on command.', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } } } function setPasswordWaitingTimer() { cb.setTimeout(passwordWaitingNotice, 60000); } function passwordWaitingNotice() { if (passwordWaiting == true) { cb.sendNotice('Word selected, ready to start. \nYou can start the game with the /pwplay command.', cb.room_slug, appNoticeColor, '', ''); if (cb.settings.passwordModsKnowWord == 'Yes') { cb.sendNotice('Word selected, ready to start. \nModerators can start the game with the /pwplay command.', '', appNoticeColor, '', '', 'red'); } } } function passwordStartPlay() { cb.sendNotice('The word/phrase for this game is: \n \u21D2 ' + passwordWord + ' \u21D0 \nA word can be skipped with the /pwskip command.', cb.room_slug, appNoticeColor, '', ''); if (cb.settings.passwordModsKnowWord == 'Yes') { cb.sendNotice('The word/phrase for this game is: \n \u21D2 ' + passwordWord + ' \u21D0 \nA word can be skipped with the /pwskip command.', '', appNoticeColor, '', '', 'red'); } passwordWaiting = false; passwordGuessing = true; cb.sendNotice('A timer is not used for the game of Password, the game will be ended manually by the broadcaster or moderators if the word is not guessed.', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); cb.sendNotice('Since no timer is used, you can use the command /pwend when you are ready to end the current game.', cb.room_slug, passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } function passwordCorrectAnswer(guessedby) { cb.sendNotice(guessedby + ' guessed the correct answer of "' + passwordWord + '"!', '', red, '', 'bold'); passwordGuessing = false; if (passwordMode == 'M1') { cb.sendNotice('Congratulations ' + guessedby + ' on the correct guess! ' + passwordCurrentPlayer + ' wins a point!', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordResults.push(guessedby + ' has guessed correctly, ' + passwordCurrentPlayer + ' wins a point!'); passwordScores[passwordCurrentPlayerIndex] ++; if (!cbjs.arrayContains(passwordBABScores.user,guessedby)) { passwordBABScores.user.push(guessedby); userIndex = passwordBABScores.user.indexOf(guessedby); passwordBABScores.score[userIndex] = 0; passwordBABScores.score[userIndex] += 1; } else { userIndex = passwordBABScores.user.indexOf(guessedby); passwordBABScores.score[userIndex] += 1; } } else if (passwordMode == 'M2') { if (guessedby == passwordTipper || passwordTipper == cb.room_slug) { cb.sendNotice('Congratulations ' + guessedby + ', you win! :smallpresent Prize is: ' + passwordPrize + ' :smallpresent ', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordResults.push(guessedby + ' has guessed correctly and has won the prize of : ' + passwordPrize); } else { cb.sendNotice('Sorry ' + passwordTipper + ', ' + guessedby + ' guessed the correct answer first!', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordResults.push(passwordTipper + ' did not win, ' + guessedby + ' guessed the correct answer first'); } } else if (passwordMode == 'M3') { var winPoints = 0; if (guessedby == passwordTipper) { cb.sendNotice('Congratulations ' + guessedby + ' on the correct guess! You win 3 points for guessing correctly in the game you tipped for!', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordResults.push(guessedby + ' guessed correctly, and wins 3 points!'); winPoints = 3; } else { cb.sendNotice('Congratulations ' + guessedby + ' on the correct guess! You win 1 point!', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordResults.push(guessedby + ' guessed correctly, and wins 1 point!'); winPoints = 1; } if (!cbjs.arrayContains(passwordVAR2Scores.user,guessedby)) { passwordVAR2Scores.user.push(guessedby); userIndex = passwordVAR2Scores.user.indexOf(guessedby); passwordVAR2Scores.score[userIndex] = 0; passwordVAR2Scores.score[userIndex] += winPoints; } else { userIndex = passwordVAR2Scores.user.indexOf(guessedby); passwordVAR2Scores.score[userIndex] += winPoints; } } passwordGameComplete(guessedby,false); passwordNewGame(); } function passwordGameComplete(guessedby,fixscore) { if (passwordMode == 'M1') { if (!fixscore) { passwordGamesThisRound++; } highScore = 0; secondScore = 0; for (var i = 0; i < passwordPlayers.length; i++) { if (passwordScores[i] > highScore) { secondScore = highScore; highScore = passwordScores[i]; } else if (passwordScores[i] > secondScore) { secondScore = passwordScores[i]; } } if (highScore >= cb.settings.passwordBABGoal) { if (passwordGamesThisRound >= passwordNumberofPlayers || passwordGamesThisRound == 0 || (highScore - secondScore) > 1) { winnercount = 0; for (var i = 0; i < passwordPlayers.length; i++) { if (passwordScores[i] == highScore) { winnercount++; winningindex = i; } } if (winnercount > 1) { passwordNextRound(); cb.sendNotice('There is a tie, we\'ll play another round of Password until there is a winner! \n' + passwordCurrentPlayer + ' will play next. \nCurrent Broadcaster Score - ' + passwordBABScore() + '\nCurrent Viewer Score - ' + passwordMode1Score(), '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } else { cb.sendNotice('Final Broadcaster Score - ' + passwordBABScore() + '\nFinal Viewer Score ' + passwordMode1Score(), '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); cb.sendNotice(passwordPlayers[winningindex] + ' has won Password! :smallpresent The prize is ' + passwordPrize + '! :smallpresent ', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordResults.push(passwordPlayers[winningindex] + ' has won Password! The prize is ' + passwordPrize); passwordRestart(); cb.sendNotice('Password Game has been reset.', cb.room_slug, appNoticeColor); } } else if (!fixscore) { if (passwordGamesThisRound >= passwordNumberofPlayers) { passwordNextRound(); cb.sendNotice((passwordRound-1) + ' round' + ((passwordRound-1) == 1 ? '' : 's') + ' played. \n' + passwordCurrentPlayer + ' will play next. \nCurrent Score - ' + passwordBABScore(), '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } else { passwordCurrentPlayerIndex ++; passwordCurrentPlayer = passwordPlayers[passwordCurrentPlayerIndex]; cb.sendNotice(passwordCurrentPlayer + ' will perform the next word/phrase. \nCurrent Broadcaster Score - ' + passwordBABScore() + '\nCurrent Viewer Score - ' + passwordMode1Score(), '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } } } else if (!fixscore) { if (passwordGamesThisRound >= passwordNumberofPlayers) { passwordNextRound(); cb.sendNotice((passwordRound-1) + ' round' + ((passwordRound-1) == 1 ? '' : 's') + ' played. \n' + passwordCurrentPlayer + ' will play next. \nCurrent Broadcaster Score - ' + passwordBABScore() + '\nCurrent Viewer Score - ' + passwordMode1Score(), '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } else { passwordCurrentPlayerIndex ++; passwordCurrentPlayer = passwordPlayers[passwordCurrentPlayerIndex]; cb.sendNotice(passwordCurrentPlayer + ' will perform the next word/phrase. \nCurrent Broadcaster Score - ' + passwordBABScore() + '\nCurrent Viewer Score - ' + passwordMode1Score(), '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } } } else if (passwordMode == 'M2') { if (guessedby == 'none') { if (passwordTipper == cb.room_slug) { cb.sendNotice('The free play started by the broadcaster ended without a correct guess.', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordResults.push('Free Play game started by the broadcaster ended with no winner, time ran out.'); } else { cb.sendNotice('Sorry ' + passwordTipper + ', time ran out so you did not win a prize - Please play again!', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordResults.push('The Password game started by ' + passwordTipper + ' ended with no winner, time ran out.'); } } else { cb.sendNotice('The current Password game started by ' + passwordTipper + ' has been completed.', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } } else if (passwordMode == 'M3') { if (!fixscore) { passwordGamesGoalRace++; } highScore = 0; for (var i = 0; i < passwordVAR2Scores.user.length; i++) { if (passwordVAR2Scores.score[i] > highScore) { highScore = passwordVAR2Scores.score[i]; winningindex = i; } } if (highScore > 0 && highScore >= cb.settings.passwordVAR2Goal) { cb.sendNotice(passwordVAR2Scores.user[winningindex] + ' has won the Password Goal Race! :smallpresent The prize is ' + passwordPrize + '! :smallpresent ', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordResults.push(passwordVAR2Scores.user[winningindex] + ' has won Password! The prize is ' + passwordPrize); cb.sendNotice('Resetting the Password game and scores... Let\'s play again!', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordRestart(); cb.sendNotice('Password Game has been reset.', cb.room_slug, appNoticeColor); } else if (!fixscore) { cb.sendNotice(passwordGamesGoalRace + ' game' + (passwordGamesGoalRace == 1 ? '' : 's') + ' played in the goal race. \nCurrent Scoreboard - ' + passwordMode3Score(), '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordNextRound(); } } } function passwordRestart() { passwordActive = false; passwordWordSelected = false; passwordRound = 1; passwordGamesThisRound = 0; passwordCurrentPlayerIndex = 0; passwordCurrentPlayer = passwordPlayers[passwordCurrentPlayerIndex]; passwordGamesGoalRace = 0; if (passwordMode == 'M1') { passwordLoadBABPlayers(); } else if (passwordMode == 'M3') { passwordVAR2Scores.user = []; passwordVAR2Scores.score = [0]; } passwordResults.push('Password game has been restarted.'); } function sortMode3Scores() { var swapped, temp1, temp2; do { swapped = false; for (var i = 0; i < passwordVAR2Scores.user.length ; i++) { if (passwordVAR2Scores.score[i] < passwordVAR2Scores.score[i + 1]) { temp1 = passwordVAR2Scores.score[i]; temp2 = passwordVAR2Scores.user[i]; passwordVAR2Scores.score[i] = passwordVAR2Scores.score[i + 1]; passwordVAR2Scores.score[i + 1] = temp1; passwordVAR2Scores.user[i] = passwordVAR2Scores.user[i + 1]; passwordVAR2Scores.user[i + 1] = temp2; swapped = true; } } } while (swapped); } function sortMode1Scores() { var swapped, temp1, temp2; do { swapped = false; for (var i = 0; i < passwordBABScores.user.length ; i++) { if (passwordBABScores.score[i] < passwordBABScores.score[i + 1]) { temp1 = passwordBABScores.score[i]; temp2 = passwordBABScores.user[i]; passwordBABScores.score[i] = passwordBABScores.score[i + 1]; passwordBABScores.score[i + 1] = temp1; passwordBABScores.user[i] = passwordBABScores.user[i + 1]; passwordBABScores.user[i + 1] = temp2; swapped = true; } } } while (swapped); } function passwordBABScore() { passwordScoreList = '\n'; for (var i = 0; i < passwordPlayers.length; i++) { passwordScoreList += (i > 0 ? ' / ' : '') + passwordPlayers[i] + ': ' + passwordScores[i]; } return passwordScoreList; } function passwordMode3Score() { if (passwordVAR2Scores.user.length > 0) { sortMode3Scores(); passwordScoreboard = ''; for (var i = 0; i < passwordVAR2Scores.user.length; i++) { passwordScoreboard += '\n' + (i+1) + '. ' + passwordVAR2Scores.user[i] + ' (' + passwordVAR2Scores.score[i] + ')'; } } else { passwordScoreboard = '\nNo Scores Yet'; } return passwordScoreboard; } function passwordMode1Score() { if (passwordBABScores.user.length > 0) { sortMode1Scores(); passwordScoreboard = ''; for (var i = 0; i < passwordBABScores.user.length; i++) { passwordScoreboard += '\n' + (i+1) + '. ' + passwordBABScores.user[i] + ' (' + passwordBABScores.score[i] + ')'; } } else { passwordScoreboard = '\nNo Scores Yet'; } return passwordScoreboard; } function passwordNextRound() { passwordRound++; passwordCurrentPlayerIndex = 0; passwordCurrentPlayer = passwordPlayers[passwordCurrentPlayerIndex]; passwordGamesThisRound = 0; } function passwordEndGame(endedby) { passwordGuessing = false; passwordWaiting = false; passwordActive = false; passwordStopTimer(endedby); if (passwordMode == 'M1') { cb.sendNotice('The current Password game started by ' + passwordTipper + ' has been ended by ' + endedby + ', but the overall point race is still active.', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordResults.push('The Password game was ended by ' + endedby); passwordGameComplete('none',false); passwordNewGame(); } else if (passwordMode == 'M2') { cb.sendNotice('The current Password game started by ' + passwordTipper + ' has been ended by ' + endedby, '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordResults.push('The current Password game started by ' + passwordTipper + ' was ended by ' + endedby); passwordNewGame(); } else if (passwordMode == 'M3') { cb.sendNotice('The current Password game started by ' + passwordTipper + ' has been ended by ' + endedby, ', but the overall point race is still active.', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordResults.push('The current Password game started by ' + passwordTipper + ' was ended by ' + endedby); passwordNewGame(); } } function passwordPlayerQueue(sendto) { if (passwordNextPlayer.length === 0) { cb.sendNotice('No players waiting.', sendto, passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } else { var msg = 'Players waiting to play Password:'; for (var i = 0; i < passwordNextPlayer.length; i++) { msg += '\n' + (i+1) + '. ' + passwordNextPlayer[i]; } cb.sendNotice(msg, sendto, passwordNoticeBgColor, passwordNoticeTextColor); } } function passwordShowResults(sendto,showall) { if (showall == 'all') { var msg = '\u22A1 \u22A1 \u22A1 \u22A1 Password Results \u22A1 \u22A1 \u22A1 \u22A1'; } else { var msg = '\u22A1 \u22A1 \u22A1 \u22A1 Last 20 Password Results \u22A1 \u22A1 \u22A1 \u22A1'; } if (passwordResults.length === 0) { cb.sendNotice('\nNo Selections have been made.', sendto, passwordNoticeBgColor, passwordNoticeTextColor); } else { if (showall == 'all') { for (var i = 0; i < passwordResults.length; i++) { msg += '\n' + (i+1) + '. ' + passwordResults[i]; } } else { var passwordRecentResults = passwordResults.slice(-20); for (var i = 0; i < passwordRecentResults.length; i++) { msg += '\n' + passwordRecentResults[i]; } } } cb.sendNotice(msg, sendto, passwordNoticeBgColor, passwordNoticeTextColor); } } // ******************************* Upon user entry of a Message ************************************** { cb.onMessage(function (msg) { var message = msg['m'].split(' '); var cmd = 0; var listRegExp = /[,\s]+/; var m = msg.m; var u = msg.user; var isMod = msg.is_mod; var isBC = (u === cb.room_slug); var BC = cb.room_slug; var isDarkBlue = false; var isLightBlue = false; var isLightPurple = false; var isDarkPurple = false; var isGray = false; var command = message[0] var commandVar1 = parseInt(message[1]); var commandVar2 = parseInt(message[2]); if (msg.tipped_tons_recently) { isDarkPurple = true; } else if (msg.tipped_alot_recently) { isLightPurple = true; } else if (msg.tipped_recently) { isDarkBlue = true; } else if (msg.has_tokens) { isLightBlue = true; } else if (!msg.has_tokens) { isGray = true; } if (cb.settings.silenceLevel == 'All Users Can Guess' || (cb.settings.silenceLevel == 'Gray Users Cannot Guess' && !isGray) || (cb.settings.silenceLevel == 'Gray & Light Blue Users Cannot Guess' && !isLightBlue && !isGray)) { if (message[0].charAt(0) != '/' && passwordToggle == 1 && passwordGuessing == true) { passwordguess = msg['m']; if (message[0].charAt(0) == '[' || message[0].charAt(0) == '|' || message[0].charAt(0) == ':') { for (var msgindex = 0; msgindex < 4; msgindex++) { if (message[0]) { if (message[0].charAt(0) == ':') { message.splice(0, 1); } } if (message[0]) { if (message[0].charAt(0) == '|') { message.splice(0, 1); } } if (message[0]) { if (message[0].charAt(0) == '[') { message.splice(0, 1); } } } passwordguess = cbjs.arrayJoin(message, ' '); } passwordguess = passwordguess.toLowerCase().trim(); passwordguess = passwordguess.replace(/[^a-z0-9]/g, ''); passwordwordtoguess = passwordWord.replace(/[^a-z0-9]/g, ''); if (passwordguess == passwordwordtoguess) { if (isMod && cb.settings.passwordModsKnowWord == 'Yes') { cb.sendNotice('Moderators are not allowed to guess when they know the word.', u, appNoticeColor); msg['X-Spam'] = true; } else if (isBC) { cb.sendNotice('Broadcasters are not allowed to guess.\n If you need to force a win for someone who guessed close enough, you can use the command "/pwwin username" before time runs out and it will give them credit for the answer.\n After time runs out, you can correct the score if necessary with the "/pwfixscore X username" command, where X is the new score for the given user.', u, appNoticeColor); msg['X-Spam'] = true; } else { passwordCorrectAnswer(u); } } } } if (message[0]) { if (message[0].charAt(0) == '/') { msg['X-Spam'] = true; var ntc = null; for (var i = 1; i < message.length; i++) { if (i == 1) ntc = message[i]; else ntc += " " + message[i]; } var cmdval = null; for (var i = 1; i < message.length; i++) { if (i == 1) cmdval = message[i]; else cmdval += " " + message[i]; } switch(command) { case '/pwi': { cmd = 1; if (passwordToggle == 1) { if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { passwordInfo(u,'BC'); } else { passwordInfo(u,'common'); } } else { cb.sendNotice('The Password Game is not enabled.', u, appNoticeColor); } break; } case '/pwlist': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { cb.sendNotice( 'Password Game Word List (' + passwordList.length + (passwordList.length == 1 ? ' entry' : ' entries') + '): \n' + (passwordList.length > 0 ? cbjs.arrayJoin(passwordList, ', ') : 'No entries.') + '\nEnd of List', u, appNoticeColor); } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } break; } case '/pwq': { cmd = 1; if (passwordToggle == 1) { passwordPlayerQueue(u); } else { cb.sendNotice('The Password Game is not enabled.', u, appNoticeColor); } break; } case '/pwh': { cmd = 1; showall = ''; if (message[1] == 'all' || message[1] == '' || message[1] == null) { showall = message[1]; } else { cb.sendNotice('Invalid parameter for the "/pwh" command, valid values are "all" and blanks (blanks defaults to last 20 plays).', u, appNoticeColor); } if (isMod) { passwordShowResults(cb.room_slug,showall); } passwordShowResults(u,showall); break; } case '/pwplay': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (passwordToggle) { if (passwordWaiting == true) { if (passwordMinsRemain >= 1 || passwordSecsRemain >= 1) { cb.sendNotice('A Password timer is already running, likely from the previous game, please stop the current timer using the command /chstoptimer if it is no longer needed.', u, appNoticeColor); } else { if (passwordWordSelected == true) { passwordStartPlay(); } else { cb.sendNotice('A word has not yet been selected for the current game, please add a word to the wordlist using the /pwword command.', u, appNoticeColor); } } } else { cb.sendNotice('The Password Game is not awaiting a start (word may not be selected, or already started and taking guesses).', u, appNoticeColor); } } else { cb.sendNotice('The Password Game is not enabled.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } break; } case '/pwword': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (isBC || (isMod && cb.settings.passwordModsKnowWord == 'Yes')) { if (cmdval != null) { var addlistarray = cmdval.split(':'); if (addlistarray.length > 1) { addnotice = ''; for (var i = 0; i < addlistarray.length; i++) { if (addlistarray[i] != '') { newPasswordWord = addlistarray[i].toLowerCase().trim(); if (!cbjs.arrayContains(passwordList, newPasswordWord)) { passwordList.push(newPasswordWord); addnotice += '\nAdded "' + newPasswordWord + '" to the Password Word List.' } else { addnotice += '\n' + newPasswordWord + ' is already on the Password Word List. Skipping.'; } } } addnotice += '\nAll words and phrases were added.'; cb.sendNotice(addnotice, u, appNoticeColor); } else { newPasswordWord = msg['m'].substring(8).trim(); if (cbjs.arrayContains(passwordList,newPasswordWord)) { cb.sendNotice(newPasswordWord + ' is already in the Password Word list.', u, appNoticeColor); } else { passwordList.push(newPasswordWord); cb.sendNotice('You have added "' + newPasswordWord + '" to the Password Word List.', u, appNoticeColor); } } if (passwordWaiting == true && passwordWordSelected == false) { selectWord(); } } else { cb.sendNotice('A parameter is required for the /pwword command and should be the word or phrase you would like to add. Multiple words and phrases can be added to the list if they are separated with a colon ":".', u, appNoticeColor); } } else { cb.sendNotice('A moderator can only add words if they are configured to know the word list.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } break; } case '/pwsave': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (isBC || (isMod && cb.settings.passwordModsKnowWord == 'Yes')) { if (passwordList.length > 0) { cb.sendNotice('Unused password words listed below. \nYou can paste this list into the Broadcaster Managed word list when next starting the bot so you don\'t reuse words from the current session: \n' + cbjs.arrayJoin(passwordList,':'), u, appNoticeColor); } else { cb.sendNotice('There are no words or phrases left in the current word list.', u, appNoticeColor); } } else { cb.sendNotice('A moderator can only use this command if they are configured to know the word list.', u, appNoticeColor); } } else { cb.sendNotice('Only moderators and broadcasters are able to use that command.', u, appNoticeColor); } break; } case '/pwrmv': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { wordtormv = msg['m'].substring(7).trim(); if (wordtormv != null && wordtormv != '' && wordtormv != ' ') { if (cbjs.arrayContains(passwordList,wordtormv)) { cbjs.arrayRemove(passwordList,wordtormv); cb.sendNotice('You have removed "' + wordtormv + '" from the Password Word List.', u, appNoticeColor); } else { cb.sendNotice('The word/phrase "' + wordtormv + '" is not in the Password Word List. Please check your spelling to ensure it is an exact match with what you are trying to remove, including upper and lower case. You can use the command /pwlist to view the list, and then copy and paste the word or phrase from the list.', u, appNoticeColor); } } else { cb.sendNotice('A parameter is required for the /pwrmv command and should be an exact match for the word or phrase you would like to remove.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } break; } case '/pwprice': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (passwordToggle == 1) { numprice = parseInt(message[1]); if(isNaN(numprice)) { cb.sendNotice('The value entered for the new Password price is not numeric, please try again.', u, appNoticeColor); } else if(numprice < 1 || numprice > 1000) { cb.sendNotice('The value entered for the new Password price is outside allowable values from 1 to 1000, please try again.', u, appNoticeColor); } else { passwordPrice = numprice; cb.sendNotice(u + ' has updated the Password price to ' + passwordPrice + ' tokens.', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } } else { cb.sendNotice('The Password Game is not enabled, you can use the command "/password on" to enable it.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } break; } case '/pwfree': { cmd = 1; if (passwordToggle == 1) { if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (passwordActive == false) { passwordPlay('free',u,false); } else { cb.sendNotice('A Password game has already started. Once the current game is finished, a new one can be started.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } } else { cb.sendNotice('The Password Game has not been enabled.', u, appNoticeColor); } break; } case '/pwend': { cmd = 1; if (passwordToggle == 1) { if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (passwordActive) { passwordEndGame(u); } else { cb.sendNotice('A Password game has not been started.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } } else { cb.sendNotice('The Password Game has not been enabled.', u, appNoticeColor); } break; } case '/pwwin': { cmd = 1; if (passwordToggle == 1) { if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (passwordGuessing) { if (message[1]) { passwordCorrectAnswer(message[1]); } else { cb.sendNotice('A user ID is required as a parameter for this command to identify the winner. Command should be used in the format "/pwwin username".', u, appNoticeColor); } } else { cb.sendNotice('A Password game has not been started.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } } else { cb.sendNotice('The Password Game has not been enabled.', u, appNoticeColor); } break; } case '/pwskip': { cmd = 1; if (passwordToggle == 1) { if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { if (passwordGuessing) { cb.sendNotice('Current word is being skipped, Password will start again on broadcaster\'s command', '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordStopTimer(u); selectWord(); } else { cb.sendNotice('The /pwskip command can only be used once the game starts after the word has been shown.', u, appNoticeColor); } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } } else { cb.sendNotice('The Password Game has not been enabled.', u, appNoticeColor); } break; } case '/pwclearlist': { cmd = 1; if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { passwordList = []; cb.sendNotice('The Password Word List has been cleared. You can add words to the list with the /pwword command.', u, appNoticeColor); } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } break; } case '/pwsb': case '/pwscoreboard': { cmd = 1; if (passwordToggle == 1) { if (isMod || isBC) { sendto = ''; } else { sendto = u; } if (passwordMode == 'M1') { cb.sendNotice((sendto == '' ? '(Sent to ALL)' : '(Sent to You)') + '\nPassword Current Broadcaster Score - ' + passwordBABScore() + '\nPassword Current Viewer Score - ' + passwordMode1Score(), sendto, passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } else if (passwordMode == 'M3') { cb.sendNotice((sendto == '' ? '(Sent to ALL)' : '(Sent to You)') + '\nPassword Current Score ' + + passwordMode3Score(), sendto, passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); } else { cb.sendNotice('The /pwsb (or /pwscoreboard) command is only valid for Password Modes 1 and 3.', u, appNoticeColor); } } else { cb.sendNotice('The Password Game has not been enabled.', u, appNoticeColor); } break; } case '/pwfixscore': { cmd = 1; if (passwordToggle == 1) { if (isBC || (isMod && cb.settings.allowModsAuthority == 'Yes')) { newscore = parseInt(message[1]); updateuser = message[2]; if (isNaN(newscore)) { cb.sendNotice('The value entered for the new user score is not numeric, please try again.\n The format of the command should be "/pwfixscore X username" to update username\'s score to a new value X.', u, appNoticeColor); } else if (!message[2]) { cb.sendNotice('A value was not entered for the username of the score to update, please try again.\n The format of the command should be "/pwfixscore X username" to update username\'s score to a new value X.', u, appNoticeColor); } else { if (passwordMode == 'M1') { if (cbjs.arrayContains(passwordPlayers,updateuser)) { index = passwordPlayers.indexOf(updateuser); passwordScores[index] = newscore; cb.sendNotice('You have updated ' + updateuser + '\'s score to ' + newscore + '.', u, appNoticeColor); if (u != BC) { cb.sendNotice(u + ' has updated ' + updateuser + '\'s score to ' + newscore + '.', BC, appNoticeColor); } cb.sendNotice( 'Password Game Current Broadcaster Score - ' + passwordBABScore() + '\nPassword Current Viewer Score - ' + passwordMode1Score(), '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordGameComplete(updateuser,true); passwordResults.push(u + ' has updated ' + updateuser + '\'s score to ' + newscore); } else { cb.sendNotice('The value entered for the username of the score to update does not match any of the current players, please try again.\n The format of the command should be "/pwfixscore X username" to update username\'s score to a new value X.\n The entry is case sensitive, current player list: ' + cbjs.arrayJoin(passwordPlayers, ', '), u, appNoticeColor); } } else if (passwordMode == 'M3') { if (cbjs.arrayContains(passwordVAR2Scores.user,updateuser)) { index = passwordVAR2Scores.user.indexOf(updateuser); passwordVAR2Scores.score[index] = newscore; cb.sendNotice('You have updated ' + updateuser + '\'s score to ' + newscore + '.', u, appNoticeColor); if (u != BC) { cb.sendNotice(u + ' has updated ' + updateuser + '\'s score to ' + newscore + '.', BC, appNoticeColor); } } else { cb.sendNotice('The value entered for the username of the score to update does not match any of the current players, an entry is being added for ' + updateuser, u, appNoticeColor); if (u != BC) { cb.sendNotice(u + ' has added ' + updateuser + ' to the scoreboard with a score of ' + newscore + '.', BC, appNoticeColor); } passwordVAR2Scores.user.push(updateuser); userIndex = passwordVAR2Scores.user.indexOf(updateuser); passwordVAR2Scores.score[userIndex] = newscore; } cb.sendNotice( 'Password Game Current Score - ' + passwordMode3Score(), '', passwordNoticeBgColor, passwordNoticeTextColor, 'bold'); passwordGameComplete(updateuser,true); passwordResults.push(u + ' has updated ' + updateuser + '\'s score to ' + newscore); } else { cb.sendNotice('The /pwfixscore command is only valid for Password Modes 1 and 3.', u, appNoticeColor); } } } else { cb.sendNotice('Only broadcasters and moderators with sufficient authority are able to use that command.', u, appNoticeColor); } } else { cb.sendNotice('The Password Game has not been enabled.', u, appNoticeColor); } break; } } } } return msg; }); } // *********************************** Actions on user entering ************************************** { cb.onEnter(function(user) { // Variables var onEnterUser = user.user; var onEnterIsMod = user.is_mod; // **** Password Message if(passwordToggle == 1) { passwordShowNotice(onEnterUser); } }); } // *********************************** Actions upon leaving ************************************** { cb.onLeave(function(user) { var onLeaveUser = user.user; }); } // *********************************** Actions upon tipping ************************************** { cb.onTip(function (tip) { var tipAmount = Number.parseInt(tip.amount, 10); var onTipUser = tip.from_user var tipForGame = false; var onTipIsMod = tip.from_user_is_mod; var isAnon = tip.is_anon_tip; if (isAnon) { onTipUser = 'Anonymous'; } if (passwordToggle == 1) { if (tipAmount == passwordPrice) { passwordPlay('tip',onTipUser,false); tipForGame = true; } } }); } // *********************************** Initialize ************************************** { if (initialize == 0) { cb.sendNotice('Dorothy\'s Password and Pictionary Bot v1.1'); cb.sendNotice('** Version 1.1 was released on 3/27/2020.', cb.room_slug, appNoticeColor); // *** Init Features using toggle functions if (cb.settings.passwordMode == 'Mode 1 - Broadcaster against Broadcaster') { passwordMode = 'M1'; passwordPrice = cb.settings.passwordBABPrice; } else if (cb.settings.passwordMode == 'Mode 2 - Viewer against Room (One Game)') { passwordMode = 'M2'; passwordPrice = cb.settings.passwordVARPrice; } else if (cb.settings.passwordMode == 'Mode 3 - Viewer against Room (Goal Race)') { passwordMode = 'M3'; passwordPrice = cb.settings.passwordVAR2Price; } passwordSetToggle('on',cb.room_slug); initialize = 1; } }
© Copyright Chaturbate 2011- 2026. All Rights Reserved.