Bots Home
|
Create an App
test-notifications
Author:
bellows1
Description
Source Code
Launch Bot
Current Users
Created by:
Bellows1
var optionA = new Set([]); var optionB = new Set([]); var optionAVal = "OptionA" var optionBVal = "OptionB" var openVoting = false var goal = 1000 var tipped = 0 var goalReached = () => tipped >= goal var removeUser = (user) => { if(optionA.has(user)) { optionA.delete(user) } if(optionB.has(user)) { optionB.delete(user) } } cb.onMessage((msg) => { if(msg['user'] == cb.room_slug && msg['m'].startsWith("/svo")) { msg['X-Spam'] = true if(msg['m'].startsWith("/svoA ")) { optionAVal = msg['m'].substring(5).trim() } else if(msg['m'].startsWith("/svoB ")) { optionBVal = msg['m'].substring(5).trim() } else if(msg['m'].startsWith("/svoGoal ")) { goal = parseInt(msg['m'].substring(9).trim()) } else if(msg['m'].startsWith("/svoTipped ")) { tipped = parseInt(msg['m'].substring(11).trim()) } else if(msg['m'].startsWith("/svoResetVote ")) { optionA.clear() optionB.clear() } else if(msg['m'].startsWith("/svoOpen")) { openVoting = true } else if(msg['m'].startsWith("/svoClose")) { openVoting = false } } if(msg['m'].startsWith("/vote")) { msg['X-Spam'] = true cb.log(goalReached()) if(goalReached() && !openVoting) { var message = `Sorry, Voting has closed for this round. Wait untl next round or for voting to be reopened` cb.sendNotice(message, msg['user'], '', '#FF0000') } else { removeUser(msg['user']) if(msg['m'] === "/vote A") { optionA.add(msg['user']) } else if(msg['m'] === "/vote B") { optionB.add(msg['user']) } else { cb.sendNotice(`Hmm, that didn't work. Try "/vote A" or "/vote B"`, msg['user']) } } } cb.drawPanel() return msg }) cb.onLeave((user) => { removeUser(user['user']) cb.drawPanel() }) cb.onTip((tip) => { if(tipped === goal) { return tip } tipped += parseInt(tip['amount']) if(tipped >= goal) { tipped = goal } if(tipped === goal) { cb.sendNotice(`Goal Reached!`) } else { cb.sendNotice(`Next Goal: ${tipped}/${goal}`) } cb.drawPanel() }) cb.onDrawPanel(function(user) { return { 'template': '3_rows_12_22_31', 'row1_label': optionAVal, 'row1_value': optionA.size, 'row2_label': optionBVal, 'row2_value': optionB.size, 'row3_value': `Next Goal: ${tipped}/${goal}` } })
© Copyright Chaturbate 2011- 2024. All Rights Reserved.