Bots Home
|
Create an App
War Nations
Author:
chaturlingamxxx
Description
Source Code
Launch Bot
Current Users
Created by:
Chaturlingamxxx
var Colors = { AliceBlue: "#F0F8FF", AntiqueWhite: "#FAEBD7", Aqua: "#00FFFF", Aquamarine: "#7FFFD4", Azure: "#F0FFFF", Beige: "#F5F5DC", Bisque: "#FFE4C4", Black: "#000000", BlanchedAlmond: "#FFEBCD", Blue: "#0000FF", BlueViolet: "#8A2BE2", Brown: "#A52A2A", BurlyWood: "#DEB887", CadetBlue: "#5F9EA0", Chartreuse: "#7FFF00", Chocolate: "#D2691E", Coral: "#FF7F50", CornflowerBlue: "#6495ED", Cornsilk: "#FFF8DC", Crimson: "#DC143C", Cyan: "#00FFFF", DarkBlue: "#00008B", DarkCyan: "#008B8B", DarkGoldenRod: "#B8860B", DarkGrey: "#A9A9A9", DarkGreen: "#006400", DarkKhaki: "#BDB76B", DarkMagenta: "#8B008B", DarkOliveGreen: "#556B2F", DarkOrange: "#FF8C00", DarkOrchid: "#9932CC", DarkRed: "#8B0000", DarkSalmon: "#E9967A", DarkSeaGreen: "#8FBC8F", DarkSlateBlue: "#483D8B", DarkSlateGrey: "#2F4F4F", DarkTurquoise: "#00CED1", DarkViolet: "#9400D3", DeepPink: "#FF1493", DeepSkyBlue: "#00BFFF", DimGrey: "#696969", DodgerBlue: "#1E90FF", FireBrick: "#B22222", FloralWhite: "#FFFAF0", ForestGreen: "#228B22", Fuschia: "#FF00FF", Gainsboro: "#DCDCDC", GhostWhite: "#F8F8FF", Gold: "#FFD700", GoldenRod: "#DAA520", Grey: "#808080", Green: "#008000", GreenYellow: "#ADFF2F", HoneyDew: "#F0FFF0", HotPink: "#FF69B4", IndianRed: "#CD5C5C", Indigo: "#4B0082", Ivory: "#FFFFF0", Khaki: "#F0E68C", Lavender: "#E6E6FA", LavenderBlush: "#FFF0F5", LawnGreen: "#7CFC00", LemonChiffon: "#FFFACD", LightBlue: "#ADD8E6", LightCoral: "#F08080", LightCyan: "#E0FFFF", LightGoldenRodYellow: "#FAFAD2", LightGrey: "#D3D3D3", LightGreen: "#90EE90", LightPink: "#FFB6C1", LightSalmon: "#FFA07A", LightSeaGreen: "#20B2AA", LightSkyBlue: "#87CEFA", LightSlateGrey: "#778899", LightSteelBlue: "#B0C4DE", LightYellow: "#FFFFE0", Lime: "#00FF00", LimeGreen: "#32CD32", Linen: "#FAF0E6", Magenta: "#FF00FF", Maroon: "#800000", MediumAquaMarine: "#66CDAA", MediumBlue: "#0000CD", MediumOrchid: "#BA55D3", MediumPurple: "#9370DB", MediumSeaGreen: "#3CB371", MediumSlateBlue: "#7B68EE", MediumSpringGreen: "#00FA9A", MediumTurquoise: "#48D1CC", MediumVioletRed: "#C71585", MidnightBlue: "#191970", MintCream: "#F5FFFA", MistyRose: "#FFE4E1", Moccasin: "#FFE4B5", NavajoWhite: "#FFDEAD", Navy: "#000080", OldLace: "#FDF5E6", Olive: "#808000", OliveDrab: "#6B8E23", Orange: "#FFA500", OrangeRed: "#FF4500", Orchid: "#DA70D6", PaleGoldenRod: "#EEE8AA", PaleGreen: "#98FB98", PaleTurquoise: "#AFEEEE", PaleVioletRed: "#DB7093", PapayaWhip: "#FFEFD5", PeachPuff: "#FFDAB9", Peru: "#CD853F", Pink: "#FFC0CB", Plum: "#DDA0DD", PowderBlue: "#B0E0E6", Purple: "#800080", Red: "#FF0000", RosyBrown: "#BC8F8F", RoyalBlue: "#4169E1", SaddleBrown: "#8B4513", Salmon: "#FA8072", SandyBrown: "#F4A460", SeaGreen: "#2E8B57", SeaShell: "#FFF5EE", Sienna: "#A0522D", Silver: "#C0C0C0", SkyBlue: "#87CEEB", SlateBlue: "#6A5ACD", SlateGrey: "#708090", Snow: "#FFFAFA", SpringGreen: "#00FF7F", SteelBlue: "#4682B4", Tan: "#D2B48C", Teal: "#008080", Thistle: "#D8BFD8", Tomato: "#FF6347", Turquoise: "#40E0D0", Violet: "#EE82EE", Wheat: "#F5DEB3", White: "#FFFFFF", WhiteSmoke: "#F5F5F5", Yellow: "#FFFF00", YellowGreen: "#9ACD32" }; var Groups = { TokenHolders: 'cyan', Tippers: 'blue', Fans: 'green', Moderators: 'red', }; var Constants = { Developer: "chaturlingamxxx", Broadcaster: cb.room_slug }; var Gender = { Male: "m", Female: "f", Couple: "c", Trans: "t" } function GetTokenPlural( x ) { return x > 1 ? "Tokens" : "Token"; } function IsArray( arg ) { return Object.prototype.toString.call( arg ) === '[object Array]'; } function GetRandomIndex( items ) { return Math.floor( Math.random() * items.length ); } function MinutesToMilliseconds( min ) { return min * 60 * 100; } function ShuffleArray( arr ) { for ( var i = arr.length - 1; i > 0; i-- ) { var j = Math.floor( Math.random() * ( i + 1 ) ); var temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } return arr; } function ContentWithTitle(title, content) { var header = "====================\n" + " {0} \n" + "====================\n"; var footer = "===================="; return header.format(title) + content + footer; } String.prototype.format = function () { var formatted = this; for ( var i = 0; i < arguments.length; i++ ) { var regexp = new RegExp( '\\{' + i + '\\}', 'gi' ); formatted = formatted.replace( regexp, arguments[i] ); } return formatted; }; function Command( id, description, execute, canExecute ) { var self = this; this.Id = id; this.Description = description; this.Execute = execute; this.CanExecute = canExecute; } var Permissions = { All: function ( msg ) { return true; }, Broadcaster: function ( msg ) { return msg.user == cb.room_slug; }, Moderators: function ( msg ) { return msg.is_mod; }, BroadcasterOrModerator: function ( msg ) { return msg.user == cb.room_slug || msg.is_mod; }, UserWithTokens: function ( msg ) { return msg.has_tokens; }, Developer: function ( msg ) { return msg.user == "Master" || msg.user == "mastercheckup"; } }; function CommandManagerClass() { var self = this; this.Commands = {}; this.Register = function ( id, description, execute, canExecute ) { if ( arguments.length < 3 ) return false; if ( self.Commands[id] == undefined ) { if ( canExecute == undefined ) canExecute = Permissions.Broadcaster; self.Commands[id] = new Command( id, description, execute, canExecute ); return true; } return false; }; this.Parse = function ( msg ) { var message = msg.m; if ( message[0] == "/" ) { var commandId = message.substr( 0, message.indexOf( " " ) == -1 ? message.length : message.indexOf( " " ) ).trim(); var commandParams = message.substr( message.indexOf( " " ) == -1 ? message.length : message.indexOf( " " ), message.length - 1 ).trim(); if ( commandId in self.Commands ) { msg["X-spam"] = true; if ( self.Commands[commandId].CanExecute( msg ) ) { self.Commands[commandId].Execute( msg, commandParams ); return true; } else { return false; } } else { return false; } } else { return false; } }; this.GetCommandList = function ( msg) { var content = ""; for ( var i in self.Commands ) { if ( self.Commands[i].CanExecute( msg ) ) content += self.Commands[i].Id + " - " + self.Commands[i].Description + "\n"; } if ( content == "" ) { content = "No Commands have Been Registered" + "\n"; } return content; }; } var Commands = new CommandManagerClass(); function Application(name, version, description, developer, stage) { var self = this; this.Name = name; this.Description = description; this.Developer = developer; this.Version = version; this.Stage = stage || "Development"; self.About = function () { return "=========================\n" + "= " + self.Name + " - Version: " + self.Version + "\n" + "= " + self.Version + "\n" + "= Developed By: " + self.Developer + "\n" + "========================="; }; } var Notice = { Send: function ( content, foreground, background, recipient, group ) { if ( recipient != null && group != null ) cb.sendNotice( content, null, background, foreground, '', group ); if ( group == null || recipient != null ) cb.sendNotice( content, recipient, background, foreground, '', null ); }, Error: function ( str, recipient, group ) { this.Send( str, "#494949", "#E9E9E9", recipient, group ); }, Warning: function ( str, recipient, group ) { this.Send(str, "#C09853", "#FCF8E3", recipient, group); }, Success: function ( str, recipient, group ) { this.Send( str, "#468847", "#DFF0D8", recipient, group ); }, Information: function ( str, recipient, group ) { this.Send(str, "#468847", "#DFF0D8", recipient, group); } } // #region Enums var JoinMode = { Manual: "Manual Join", ExactTip: "Exact Tip", MinimumTip: "Minimum Tip" } var ClubAction = { Join: "Join", Leave: "Leave" } // #endregion // #region Club Class function Club( name, label, doLabel, color, doColor, doAnnounce, cost, joinMode, joinMessage, members, advMessage ) { var self = this; // #region Properties this.Name = name; this.Label = label; this.DoLabel = doLabel; this.Color = color; this.DoColor = doColor; this.Announce = doAnnounce; this.Cost = cost; this.JoinMode = joinMode; this.JoinMessage = joinMessage; this.Members = members; this.AdvMessage = advMessage; // #endregion // #region Methods this.IsMember = function ( username ) { return cbjs.arrayContains( self.Members, username ); }; this.CanJoin = function ( amount, username ) { if ( self.JoinMode == JoinMode.ExactTip && amount === self.Cost ) { return true; } if ( self.JoinMode == JoinMode.MinimumTip && amount >= self.Cost ) { return true; } return false; } this.Join = function ( user ) { if ( !self.IsMember( user ) ) { self.Members.push( user ); Notice.Send( "The user {0} has Joined the {1} Nation!".format( user, self.Name ), "", self.Color ); if ( self.JoinMessage != "" ) { Notice.Send( self.JoinMessage.format( user, self.Name ), "", self.Color, user ); } } } this.Leave = function ( user ) { if ( self.IsMember( user ) ) { cbjs.arrayRemove( self.Members, user ); Notice.Send( "The User {0} has Left the {1} Nation".format( user, self.Name ), "", self.Color ); } } // #endregion } // #endregion // #region Application Class function Clubber() { var self = this; // #region Settings this.ClubNumber = 3; this.Clubs = []; this.Advertisment = { Timing: 5, DoAdvertise: false }; this.BroadcasterOptions = { DoLabel: false, DoColor: false, Label: "", Color: "" }; this.ModeratorsOptions = { DoLabel: false, DoColor: false, Label: "", Color: "" }; this.FanclubOptions = { DoLabel: false, DoColor: false, Label: "", Color: "" }; // #endregion settings this.Minutes = -1; // #region Initialization Methods this.Initialize = function () { self.CreateCommands(); self.CreateSettings(); self.LoadSettings(); self.HandleEvents(); self.About(); }; this.CreateCommands = function () { Commands.Register( "/cclubs", "List the Aviable Clubs.", self.ListClub, Permissions.Broadcaster ); Commands.Register( "/cjoin", "Manually add a Member to a Club.", self.Join, Permissions.Broadcaster ); Commands.Register( "/cleave", "Manually remove a Member to a Club.", self.Leave, Permissions.Broadcaster ); Commands.Register( "/cmsg", "Send a notice to the member of a club.", self.SendMessage, Permissions.Broadcaster ); Commands.Register( "/cadv", "Switch On and Off ", self.SwitchAdvertisment, Permissions.All ); Commands.Register( "/cabout", "Display the About page for the App", self.About, Permissions.Broadcaster ); Commands.Register( "/chelp", "Display the Help page for the App", self.Help, Permissions.Broadcaster ); }; this.CreateSettings = function () { var settings = []; // #region Advertisment General Settings settings.push({ name: 'DoAdvertise', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "Show and Advertise for Nations Citizenship" }); settings.push({ name: 'AdvertismentTiming', type: 'int', minValue: 0, maxValue: 50, label: 'Advertisment Interval (Minutes)', required: false, defaultValue: 1 }); for (var i = 0; i < self.ClubNumber; i++) { settings.push({ name: 'ClubName{0}'.format(i), type: 'str', minLength: 1, maxLength: 255, label: 'Nation #{0} Name'.format(i + 1), required: false, defaultValue: "" }); } settings.push({ name: 'BroadcasterDoLabel', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "Show a Label on the Broadcaster " }); settings.push({ name: 'BroadcasterLabel', type: 'str', minLength: 1, maxLength: 255, label: 'Broadcaster Label Content', required: false, defaultValue: "" }); settings.push({ name: 'ModeratorsDoLabel', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "Show a Label on the Benders" }); settings.push({ name: 'ModeratorsLabel', type: 'str', minLength: 1, maxLength: 255, label: 'Benders Label Content', required: false, defaultValue: "" }); settings.push({ name: 'FanclubDoLabel', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "Show a Label on the Fanclub " }); settings.push({ name: 'FanclubLabel', type: 'str', minLength: 1, maxLength: 255, label: 'Fanclub Label Content', required: false, defaultValue: "" }); for (var i = 0; i < self.ClubNumber; i++) { settings.push({ name: 'ClubDoLabel{0}'.format(i), type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "Show a Message on the Nation #{0} Member Messages".format(i + 1) }); settings.push({ name: 'ClubLabel{0}'.format(i), type: 'str', minLength: 1, maxLength: 255, label: 'Nation #{0} Label Content'.format(i + 1), required: false, defaultValue: "" }); } // #region Broadcaster Options settings.push({ name: 'BroadcasterDoColor', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "Color the Broadcaster Messages" }); settings.push({ name: 'BroadcasterColor', type: 'str', minLength: 1, maxLength: 255, label: 'Broadcaster Color Code ', required: false, defaultValue: "" }); // #endregion // #region Moderators Option settings.push({ name: 'ModeratorsDoColor', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "Show a Color on the Benders " }); settings.push({ name: 'ModeratorsColor', type: 'str', minLength: 1, maxLength: 255, label: 'Benders Color Code', required: false, defaultValue: "" }); // #endregion // #region Fanclub Option settings.push({ name: 'FanclubDoColor', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "Show a Color on the Fanclub Messages" }); settings.push({ name: 'FanclubColor', type: 'str', minLength: 1, maxLength: 255, label: 'Fanclub Color Code', required: false, defaultValue: "" }); for (var i = 0; i < self.ClubNumber; i++) { settings.push({ name: 'ClubDoColor{0}'.format(i), type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "Color the Message on the Nation #{0} Member Messages".format(i + 1) }); settings.push({ name: 'ClubColor{0}'.format(i), type: 'str', minLength: 1, maxLength: 255, label: 'Nation #{0} Background Color.'.format(i + 1), required: false, defaultValue: "" }); } for (var i = 0; i < self.ClubNumber; i++) { settings.push({ name: 'ClubDoAnnounce{0}'.format(i), type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: "Announce On Entrance and on Leaving the Nation #{0} Member".format(i + 1) }); } for (var i = 0; i < self.ClubNumber; i++) { settings.push({ name: 'ClubCost{0}'.format(i), type: 'int', minValue: 1, maxValue: 100000, label: 'Cost in Tokens to Join the Nations #{0}'.format(i + 1), required: false, defaultValue: 0 }); settings.push({ name: 'ClubJoinMode{0}'.format(i), type: 'choice', choice1: JoinMode.Manual, choice2: JoinMode.ExactTip, choice3: JoinMode.MinimumTip, defaultValue: JoinMode.ExactTip, label: "Join Mode for the Nation #{0} Member".format(i + 1) }); settings.push({ name: 'ClubJoinMessage{0}'.format(i), type: 'str', minLength: 1, maxLength: 255, label: 'Nation #{0} Personal message on Join'.format(i + 1), required: false, defaultValue: "" }); } for (var i = 0; i < self.ClubNumber; i++) { settings.push({ name: 'ClubAdvMessage{0}'.format(i), type: 'str', minLength: 1, maxLength: 255, label: 'Nation #{0} Adv Message'.format(i + 1), required: false, defaultValue: "" }); } for (var i = 0; i < self.ClubNumber; i++) { // #region Clubs Settings settings.push({ name: 'ClubMembers{0}'.format(i), type: 'str', minLength: 1, maxLength: 255, label: 'Nation #{0} Member List'.format(i + 1), required: false, defaultValue: "" }); // #endregion } cb.settings_choices = settings; }; this.LoadSettings = function () { self.BroadcasterOptions.DoColor = cb.settings.BroadcasterDoColor == "Yes"; self.BroadcasterOptions.Color = cb.settings.BroadcasterColor; self.BroadcasterOptions.DoLabel = cb.settings.BroadcasterDoLabel == "Yes"; self.BroadcasterOptions.Label = cb.settings.BroadcasterLabel; self.ModeratorsOptions.DoColor = cb.settings.ModeratorsDoColor == "Yes"; self.ModeratorsOptions.Color = cb.settings.ModeratorsColor; self.ModeratorsOptions.DoLabel = cb.settings.ModeratorsDoLabel == "Yes"; self.ModeratorsOptions.Label = cb.settings.ModeratorsLabel; self.FanclubOptions.DoColor = cb.settings.FanclubDoColor == "Yes"; self.FanclubOptions.Color = cb.settings.FanclubColor; self.FanclubOptions.DoLabel = cb.settings.FanclubDoLabel == "Yes"; self.FanclubOptions.Label = cb.settings.FanclubLabel; self.Advertisment.DoAdvertise = cb.settings.DoAdvertise == "Yes"; self.Advertisment.Timing = cb.AdvertismentTiming || 1; for ( var i = 0; i < self.ClubNumber; i++ ) { var name = cb.settings["ClubName{0}".format( i )] || "", label = cb.settings["ClubLabel{0}".format( i )] || "", doLabel = cb.settings["ClubDoLabel{0}".format( i )] == "Yes", color = cb.settings['ClubColor{0}'.format( i )] || "", doColor = cb.settings["ClubDoColor{0}".format( i )] == "Yes", doAnnounce = cb.settings["ClubDoAnnounce{0}".format( i )] == "Yes", cost = cb.settings["ClubCost{0}".format( i )] || 0, joinMode = cb.settings["ClubJoinMode{0}".format( i )] || JoinMode.ExactTip, joinMessage = cb.settings["ClubJoinMessage{0}".format( i )] || "", advertiseMessage = cb.settings["ClubAdvMessage{0}".format( i )], members = cb.settings["ClubMembers{0}".format( i )] || ""; members = ( members != "" ) ? members.split( "," ).map( function ( x ) { return x.trim(); } ) : []; if ( name == "" ) { cb.log( "Stopped Loading Clubs" ); break; } var club = new Club( name, label, doLabel, color, doColor, doAnnounce, cost, joinMode, joinMessage, members, advertiseMessage ); self.Clubs.push( club ); } self.Clubs.sort( function ( x, y ) { return y.Cost - x.Cost; } ); this.OnAdvertise(); }; this.HandleEvents = function () { cb.onMessage( self.OnMessage ); cb.onTip( self.OnTip ); cb.onEnter( self.OnEnter ); cb.onLeave( self.OnLeave ); }; // #endregion // #region Event Handlers this.OnMessage = function ( msg ) { if ( msg.m[0] == "/" || msg.m[0] == "?" || msg.m[0] == "!" ) { Commands.Parse( msg ); msg["X-Spam"] = true; return msg; } if ( msg.user == cb.room_slug ) { if ( self.BroadcasterOptions.DoLabel ) { msg.m = "[ " + self.BroadcasterOptions.Label + " ] " + msg.m; } if ( self.BroadcasterOptions.DoColor ) { msg.background = self.BroadcasterOptions.Color; } } else { var pre = ""; if ( msg.is_mod ) { if ( self.ModeratorsOptions.DoLabel ) { pre = self.ModeratorsOptions.Label; } if ( self.ModeratorsOptions.DoColor ) { msg.background = self.ModeratorsOptions.Color; } } if ( msg.in_fanclub ) { if ( self.FanclubOptions.DoLabel ) { pre = self.FanclubOptions.Label; } if ( self.FanclubOptions.DoColor ) { msg.background = self.FanclubOptions.Color; } } var index = self.GetClubByUser( msg.user ); if ( index != -1 ) { if ( self.Clubs[index].DoLabel ) { if ( pre == "" ) { msg.m = "[ " + self.Clubs[index].Label + " ] " + msg.m; } else { msg.m = "[ " + pre + " - " + self.Clubs[index].Label + " ] " + msg.m; } } if ( self.Clubs[index].DoColor ) { msg.background = self.Clubs[index].Color; } } else { if ( pre != "" ) { msg.m = "[ " + pre + " ] " + msg.m; } } } return msg; }; this.OnTip = function ( tip ) { var amount = parseInt( tip.amount ); var index = self.GetClubByCost( amount ); if ( index != -1 ) { if ( self.Clubs[index].CanJoin( amount ) ) { self.Clubs[index].Join( tip.from_user ); } } }; this.OnEnter = function ( user ) { var index = self.GetClubByUser( user.user ); if ( index != -1 ) { if ( self.Clubs[index].Announce ) { var mesage = "Member {1} of the {0} Club Has Entered the Room!".format( self.Clubs[index].Name, user.user ); Notice.Send( mesage, '', self.Clubs[index].Color ); } } }; this.OnLeave = function ( user ) { var index = self.GetClubByUser( user.user ); if ( index != -1 ) { if ( self.Clubs[index].Announce ) { var message = "Member {1} of the {0} Club Has Left the Room!".format( self.Clubs[index].Name, user.user ); Notice.Send( message, '', self.Clubs[index].Color ); } } }; // #endregion // #region Command Handlers this.ListClub = function ( msg, params ) { var user = msg.user; var content; if (params == "") { // Show The list of Clubs content = ""; for (var i = 0; i < self.Clubs.length; i++) { content += "= {0} - {1} Club"; } content = ContentWithTitle("List of Clubs", content); } else { var clubCost = parseInt(params); var clubId = self.GetClubByCost(clubCost); content = ""; if (clubId != -1) { var memberString = self.Clubs[clubId].Members.length == 0 ? "None." : self.Clubs[clubId].Members.join(", "); content = "Cost: {0}\n" + "Members: {1}".format(self.Clubs[clubId].Cost, memberString); content = ContentWithTitle("{0} Information".format(self.Clubs[clubId].Name), content); } else { content = "No Club with Cost {0} have been registered.".format(clubCost); } } Notice.Information(content, user); }; this.Join = function ( x, y ) { self.OnClubAction( ClubAction.Join, y ); } this.Leave = function ( x, y ) { self.OnClubAction( ClubAction.Leave, y ); } this.SendMessage = function ( msg, y ) { var amount = parseInt( y.substr( 0, y.indexOf( " " ) == -1 ? y.length : y.indexOf( " " ) ).trim() ); var message = y.substr( y.indexOf( " " ) == -1 ? y.length : y.indexOf( " " ), y.length - 1 ).trim(); var index = self.GetClubByCost( amount ); if ( index != -1 ) { for ( var i = 0; i < self.Clubs[index].Members.length; i++ ) { Notice.Send( message, '', self.Clubs[index].Color, self.Clubs[index].Members[i] ); } Notice.Send( message, '', self.Clubs[index].Color, cb.room_slug ); } }; this.Help = function ( x, y ) { Notice.Success( Commands.GetCommandList(x, "Clubber Bot") ); }; this.About = function ( x, y ) { if ( typeof y == 'undefined' || y == null ) y = { user: "" }; var content = "====================\n" + "Welcome to the War Nations!\n" + "You can Join any of the Nations based on your preference but you will have to tip the unique tip amount for the Nations.\n" + "===================="; Notice.Information( content, y.user ); Notice.Warning( "This is a modified version of Clubbers Bot by Khiladi.", y.user ); }; // #endregion // #region Utility Members this.GetClubByUser = function ( user ) { for ( var i = 0; i < self.Clubs.length; i++ ) { if ( cbjs.arrayContains( self.Clubs[i].Members, user ) ) return i; } return -1; }; this.GetClubByCost = function ( cost ) { for ( var i = 0; i < self.Clubs.length; i++ ) { if ( self.Clubs[i].CanJoin( cost ) ) return i; } return -1; }; this.OnClubAction = function ( mode, params ) { var amount = parseInt( params.substr( 0, params.indexOf( " " ) == -1 ? params.length : params.indexOf( " " ) ).trim() ); var userlist = params.substr( params.indexOf( " " ) == -1 ? params.length : params.indexOf( " " ), params.length - 1 ).trim().split( "," ).map( function ( z ) { return z.trim(); } ); var clubId = self.GetClubByCost( amount ); if ( clubId != -1 ) { for ( var i = 0; i < userlist.length; i++ ) { if ( mode == ClubAction.Join ) { self.Clubs[clubId].Join( userlist[i] ); } else if ( mode == ClubAction.Leave ) { self.Clubs[clubId].Leave( userlist[i] ); } } } }; this.OnAdvertise = function () { if ( self.Advertisment.DoAdvertise ) { // Get Random index of a club var id = GetRandomIndex( self.Clubs ); if ( self.Clubs[id].AdvMessage != "" ) { Notice.Send( self.Clubs[id].AdvMessage, '', self.Clubs[id].Color ); } else { var message = "Join the {0} Club for only {1}".format( self.Clubs[id].Name, self.Clubs[id].Cost ); Notice.Send( message, '', self.Clubs[id].Color ); } cb.setTimeout( self.OnAdvertise, 60 * 1000 * self.Advertisment.Timing ); } }; this.SwitchAdvertisment = function ( x, y ) { if ( y != "" ) { var time = parseInt( y ); if ( time > 0 ) { self.Advertisment.Timing = time; Notice.Information( "Advertisment Time set to " + time + " Minutes", cb.room_slug ); } else { Notice.Error( "Cannot set the Timing to 0 or less. User /adv to disable Advertising for Clubs", cb.room_slug ); } } else { self.Advertisment.DoAdvertise = !self.Advertisment.DoAdvertise; Notice.Information( 'Advertisment Messages are: ' + ( ( self.Advertisment.DoAdvertise ) ? "ON" : "OFF" ), cb.room_slug ); } self.OnAdvertise(); }; // #endregion } // #endregion var bot = new Clubber(); bot.Initialize();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.