Bots Home
|
Create an App
test - f4
Author:
testdan699
Description
Source Code
Launch Bot
Current Users
Created by:
Testdan699
/*************************************************************************************** * AKWBot Alpha0.1 * * Developed By DoobieDan69 * * <-----------Modules------------> * * CoreSystems A0.3 * * QuickPickLotto A0.2 * * AntiSpam A0.1 * * SlotMachine ComingSoon * * ShellGame ComingSoon * * BlackJackGame ComingSoon * * SideQuests ComingSoon * **************************************************************************************/ //TODO //Add user list to global data on start cb.settings_choices = [ {name: 'LottoTicketPrice', type: 'int', minValue: 1, maxValue: 299, defaultValue: 2}, {name: 'TrustedMods', type: 'str',minLength: 1, maxLength: 255, defaultValue: "DobbieDan69"} ]; /***********GLobal Data***********/ let GlobalData = { USERDATA: new Array(300), TotalTips: 0 } /***********Type Defs***********/ let UserData = class { constructor() { this.total_tiped = 0; } } let AntiSpam = { IsSpam: function (msgStr) { let spamList = new RegExp("cum\\S*\.lin|prv\\S*\.sho|ums\\S*\.m") return msgStr.search(spamList) > -1; }, HandleMessage: function (msg, isOwner, isMod) { if(this.IsSpam(msg)) { msg['X-Spam'] = true; } return msg }, } /***********Modules Defs**************/ let QuickPickLotto = { LottoPrize: "Flash (You Chose)", LottoTickets: new Array(300), LottoMax: 5, TicketCost: 2, TicketsSold: 0, AnyOver:true , IsRunning: false, OddsList: { 5: 60, 6: 120, 7: 210, 8: 336, 9: 504, 10: 720, 11: 990, 12: 1320, 13: 1716, 14: 2184, 15: 2730, 16: 3360 }, NewGame: function () { this.LottoTickets = new Array(100) this.IsRunning = true; this.TicketsSold = 0; cb.sendNotice("New lotto game started with 1 in " + this.OddsList[this.LottoMax] + " odds", cb['room_slug'], '', '', ''); cb.sendNotice("The QuickPick Lotto Game Has Started. Tip "+this.TicketCost+" or more to get a ticket \n" , "", '#FEFBAF', '', '100'); }, GenNewTicket: function (user) { if (this.IsRunning) { var lottoTicketStr = ""; do { let nums = GetThreeNumbers(this.LottoMax); lottoTicketStr = nums[0] + "-" + nums[1] + "-" + nums[2]; } while (this.LottoTickets.hasOwnProperty(lottoTicketStr)); this.LottoTickets[lottoTicketStr] = user; cb.sendNotice( lottoTicketStr, user, '#FEFBAF', '', '100'); TicketsSold++; } }, MyTickets: function (user) { if (this.IsRunning) { for (var key in this.LottoTickets) { if (this.LottoTickets[key] == user) { cb.sendNotice( key, user, '#FEFBAF', '', '100'); } } } }, SetMax: function (number) { let num = parseInt(number); cb.chatNotice(num) if (num <= 16 && num >= 5) { this.LottoMax = num; } }, SetPrize: function (prize) { this.LottoPrize = prize; cb.sendNotice(this,this.LottoPrize, '#FEFBAF', '', '100'); }, StartTheDraw: function () { var nums = GetThreeNumbers(this.LottoMax); var lottoTicketStr = nums[0] + "-" + nums[1] + "-" + nums[2]; cb.chatNotice("Winning numbers are" + lottoTicketStr); if (this.LottoTickets.hasOwnProperty(lottoTicketStr)) { cb.sendNotice(this.LottoTickets[lottoTicketStr].User + " Has Won " + this.LottoPrize, "", "#d4af37", "#ffffff", "150", ""); } else { cb.sendNotice("Sorry there was no winner, Better Luck Next Time :kisses4u", "", "#ff8484", "#ffffff", "150", ""); } }, HandleCMDS: function (cmd, args,user, isOwner, isMod) { if (isOwner) { if (cmd == "/startLotto" || cmd == "/sl") { this.NewGame(); } if (cmd == "/GiveTicket ") { if(GlobalData.USERDATA[args.trim()] != undefined) { this.GenNewTicket(args.trim()); } } if (cmd == "/setLMax") { this.SetMax(args.trim()); } if (cmd == "/SetLPrize") { this.SetMax(args.trim()); } } if (isOwner || is_mod) { if (cmd == "/RunLotto") { this.StartTheDraw(args.trim()); } } if (cmd == "/MyTickets") { this.MyTickets(user); } }, HandleTip: function (intAmout, user, tip) { if (this.IsRunning) { if(this.TicketsSold < this.OddsList[this.LottoMax] ) { if ((this.AnyOver && intAmout >= this.TicketCost) || (!this.AnyOver && intAmout == this.TicketCost)) { this.GenNewTicket(user) } } } }, Notifications: function (){ cb.sendNotice("The Quick Pick lotto Game is running, any tip over +"+this.TicketCost+" Will get one ticket.", "", "#ff8484", "#ffffff", "150", ""); cb.sendNotice("The Lotto Draw tip +"+this.TicketCost+" or more to get one ticket.", "", "#ff8484", "#ffffff", "150", ""); cb.setTimeout(function (){Core.Notifications}, 15000); }, Init: function () { Core.CMDListeners.push(this); Core.TipListeners.push(this); cb.setTimeout(function (){Core.Notifications}, 15000); } } let template = { HandleCMDS: function (cmd, args, isOwner, isMod, IsFanClub) { }, //must return msg HandleMessage: function (msg, isOwner, isMod) { return msg }, HandleTip: function (intAmout, user, tip) { }, HandleEnter: function (user, data) { }, HandleFanclubJoin: function (user, data) { }, Init: function () { }, } let Core = { CMDListeners: new Array(33), TipListeners: new Array(33), MSGListeners: new Array(33), EnterListeners: new Array(33), HandleTip: function (tip) { var intTip = parseInt(tip['amount']); GlobalData.USERDATA[tip['from_user']].total_tiped += intTip; GlobalData.TotalTips += intTip; if(this.TipListeners.length >0) { this.TipListeners.forEach(function (lissener) { lissener.HandleTip(intTip, tip['from_user'], tip); }) } }, HandleEnter: function (user) { GlobalData.USERDATA[user['user']] = new UserData(); if(this.EnterListeners.length >0) { this.EnterListeners.forEach(function (lisssener) { lisssener.HandleEnter(user['user'], user); }) } }, HandleMessage: function (message) { var msgTxt = message['m']; var isOwner = message['user'] == cb['room_slug']; if (msgTxt.indexOf("/") != -1) { var cmd = msgTxt.split(" ", 1)[0]; var args = msgTxt.slice(cmd.length + 1); this.CMDListeners.forEach(function (lisssener) { lisssener.HandleCMDS(cmd, args,message['user'] , isOwner, message['is_mod']); }); message['X-Spam'] = true; return message; } this.CMDListeners.forEach(function (lisssener) { message = lisssener.HandleCMDS(message, isOwner, message['is_mod']); }); return message; }, RunCoreNotifications: function () { cb.setTimeout(this.RunCoreNotifications, 15000) }, Init: function () { QuickPickLotto.Init(); } } function GetThreeNumbers(Max) { var list = []; do { var numb = RandomRange(1, Max); if (list.lastIndexOf(numb) == -1) { list.push(numb); } } while (list.length < 3) return list; } function RandomRange(min, max) { return Math.floor(Math.random() * max) + min } cb.onEnter(function (user) { Core.HandleEnter(user); }); cb.onMessage(function (message) { Core.HandleMessage(message); });+ cb.onTip(function (tip) { Core.HandleTip(tip); }); function IsSpam(msgStr) { let spamList = new RegExp("cum\\S*\.lin|prv\\S*\.sho|ums\\S*\.m") return msgStr.search(spamList) > -1; } Core.Init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.