Bots Home
|
Create an App
Donate
Author:
erik91383
Description
Source Code
Launch Bot
Current Users
Created by:
Erik91383
var items = [], itemGoals = [], goals = [], madeGoal = [] var heart = '\u2665', diamond = '\u2666', star = '\u2605', smiley = '\u263A', clover = '\u2618' // ♥ ♦ ★ ☺ ☘ var space = '\u2007' var bcp = { aqua: "#00FFFF", black: "#000000", blue: "#0000FF", fuchsia: "#FF00FF", gray: "#808080", grey: "#808080", green: "#008000", lime: "#00FF00", maroon: "#800000", navy: "#000080", olive: "#808000", orange: "#FFA500", purple: "#800080", red: "#FF0000", silver: "#C0C0C0", teal: "#008080", white: "#FFFFFF", yellow: "#FFFF00" }; cb.settings_choices = [ {name: 'item1', type: 'str', minLength: 1, maxLength: 255, label: "Item 1"}, {name: 'item1Goal', type: 'int', minValue: 1, label: "Goal Amount. This won't be shown (2000 tokens = $100)"}, {name: 'donations1', type: 'int', required: false, label: "Donatations made for this item from previous shows?"}, {name: 'item2', type: 'str', required: false, minLength: 1, maxLength: 255, label: "Item 2"}, {name: 'item2Goal', type: 'int', required: false, label: "Goal Amount. This won't be shown (2000 tokens = $100)"}, {name: 'donations2', type: 'int', required: false, label: "Donatations made for this item from previous shows?"}, {name: 'item3', type: 'str', required: false, minLength: 1, maxLength: 255, label: "Item 3"}, {name: 'item3Goal', type: 'int', required: false, label: "Goal Amount. This won't be shown (2000 tokens = $100)"}, {name: 'donations3', type: 'int', required: false, label: "Donatations made for this item from previous shows?"}, {name: 'item4', type: 'str', required: false, minLength: 1, maxLength: 255, label: "Item 4"}, {name: 'item4Goal', type: 'int', required: false, label: "Goal Amount. This won't be shown (2000 tokens = $100)"}, {name: 'donations4', type: 'int', required: false, label: "Donatations made for this item from previous shows?"}, {name: 'item5', type: 'str', required: false, minLength: 1, maxLength: 255, label: "Item 5"}, {name: 'item5Goal', type: 'int', required: false, label: "Goal Amount. This won't be shown (2000 tokens = $100)"}, {name: 'donations5', type: 'int', required: false, label: "Donatations made for this item from previous shows?"}, {name: 'time', type: 'int', minValue: 1, maxValue: 30, label: 'Frequency of wish list notification (in minutes)?', defaultValue: 10}, {name: 'divider', type: 'choice', label: 'Divider for wish list items', choice1: 'Heart', choice2: 'Diamond', choice3: 'Star', choice4: 'Smiley', choice5: 'Clover', defaultValue: 'Heart'}, {name: 'gif', type: 'str', minLength: 1, maxLength: 255, label: 'Thank you gif', defaultValue: ':kisses4u'}, {name: 'thanks', type: 'choice', label: 'Show when goal is met?', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, {name: 'celebrate', type: 'str', minLength: 1, maxLength: 255, label: 'Celebration Gif for completed goal', defaultValue: ':congratulationslove'}, {name: 'enter', type: 'choice', label: 'Show donation list information on entry?', choice1: 'Yes', choice2: 'No', defaultValue: 'No'}, ]; cb.onTip(function(tip){ var grossTip = parseInt(tip['amount']) if (tip['message'].match(/donate/i) != null ){ if (tip['message'].match(/all/gi) != null ){ donateAll(tip['from_user'],grossTip) } else if(tip['message'].match(/random/gi) != null ){ donateRandom(tip['from_user'],grossTip) } else if (tip['message'].match(RegExp(cb.settings.item1,'gi')) != null ){ if(goals[0] < itemGoals[0]){ donations(0,tip['from_user'],grossTip) } } else if (tip['message'].match(RegExp(cb.settings.item2,'gi')) != null ){ if(goals[1] < itemGoals[1]){ donations(1,tip['from_user'],grossTip) } } else if (tip['message'].match(RegExp(cb.settings.item3,'gi')) != null ){ if(goals[2] < itemGoals[2]){ donations(2,tip['from_user'],grossTip) } } else if (tip['message'].match(RegExp(cb.settings.item4,'gi')) != null ){ if(goals[3] < itemGoals[3]){ donations(3,tip['from_user'],grossTip) } } else if (tip['message'].match(RegExp(cb.settings.item5,'gi')) != null ){ if(goals[4] < itemGoals[4]){ donations(4,tip['from_user'],grossTip) } } } }); cb.onMessage(function(msg){ var message = "" if ( msg['m'] == '/goals'){ msg['X-Spam'] = true if (msg['user'] == cb.room_slug || msg['is_mod']){ for(var i = 0; i<items.length; i++){ message = message + items[i] + " has " + (goals[i]) + " tokens donated.\n" } cb.chatNotice("The status of each goal is:\n" + message,msg['user'],"",bcp.navy,"bold") } } if(msg['m'] == '/progress'){ for(var i = 0; i<items.length; i++){ if(goals[i]>=itemGoals[i]){ message = message + "My wish for a " + items[i] + " has already come true!\n" } else{ message = message + "My wish for a " + items[i] + " is " + (itemGoals[i] - goals[i]) + " tokens from my goal.\n" } } cb.chatNotice("\n" + message,msg['user'],"",bcp.blue,"bold") msg['X-Spam'] = true } if(msg['m'] == '/donate'){ msg['X-Spam'] = true if(cb.settings.divider == 'Heart'){ donate(heart, msg['user']) } else if(cb.settings.divider == 'Diamond'){ donate(diamond, msg['user']) } else if(cb.settings.divider == 'Star'){ donate(star, msg['user']) } else if(cb.settings.divider == 'Smiley'){ donate(smiley, msg['user']) } else if(cb.settings.divider == 'Clover'){ donate(clover, msg['user']) } } }); cb.onEnter(function(user){ var userName = user['user'] if (user['is_mod'] || user['user'] == cb.room_slug){ setTimeout(function(){cb.chatNotice("Type /goals for current donation totals. These numbers need to be remembered before ending the show and used when setting up the bot before the next show for accuracy!",userName,"",bcp.red,"bold");},1500) } if(cb.settings.enter == 'Yes'){ if(userName != cb.room_slug){ setTimeout(function(){notice(userName);},1500) } } }); function getList(){ if(cb.settings.item1Goal > 0 && cb.settings.donations1 < cb.settings.item1Goal){ items.push(cb.settings.item1) itemGoals.push(cb.settings.item1Goal) goals.push(cb.settings.donations1) madeGoal.push(0) } if(cb.settings.item2Goal > 0 && cb.settings.donations2 < cb.settings.item2Goal){ items.push(cb.settings.item2) itemGoals.push(cb.settings.item2Goal) goals.push(cb.settings.donations2) madeGoal.push(0) } if(cb.settings.item3Goal > 0 && cb.settings.donations3 < cb.settings.item3Goal){ items.push(cb.settings.item3) itemGoals.push(cb.settings.item3Goal) goals.push(cb.settings.donations3) madeGoal.push(0) } if(cb.settings.item4Goal > 0 && cb.settings.donations4 < cb.settings.item4Goal){ items.push(cb.settings.item4) itemGoals.push(cb.settings.item4Goal) goals.push(cb.settings.donations4) madeGoal.push(0) } if(cb.settings.item5Goal > 0 && cb.settings.donations5 < cb.settings.item5Goal){ items.push(cb.settings.item5) itemGoals.push(cb.settings.item5Goal) goals.push(cb.settings.donations5) madeGoal.push(0) } }; function donations(index,user,tip){ goals[index] = tip + goals[index] cb.chatNotice("Thank you so much for donating to my " + items[index] +"\n" + cb.settings.gif,user,"","","bold") if(goals[index] >= itemGoals[index] && cb.settings.thanks == 'Yes' && madeGoal[index] == 0){ goalMade(index) } }; function donateAll(user,tip){ cb.chatNotice("Thank you so much for donating to all of my wishes!\n"+cb.settings.gif,user,"","","bold") var x = 0, a = 0, b = 0 for (var i = 0; i<goals.length; i++){ if(goals[i]<itemGoals[i]){ x++ } } var whole = Math.floor(tip/x) for (var i = 0; i<goals.length; i++){ if(goals[i]<itemGoals[i]){ goals[i] = goals[i]+whole var temp = itemGoals[i] - goals[i] if(a<temp){b=i,a=temp} if(goals[i] >= itemGoals[i] && cb.settings.thanks == 'Yes' && madeGoal[i] == 0){ goalMade(i) } } } goals[b] = goals[b]+(tip%x) if(goals[b] >= itemGoals[b] && cb.settings.thanks == 'Yes' && madeGoal[b] == 0){ goalMade(b) } }; function donateRandom(user,tip){ var x = [] var a = 0, b = 0 for (var i = 0; i<goals.length; i++){ if(goals[i]<itemGoals[i]){ x.push(i) } } var ran = Math.floor(Math.random()*x.length) var w = x[ran] cb.chatNotice("Thank you so much for donating to my " + items[w] +"\n" + cb.settings.gif,user,"","","bold") goals[w] = goals[w] + tip if(goals[w] > itemGoals[w]){ goalMade(w) var over = goals[w] - itemGoals[w] goals[w] = goals[w] - over for (var i = 0; i<x.length; i++){ if(goals[x[i]]<itemGoals[x[i]]){ var temp = itemGoals[x[i]] - goals[x[i]] if(a<temp){b=x[i],a=temp} } } goals[b] = goals[b]+over cb.chatNotice("Thank you so much for donating to my " + items[b] +"\n" + cb.settings.gif,user,"","","bold") if(goals[b] >= itemGoals[b] && cb.settings.thanks == 'Yes' && madeGoal[b] == 0){ goalMade(b) } } }; function goalMade(i){ cb.chatNotice("The donation goal for my " + items[i] + " has been met!!!\nThank you all for making my wish come true!!\n" + cb.settings.celebrate,"","",bcp.green,"bold") madeGoal[i] = 1 } function donate(div, user){ var spc = space + space var str = space + div + spc + div + space cb.chatNotice("Thank you for your interest in my wish list, "+ user +"!\n" + "These are the items that I have I am wishing for:\n" + space + div + space + items.join(str) + space + div + space + "\n" + "If you would like to donate, send a tip with the number of tokens and\n" + "in the tipnote type 'donate x' where 'x' is one of my wishes.\n" + "For example: 'donate " + items[Math.floor(Math.random()*items.length)] + "' - then add any message.\n" + "If you feel to donate to all of my wishes type 'donate all' in the tipnote\n" + "and your donation will be divided equally to all of my remaining wishes.\n"+ "Or, if you can't decide, simply write 'donate random' and your donation will\n"+ "be put to a random item in my wish list. Make sure to spell my wish just\n"+ "as you see in the list or it won't work!",user,"","","bold") }; function notify(){ notice() setTimeout(notify,cb.settings.time*60000) }; function notice(user){ cb.chatNotice("I have a wish list with " + items.length + " item(s). If you would like see my list or how to donate\ntype '/donate' or to see my wish list progress type '/progress' in to the chat.",user,"",bcp.purple,"bold") }; function init(){ getList() setTimeout(notify,cb.settings.time*60000) }; init()
© Copyright Chaturbate 2011- 2024. All Rights Reserved.