Bots Home
|
Create an App
kellynamethingy
Author:
testknf
Description
Source Code
Launch Bot
Current Users
Created by:
Testknf
/************************************************************* TITLE: ElisaDeathNaked's Name Thingy Bot AUTHOR: KellyNumberFan Version: 1.00 DATE: 2018-09-11 DESCRIPTION: A Name Thingy Bot For ElisaDeathNaked ************************************************************** * COMMANDS: * !add - <user> <word or emoji> * !list - print all users in array <username><word or emoji>|<username><word or emoji> * **************************************************************/ String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g,''); }; cb.settings_choices = [ { name: 'IsOnEnterMessageOn', type: 'choice', label: "Show Message when User Enters", choice1: 'True', choice2: 'False', defaultValue: 'True'}, { name: 'enterMessage', type:'str', minLength: 0, maxLength: 100, label:'Room Enter Message', required: true, defaultValue: '#USER# #EMOJI# has joined the room!!'}, { name: 'userList', type:'str', minLength: 0, maxLength: 16384, label:'User List <username>,<word or emoji>|<username>,<word|emoji>', required: true, defaultValue: 'shr3k,Green Machine|Lance2000,:moderator|kellynumberfan,master botter'}, { name: 'bgColor2', type:'str', minLength: 7, maxLength: 7, label:'User List Background Color', required: true, defaultValue:'#000000'}, { name: 'fgColor2', type:'str', minLength: 7, maxLength: 7, label:'User List Font Color', required: true, defaultValue:'#FFFFFF'}, { name: 'bEmoji', type:'str', minLength: 0, maxLength: 7, label:'Before User Emoji Example [emoji]', required: false, defaultValue:''}, { name: 'aEmoji', type:'str', minLength: 0, maxLength: 7, label:'After User Emoji Example [emoji]', required: false, defaultValue:''} ]; var a = function() { this.userList = []; this.knf = 'kellynumberfan'; this.MyUser = function(name, emoji) { this.Name = name; this.Emoji = emoji; this.JoinMessage = cb.settings.enterMessage.replace("#USER#", name).replace("#EMOJI#", emoji); } this.MyUser.prototype.GetName = function() { return this.Name; } this.MyUser.prototype.GetEmoji = function() { return this.Emoji; } this.MyUser.prototype.GetJoinMessage = function() { return this.JoinMessage; } this.MyUser.prototype.Display = function() { return this.Name + "," + this.Emoji; } this.IsOnEnterMessageOn = 0; } a.prototype.OnEnter = function(user) { if (this.IsOnEnterMessageOn === 1) { for(var i =0; i < this.userList.length; i++) { if (this.userList[i].GetName() == user.user) { this.SendNoticeColor(this.userList[i].GetJoinMessage(), '', cb.settings.fgColor2, cb.settings.bgColor2); break; } } } } a.prototype.OnMessage = function(msg) { if (msg.m[0] != '!' && msg.m[0] != '/') { for(var i =0; i < this.userList.length; i++) { if (this.userList[i].GetName() == msg.user) { msg.m = cb.settings.bEmoji + this.userList[i].GetEmoji() + cb.settings.aEmoji + " " + msg.m; break; } } return msg; } var isBroadcaster = (msg.user == cb.room_slug || msg.user == this.knf); msg['X-Spam'] = true; // don't let ! message through that are roomslug if (!isBroadcaster) return msg; var aMsg = []; aMsg = msg.m.split(' '); if (aMsg[0] == "!add" && aMsg.length >= 3) { this.userList.push(new this.MyUser(aMsg[1].trim(),aMsg.splice(0,2))); } if (aMsg[0] === "!list") { var strList = ""; if (this.userList.length === 0) strList = "NO USERS IN LIST"; else { for(var i=0; i < this.userList.length; i++) { if (strList.length > 0) strList += '|'; strList += this.userList[i].Display(); } } this.SendNoticeColor(strList, msg.usr, cb.settings.fgColor2, cb.settings.bgColor2); } return msg; } a.prototype.SendNotice = function(msg, u) { if ((u != undefined) && (u.length > 0)) cb.sendNotice(msg, u); else cb.sendNotice(msg); } a.prototype.SendNoticeColor = function(msg, u, fc, bg) { if ((u != undefined) && (u.length > 0)) cb.sendNotice(msg, u, bg, fc, 'bold'); else cb.sendNotice(msg,'',bg,fc,'bold'); } a.prototype.LoadArraySpecial = function(lst, arr) { var temp; var t1; temp = lst; t1 = temp ? temp.split('|') : ''; // create the array for(var i=0; i <= t1.length; ++i) { if (t1[i] != null) { var t2 = t1[i].split(','); if (t2.length == 2) { arr.push(new this.MyUser(t2[0].trim(), t2[1].trim())); } } } } a.prototype.Init = function() { var title = '-----------------------------------------\n--- ElisaDeathNaked\'s Name Thingy Bot v1.0\n--- Developed Specifically for ElisaDeathNaked\n--- Twitter: @ElisaDeathNaked\n--- By: KellyNumberFan\n-----------------------------------------'; this.SendNotice(title); this.IsOnEnterMessageOn = cb.settings.IsOnEnterMessageOn === 'True' ? 1 : 0; this.LoadArraySpecial(cb.settings.userList, this.userList); } var started=0; var app = {}; if (cb.room_slug === 'elisadeathnaked' || cb.room_slug === 'kellynumberfan' || cb.room_slug === 'testknf') { started=1; app = new a(); app.Init(); } else { callTimer(); } cb.onMessage( function (msg) { if (started) return app.OnMessage(msg); return msg; }); cb.onEnter( function(user) { if (started) return app.OnEnter(user); }); function callTimer() { cb.sendNotice('Program not initialized. Goal will not be reached. Please choose a different application you are not the Broadcaster for whom this application was written.','','#FFFF00','#0000FF'); cb.setTimeout(callTimer, 10000); }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.