Bots Home
|
Create an App
Memnoch Goal Bot Multi-lang
Author:
memnoch91
Description
Source Code
Launch Bot
Current Users
Created by:
Memnoch91
String.prototype.format = function () { var newString = String(this); for (var i = 0; i < arguments.length; i++) { newString = newString.replace('{' + i + '}', arguments[i]); } return String(newString); } String.prototype.genre=function(){ var newString=String(this) var mS=newString.match(/\[m:.*?]/) var fS=newString.match(/\[f:.*?]/) var tS=newString.match(/\[t:.*?]/) var cS=newString.match(/\[c:.*?]/) switch (arguments[0]){ case 'c': if (!isUndefined(cS)){ if (cS.length>0){ for (var i=0;i<cS.length;i++){ newString=newString.replace(cS[i],cS[i].substring(3,cS[i].length-1)) } }else{ if (!isUndefined(mS)){ if(mS.length>0){ for (var i=0;i<mS.length;i++){ newString=newString.replace(mS[i],mS[i].substring(3,mS[i].length-1)) } } } } }else{ if (!isUndefined(mS)){ if(mS.length>0){ for (var i=0;i<mS.length;i++){ newString=newString.replace(mS[i],mS[i].substring(3,mS[i].length-1)) } } } } break; case 't': if (!isUndefined(tS)){ if (tS.length>0){ for (var i=0;i<tS.length;i++){ newString=newString.replace(tS[i],tS[i].substring(3,tS[i].length-1)) } }else{ if (!isUndefined(mS)){ if(mS.length>0){ for (var i=0;i<mS.length;i++){ newString=newString.replace(mS[i],mS[i].substring(3,mS[i].length-1)) } } } } }else{ if (!isUndefined(mS)){ if(mS.length>0){ for (var i=0;i<mS.length;i++){ newString=newString.replace(mS[i],mS[i].substring(3,mS[i].length-1)) } } } } break; case 'f': if (!isUndefined(fS)){ if (fS.length>0){ for (var i=0;i<fS.length;i++){ newString=newString.replace(fS[i],fS[i].substring(3,fS[i].length-1)) } }else{ if (!isUndefined(mS)){ if(mS.length>0){ for (var i=0;i<mS.length;i++){ newString=newString.replace(mS[i],mS[i].substring(3,mS[i].length-1)) } } } } }else{ if (!isUndefined(mS)){ if(mS.length>0){ for (var i=0;i<mS.length;i++){ newString=newString.replace(mS[i],mS[i].substring(3,mS[i].length-1)) } } } } break; case 'm': if (!isUndefined(mS)){ if(mS.length>0){ for (var i=0;i<mS.length;i++){ newString=newString.replace(mS[i],mS[i].substring(3,mS[i].length-1)) } } } break; } for (var i=0;i<mS.length;i++){ newString=newString.replace(mS[i],"") } for (var i=0;i<fS.length;i++){ newString=newString.replace(fS[i],"") } for (var i=0;i<cS.length;i++){ newString=newString.replace(cS[i],"") } for (var i=0;i<tS.length;i++){ newString=newString.replace(tS[i],"") } return String(newString) } String.prototype.isInt = function () { return isInt(this) } String.prototype.left=function(){ var str = String(this) return str.substring(0,arguments[0]) } String.prototype.right=function(){ var str = String(this) return str.substring(str.length-arguments[0]) } String.prototype.mid=function(){ var str = String(this) return str.substring((arguments[0]-1),arguments[1]) } String.prototype.match=function(){ var regex = new RegExp(arguments[0])// /<p.*?<\/p>/g; var str = String(this) var arr=[] if (regex.test(str)==false){ return arr }else{ var m=regex.exec(str) while (m!=null){ arr.push(m[0]) str=str.replace(m[0],'') m=regex.exec(str) } return arr } } String.prototype.valMatch=function(){ var regex = new RegExp(arguments[0])// /<p.*?<\/p>/g; var str = String(this) var arr=[] if (regex.test(str)==false){ arr.push(undefined) }else{ var m=regex.exec(str) while (m!=null){ arr.push(m[0].mid(arguments[1],(m[0].length-arguments[2]))) str=str.replace(m[0],'') m=regex.exec(str) } } return arr } String.prototype.p=function(){ var str = String(this) if (arguments.length==0){ return "<p f:'' b:'' bo:'' >"+str+"</p>" }else{ var s="<p" s+=valIfTrueElse(isUndefined(arguments[0]),true," f:''"," f:"+arguments[0]) s+=valIfTrueElse(isUndefined(arguments[1]),true," b:''"," b:"+arguments[1]) s+=valIfTrueElse(isUndefined(arguments[2]),true," bo:''"," bo:"+arguments[2]) s+=">"+str+"</p>" return s } } String.prototype.paragraphe=function(){ var newString=String(this) var P=newString.match(/<p.*?<\/p>/) var arr=[] if (P.length==0){ var o={ st:"", f:undefined, b:undefined, bo:undefined, } o.st=newString arr.push(o) }else{ for (var i=0;i<P.length;i++){ var pa=P[i].match(/<p.*?>/) if (pa.length>0){var f=pa[0].match(/f:.*? /)}else{var f=''} if (pa.length>0){var b=pa[0].match(/b:.*? /)}else{var b=''} if (pa.length>0){var bo=pa[0].match(/bo:.*?>/)}else{var bo=''} var st=P[i].match(/>.*?<\/p>/) var o={ st:"", f:undefined, b:undefined, bo:undefined, } if (st.length>0){o.st=st[0].mid(2,st[0].length-4)} if (f.length>0){o.f=f[0].mid(3,f[0].length-1)} if (b.length>0){o.b=b[0].mid(3,b[0].length-1)} if (bo.length>0){o.bo=bo[0].mid(4,bo[0].length-1)} arr.push(o) } } return arr } function isInt (value) { return !isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10)); }; function valIfUndefined (test,valIf){ if (isUndefined(test)){ return valIf }else{ return test } }; function valIfTrue(test,val,valIf){ if(test==val){ return valIf }else{ return test } }; function valIfTrueElse(test,val,valIf,valElse){ if(test==val){ return valIf }else{ return valElse } } function isUndefined (test) { return (test == undefined || test == "" || test == 0 || test==null); }; function Ran (min, max) { return Math.floor(Math.random() * (max - min +1)) + min; }; function isSuperuser (username, isMod) { return (username == cb.room_slug || isMod); }; function retourLigne (strBase,newStr){ var output=strBase output+=valIfTrueElse((output!="" && newStr!=""),true,"\n","")+newStr return output } function alert(msg){ M.message.sendMessageToGroup(null,msg) } function numInArray(arr,i){ if (arr.length==0 || isUndefined(i)){ return -1 }else{ if (i<0){ return 0 }else if (i>arr.length-1){ return arr.length-1 }else{ return i } } } function isInArray(arr,i){ if (arr.length==0 || isUndefined(i)){ return false }else{ if (i<0 || i>arr.length-1){ return false }else{ return true } } } function nbrOccurence(chaine,occ){ var mot2 = chaine.split(occ); var nbre_de_fois_trouve = mot2.length-1; return nbre_de_fois_trouve; } function sleep(miliseconds) { var currentTime = new Date().getTime(); while (currentTime + miliseconds >= new Date().getTime()) { } } ////////////////////////////////////////////////////////////////////////// var Mod = { Name: "Memnoch Goal", Version: 1.01, Author: "memnoch91", OriginalAuthor: "memnoch91", Debug: false, StartupTime: null, Constants: { languages: 1, goals:1, }, }; // ! modifiable var UserConstants = { "memnoch91": { languages: 2, goals:5, }, }; // ! Non modifiable var Colours = { 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" }; if (cb != null) { if (UserConstants[cb.room_slug] != undefined) Mod.Constants = UserConstants[cb.room_slug]; } if (cb == null) { var cb = { settings_choices: [], changeRoomSubject: function (new_subject) { }, drawPanel: function () { }, log: function (message) { }, onDrawPanel: function (func) { }, onEnter: function (func) { }, onLeave: function (func) { }, onMessage: function (func) { }, onShowStatus: function (func) { }, onTip: function (func) { }, room_slug: '', sendNotice: function (message, to_user, background, foreground, weight, to_group) { }, setTimeout: function (func, msec) { }, settings: {}, tipOptions: function (func) { }, limitCam_start: function (message, allowed_users) { }, limitCam_stop: function () { }, limitCam_addUsers: function (allowed_users) { }, limitCam_removeUsers: function (removed_users) { }, limitCam_removeAllUsers: function () { }, limitCam_userHasAccess: function (user) { }, limitCam_allUsersWithAccess: function () { }, limitCam_isRunning: function () { }, }; } cb.settings_choices = [] var M={ params:{ DelaiForMessage:10, }, settings:{}, message:{ sendMessageToUser(userName,mess,fontColor,backgroundColor,fontBold){ this.send(mess,userName,null,fontColor,backgroundColor,fontBold) }, sendMessageExceptUser(userName,mess,fontColor,backgroundColor,fontBold){ for (us in utilisateurs.utilisateurs){ if (us.name!=userName && us.connected==true){ this.send(mess,us.name,null,fontColor,backgroundColor,fontBold) } } }, sendMessageToGroup(group,mess,fontColor,backgroundColor,fontBold){ this.send(mess,null,group,fontColor,backgroundColor,fontBold) }, send(message,utilisateurName,group,couleurTexte,couleurFond,bold){ cb.setTimeout(function(){ if (!isUndefined(message)){ //cb.sendNotice(message,null,null,Colours.SkyBlue,Colours.AliceBlue) var arr=String(message).paragraphe() for (var i=0;i<arr.length;i++){ var m = arr[i].st var c = valIfUndefined(arr[i].f,valIfUndefined(couleurTexte,Colours.Black)) var f = valIfUndefined(arr[i].b,valIfUndefined(couleurFond,Colours.White)) var b = valIfUndefined(arr[i].bo,valIfUndefined(bold,'normal')) if (!isUndefined(utilisateurName) && !isUndefined(group)) { cb.sendNotice(m, null, f, c, b, group); cb.sendNotice(m, utilisateurName, f, c, b, null); }else if (!isUndefined(utilisateurName) && isUndefined(group)){ cb.sendNotice(m, utilisateurName, f, c, b, null); }else if (isUndefined(utilisateurName) && !isUndefined(group)){ cb.sendNotice(m, null, f, c, b, group); }else if (isUndefined(utilisateurName) && isUndefined(group)) { cb.sendNotice(m, null, f, c, b, null); } sleep(10) } } },M.params.DelaiForMessage) }, }, languages:{ //----------------------------------------------------------------------------- params:{ C:"languages", I:function(i){return "Language_{0}".format(i)}, S:"> LANGUAGE (<Abrev>,<Name>,<Description>) . . . . . . . . . . . . . . . . . . ", Settings:[], Co:[], }, //----------------------------------------------------------------------------- innit(){ var Me=M.languages.params for (var i=2;i<=Mod.Constants.languages;i++){ var st="" if (i==2){ st+= Me.S+"-> Lang. "+i }else{ st="-> Lang. "+i } Me.Settings.push({ name: Me.I(i), label:st, type: 'str', minLength: 0, maxLength: 255, required: false, defaultValue:'' }); } cb.settings_choices = cb.settings_choices.concat(Me.Settings); }, parseOptions(){ var Me=M.languages.params var d = new language(1,'En','English','For an English traduction',true) Me.Co.push(d) var z=1; for (var i = 2; i <= Mod.Constants[Me.C]; i++) { if (!isUndefined(cb.settings[Me.I(i)])){ var Arr= cb.settings[Me.I(i)].split(',') if (Arr.length==3){ z++; var cl = new language(z,Arr[0],Arr[1],Arr[2],false) Me.Co.push(cl) } } } }, //----------------------------------------------------------------------------- buildHelp(msg,_utilisateur){ var output = "" //output=retourLigne(output,language.buidHelp(msg_utilisateur)) return output }, onMessage(msg,_utilisateur){ var output="" //language.onMessage(msg,_utilisateur) }, //----------------------------------------------------------------------------- get All(){ return M.languages.params.Co }, get DefaultLanguage(){ var all=this.All for (var i = 0 ; i <all.length;i++){ if (all[i].Default==true){ return all[i] } } }, Get(args){ if (isUndefined(args)){ return this.DefaultLanguage }else{ if (isInt(args)){ var all=this.All for (var i = 0 ; i <all.length;i++){ if (all[i].Index==args){ return all[i] } } return undefined }else if (typeof args=="string"){ var all=this.All for (var i = 0 ; i <all.length;i++){ if (all[i].Abrev==args){ return all[i] } } return undefined }else{ return args } } }, }, utilisateurs:{ params:{ Co:[], }, innit(){}, parseOptions(){}, //----------------------------------------------------------------------------- buildHelp(msg,_utilisateur){ var output = "" output=retourLigne(output,utilisateur.buidHelp(msg,_utilisateur)) return output }, onMessage(msg,_utilisateur){ var output="" utilisateur.onMessage(msg,_utilisateur) }, //----------------------------------------------------------------------------- get All(){ return M.utilisateurs.params.Co }, Get(args){ if (isUndefined(args)){ return undefined }else{ var all=this.All for (var i = 0 ; i <all.length;i++){ if (all[i].Name.toLowerCase()==args.toLowerCase()){ return all[i] } } return undefined } }, //----------------------------------------------------------------------------- onEnter(user){ if (isUndefined(this.Get(user.user))){ var u = new utilisateur(user) this.params.Co.push(u) u.Connected=true }else{ if (this.Get(user.user).Param.U==undefined){ this.Get(user.user).reload(user) } this.Get(user.user).Connected=true } }, onLeave(user){ if (isUndefined(this.Get(user.user))){ var u = new utilisateur(user) this.params.Co.push(u) u.Connected=false }else{ this.Get(user.user).Connected=false } }, onTip(tip){ if (isUndefined(this.Get(tip.from_user))){ var u = new utilisateur(tip.from_user) this.params.Co.push(u) u.Connected=true u.in_fanclub=tip.from_user_in_fanclub u.Param.has_tokens=tip.from_user_has_tokens u.Param.is_mod=tip.from_user_is_mod u.Param.tipped_recently=tip.from_user_tipped_recently u.Param.tipped_alot_recently=tip.from_user_tipped_alot_recently u.Param.tipped_tons_recently=tip.from_user_tipped_tons_recently u.Param.genre=tip.from_user_genre } this.Get(tip.from_user).onTip(tip) }, onMessage(msg){ var u = undefined if (isUndefined(this.Get(msg.user))){ u = new utilisateur(msg.user) this.params.Co.push(u) u.Connected=true } u=this.Get(msg.user) u.in_fanclub=msg.in_fanclub u.Param.has_tokens=msg.has_tokens u.Param.is_mod=msg.is_mod u.Param.tipped_recently=msg.tipped_recently u.Param.tipped_alot_recently=msg.tipped_alot_recently u.Param.tipped_tons_recently=msg.tipped_tons_recently u.Param.genre=msg.genre //var messages = msg['m'].split(/\s+/g); // un tableau de tous les messages) //u.onMessage(msg['m'].split(/\s+/g),u) } }, innit(){ M.languages.innit() }, parseOptions(){ M.languages.parseOptions() } } class language{ //----------------------------------------------------------------------------- constructor(_Index,_Abrev,_Nom,_Description,_Default){ this.Param={ I:0, A:'', N:'', Descr:'', D:false, } this.Param.I=_Index this.Param.A=_Abrev this.Param.N=_Nom this.Param.Descr=_Description this.Param.D=_Default } //----------------------------------------------------------------------------- get Index(){ return this.Param.I } get Abrev(){ return this.Param.A } get Name(){ return this.Param.N } get Description(){ return this.Param.Descr } get Default(){ return this.Param.D } //----------------------------------------------------------------------------- static Get(args){ return M.languages.Get(args) } static get DefaultLanguage(){ return M.languages.DefaultLanguage } static get All(){ return M.languages.All } //----------------------------------------------------------------------------- static buildHelp(msg,ut){ var output='' var output="### LANGUAGES COMMAND LINE".p(Colours.White,Colours.Black,'bolder') output+=". . 1 -> /l => display the list of all available languages".p(Colours.Red,undefined,'bold') output+=". . 2 -> /l <Abrev> => change your current language to <Abrev> (Beta test)".p(Colours.Red,undefined,'bold') return output } static onMessage(msg,ut){ var isCommand=(msg[0].substring(0,1)=="/") if (isCommand==true){ msg[0]=msg[0].substring(1) if (msg[0]=="l"){ //if (ut.isSuperUtilisateur){ if (msg.length==1){ var all = language.All var output="### LANGUAGES LIST ###".p(Colours.White,Colours.Black,'bolder') for (var i=0;i<all.length;i++){ if (ut.Language.Abrev==all[i].Abrev){ output+=String(" -> "+all[i].Index+" : " + all[i].Abrev + " => " + all[i].Name + " (this is your current language)").p(Colours.Red,Colours.White,'bold') }else{ output+=String(" -> "+all[i].Index+" : " + all[i].Abrev + " => " + all[i].Name + " ("+ all[i].Description +")").p(Colours.Red,Colours.White,'bold') } } output+=String("##############################").p(Colours.White,Colours.Black,'bold') ut.Messages.sendToUser(output) }else{ //}else{ var l = language.Get(msg[1]) if (isUndefined(l)){ output+=String("Wrong command line : " + msg[1] +" is not an available language.").p(Colours.Red,Colours.Black,'bolder') output+=String("Enter the command '/l' for a complete list of available languagues").p(Colours.Red,Colours.Black,'bold') ut.Messages.sendToUser(output) }else{ ut.Language=l } } //} } } } } class utilisateur{ //----------------------------------------------------------------------------- constructor(user){ this.Param={ U:undefined, N:'', in_fanclub:false, has_tokens:false, is_mod:false, tipped_recently:false, tipped_alot_recently:false, tipped_tons_recently:false, genre:'m', C:false, languageIndex:0, } this.Messages={ U:undefined, sendToUser(message,fontColor,BackColor,Bold){ this.send(this.U.Name,null,message,fontColor,BackColor,Bold) }, send(user,group,mess,font,back,bold){ var f=valIfTrueElse(font,undefined,Colours.Black,font) var b=valIfTrueElse(back,undefined,Colours.white,back) var bo=valIfTrueElse(bold,undefined,'',bold) M.message.send(mess,user,group,font,back,bold) } } if (typeof user=="string"){ this.Param.N=user }else{ this.reload(user) } this.Messages.U=this } reload(user){ this.Param.U=user this.Param.N=user.user this.Param.in_fanclub=user.in_fanclub this.Param.has_tokens=user.has_tokens this.Param.is_mod=user.is_mod this.Param.tipped_recently=user.tipped_recently this.Param.tipped_alot_recently=user.tipped_alot_recently this.Param.tipped_tons_recently=user.tipped_tons_recently this.Param.genre=user.genre } //----------------------------------------------------------------------------- get Name(){return this.Param.N} get in_fanclub(){return this.Param.in_fanclub} get has_tokens(){return this.Param.has_tokens} get is_mod(){return this.Param.is_mod} get is_prop(){return this.Name==cb.room_slug} get tipped_recently(){return this.Param.tipped_recently} get tipped_alot_recently(){return this.Param.tipped_alot_recently} get tipped_tons_recently(){return this.Param.tipped_tons_recently} get genre(){return this.Param.genre} get Connected(){return this.Param.C} set Connected(value){ if (this.Param.C!=value){ this.Param.C=value } } get isSuperUtilisateur(){return (this.is_mod || this.Name==cb.room_slug)} get Language(){ if (this.Param.languageIndex==0){ return language.DefaultLanguage }else{ return language.Get(this.Param.languageIndex) } } set Language(value){ if (typeof value=="string" || isInt(value)){ this.Param.languageIndex=language.Get(value).Index }else{ this.Param.languageIndex=value.Index } } onMessage(msg,ut){ var isCommand=msg[0].substring(0,1)=="/" if (isCommand==true){ msg[0]=msg[0].substring(1) if (msg[0]=="u"){ if (ut.isSuperUtilisateur){ var par="" for (var i=1;i<msg.length;i++){ par+=msg[i]+" " } var utils=utilisateur.All var con=par.match(/-c:.+? /) if (con.length>0){ con=con[0].mid(4,con[0].length-1) switch (con){ case 'true': utils=utilisateur.Connected(utils) break; case 'false': utils=utilisateur.Disconnected(utils) break; } } var gen = par.match(/-g:.+? /) if (gen.length>0){ gen=gen[0].mid(4,gen[0].length-1) switch (gen){ case 'm': utils=utilisateur.Genre(utils,"m") break; case 'f': utils=utilisateur.Genre(utils,"f") break; case 't': utils=utilisateur.Genre(utils,"t") break; case 'c': utils=utilisateur.Genre(utils,"c") break; } } var output="### USERS LIST ###".p(Colours.White,Colours.Black,'bolder') for (var i=0;i<utils.length;i++){ var u= utils[i] output+=String(" -> UTILISATEUR : " + u.Name).p(Colours.Black,Colours.White,'bold') if (u.is_prop){ output+=". . . . User type : broadcaster".p(Colours.Orange,Colours.White,'bold') }else{ switch(u.is_mod){ case true: output+=". . . . User type : moderator".p(Colours.Red,Colours.White,'bold') break; case false: output+=". . . . User type : simple user".p(Colours.Black,Colours.White,'bold') break; } } switch (u.genre){ case "m": output+=". . . . Gender : Male".p(Colours.Blue,Clours.White) break; case "f": output+=". . . . Gender : Female".p(Colours.Pink,Clours.White) break; case "t": output+=". . . . Gender : Trans".p(Colours.Green,Clours.White) break; case "c": output+=". . . . Gender : Couple".p(Colours.Black,Clours.White) break; } if (u.in_fanclub){ output+=". . . . FANCLUB : user is in fanclub".p(Colours.Green,Colours.White) } switch (u.has_tokens){ case (true): output+=". . . . Tokens : user has tokens".p(Colours.Gold,Colours.White) break; case (false): output+=". . . . Tokens : user has no tokens".p(Colours.Red,Colours.White) break; } if (u.tipped_tons_recently){ output+=". . . . Tipped style : TONS".p(Colours.Purple,Colours.White,'bolder') }else if(u.tipped_alot_recently){ output+=". . . . Tipped style : LOT".p(Colours.Blue,Colours.White,'bold') }else if(u.tipped_recently){ output+=". . . . Tipped style : TONS".p(Colours.DarkBlue,Colours.White,'') }else{ output+=". . . . Tipped style : NONE".p(Colours.Red,Colours.White,'') } if (u.Connected){ output+=". . . . STATUS : user is currently connected".p(Colours.Green,Colours.White) }else{ output+=". . . . STATUS : user is currently disconnected".p(Colours.Red,Colours.White) } output+=String("-----------------------------").p(Colours.Black,Colours.White,'bold') } output+=String("##############################").p(Colours.White,Colours.Black,'bolder') this.Messages.sendToUser(output) } } } } onEnter(user){ //M.utilisateurs.onEnter(user) } onLeave(user){ //M.utilisateurs.onLeave(user) } onTip(tip){ //M.utilisateurs.onTip(tip) } //----------------------------------------------------------------------------- buildHelp(msg,u){ var output='' if (u.isSuperUtilisateur) { var output="### USERS COMMAND LINE".p(Colours.White,Colours.Black,'bolder') output+=". . 1 -> /u [[,-c:(true,false)][,-g:(m,f,c,t)] ] => display the list of cession users".p(Colours.Red,undefined,'bold') output+=". . . . . . -c:(true,false) -> missed : all users".p(Colours.Orange,undefined,'') output+=". . . . . . . . . . . . . . . . . . . .true : connected users users".p(Colours.Orange,undefined,'') output+=". . . . . . . . . . . . . . . . . . . .false : disconnected users users".p(Colours.Orange,undefined,'') output+=". . . . . . -g:(m,f,c,t) -> missed : all users".p(Colours.Orange,undefined,'') output+=". . . . . . . . . . . . . . . . . . . .m : male users users".p(Colours.Orange,undefined,'') output+=". . . . . . . . . . . . . . . . . . . .f : female users users".p(Colours.Orange,undefined,'') output+=". . . . . . . . . . . . . . . . . . . .c : couple users users".p(Colours.Orange,undefined,'') output+=". . . . . . . . . . . . . . . . . . . .t : trans users users".p(Colours.Orange,undefined,'') }else{ } return output } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- static Get(args){ if (typeof args=="string"){ return M.utilisateurs.Get(args) }else{ return M.languages.Get(args.user) } } static get All(){ return M.utilisateurs.All } static Connected(rep){ var arr=[] if (isUndefined(rep)){var all= utilisateur.All}else{var all=rep} for (var i=0;i<all.length;i++){ if (all[i].Connected){ arr.push(all[i]) } } return arr } static Disconnected(rep){ var arr=[] if (isUndefined(rep)){var all= utilisateur.All}else{var all=rep} for (var i=0;i<all.length;i++){ if (all[i].Connected==false){ arr.push(all[i]) } } return arr } static Genre(rep,val){ var arr=[] if (isUndefined(rep)){var all= utilisateur.All}else{var all=rep} for (var i=0;i<all.length;i++){ if (all[i].genre==val){ arr.push(all[i]) } } return arr } } class Emojis{ constructor(str){ this.Params={ E:[] } if (!isUndefined(str)){ var arrA=str.split(" ") var arrB=[] for (var i=0;i<arrA.length;i++){ arrB=arrB.concat(arrA[i].split(";")) } for (var i=0;i<arrB.length;i++){ this.Params.E.push(arrB[i]) } } } get Ran(){ if (this.Params.E.length==0){ return "" }else{ return this.Params.E[Ran(0,this.Params.E.length-1)] } } get All(){ return this.Params.E } Get(Index){ if (isInArray(this.Params.E,Index)){ return this.Param.E[Index] }else{ return "" } } } class Sentences{ constructor(ParamName,Abr){ this.Params={ PN:ParamName, S:Abr, Sentences:[], } this.parseOptions() } parseOptions(){ for (var i=1;i<=Mod.Constants[this.Params.PN];i++){ var S=new Sentence(this.Params.S,i) if (S.Valide){ this.Params.Sentences.push(S) } } } AllObject(){ var arr=[] var a=this.Params.Sentences for (var i=0;i<a.length;i++){ var b=a.AllObject(true) for (var j=0;j<b.length;j++){ arr.push(b) } } return arr } All(Lang){ var arr=[] var a = this.AllObject() for (var i=0;i<a.length;i++){ arr.push(a.Sentence) } } GetObject(Index,Lang,returnDefault){ for (var i=0;i<this.Params.Sentences.length;i++){ if(this.Params.Sentences[i].Index==Index){ return this.Params.Sentences[i].GetObject(Lang,returnDefault) } } return undefined } Get(Index,Lang,returnDefault){ for (var i=0;i<this.Params.Sentences.length;i++){ if(this.Params.Sentences[i].Index==Index){ return this.Params.Sentences[i].Get(Lang,returnDefault) } } } } class Sentence{ constructor(Abr,Index){ this.Params={ S:Abr, I:Index, L:[], } this.parseOptions() } parseOptions(){ for (var i=1;i<Mod.Constants.languages;i++){ var l=new SentenceLang(this.Params.S,this.Params.Index,i) L.push(l) } } Valide(Lang){ if (isUndefined(Lang)){ for (var i=0;i<this.Params.L.length;i++){ if (this.Params.L[i].Valide){ return true } } return false } } get Index(){return this.Params.I} AllObject(withInvalide){ var arr if (isUndefined(withInvalide) || withInvalide==false){ for (var i=0;i<this.Params.L.length;i++){ if (this.Params.L[i].Valide){ arr.push(this.Params.L[i]) } } return arr }else{ for (var i=0;i<this.Params.L.length;i++){ arr.push(this.Params.L[i]) } return arr } } All(withInvalide){ var arr if (isUndefined(withInvalide) || withInvalide==false){ for (var i=0;i<this.Params.L.length;i++){ if (this.Params.L[i].Valide){ arr.push(this.Params.L[i].Sentence) } } return arr }else{ for (var i=0;i<this.Params.L.length;i++){ arr.push(this.Params.L[i].Sentence) } return arr } } GetObject(Lang,returnDefault){ for(var i=0;i<this.Params.L.length;i++){ if (this.Params.L[i].Language.Index==language.Get(Lang).Index){ return this.Params.L[i] } } if (isUndefined(returnDefault) || returnDefault==true){ var l = language.DefaultLanguage for(var i=0;i<this.Params.L.length;i++){ if (this.Params.L[i].Language.Index==l.Index){ return this.Params.L[i] } } for (var i=0;i<this.Params.L.length;i++){ if (this.Params.L[i].Valide==true){ return this.Params.L[i] } } return undefined }else{ return undefined } } Get(Lang,returnDefault){ for(var i=0;i<this.Params.L.length;i++){ if (this.Params.L[i].Language.Index==language.Get(Lang).Index){ return this.Params.L[i].Sentence } } if (isUndefined(returnDefault) || returnDefault==true){ var l = language.DefaultLanguage for(var i=0;i<this.Params.L.length;i++){ if (this.Params.L[i].Language.Index==l.Index){ return this.Params.L[i].Sentence } } for (var i=0;i<this.Params.L.length;i++){ if (this.Params.L[i].Valide==true){ return this.Params.L[i].Sentence } } return "" }else{ return "" } } } class SentenceLang{ constructor(Abr,Index,LIndex){ this.Params={ S:Abr, Index:Index, LIndex:LIndex, } } get Valide(){ if (cb.settings[String(Abr+Index+"_"+LIndex)]==""){ return false }else{ return true } } get Language(){ return language.Get(LIndex) } get Sentence(){ return cb.settings[String(Abr+Index+"_"+LIndex)] } } ///////////////////////////////////////////////////////////// var goals={ params:{ Settings:[], SA:"Goal_{0}_A", SE:"Goal_{0}_E", SS:"Goal_{0}_{1}", Sentences:undefined, }, goals:[], innit(){ var Me=goals.params for (var i=1;i<=Mod.Constants.goals;i++){ var st="" if (i==1){ st="> GOALS . . . . . . . ." } st+="Goal N "+i+" - Amount " Me.Settings.push({ name: Me.SA.format(i), label:st, type: 'int', required: (i==1), defaultValue:(i*25) }); st="Random Emoji " Me.Settings.push({ name: Me.SE.format(i), label:st, type: 'str', required: false, defaultValue:'' }); for (var j=1;j<=Mod.Constants.languages;j++){ if (Mod.Constants.languages==1){ st="Description" }else{ st="Description for Lang. "+j } Me.Settings.push({ name: Me.SS.format(i,j), label:st, type: 'str', required: (j==1), defaultValue:'' }); } cb.settings_choices = cb.settings_choices.concat(Me.Settings); } }, parseOptions(){ var Me=M.languages.params for (var i=1;i<=Mod.Constants.goals;i++){ var g = new goal(Me,i) if (g.available==true){ goals.goals.push(g) } } Me.Sentences=new Sentences("Goal_") } } class goal{ constructor(Params,Index){ this.Params={ SA:Params.SA, SE:Params.SE, SS:Params.SS, I:Index, A:false, Amount:0, Emoji:undefined, } this.parseOptions() } parseOptions(){ this.Params.Amount=parseInt(cb.settings[String(this.Params.SA).format(this.Params.I)]) this.Params.Emoji=new Emojis(cb.settings[String(this.Params.SE).format(this.Params.I)]) } get Index(){return this.Params.I} get Amount(){return this.Params.Amount} get Emojis(){return this.Params.Emojis} //Goals:[], //settings:{}, //innit(){ // var Me=goals //for (var i=2;i<=Mod.Constants.languages;i++){ // var st="" // if (i==2){ // st+= Me.S+"-> Lang. "+i // }else{ // st="-> Lang. "+i // } // Me.Settings.push({ // name: Me.I(i), // label:st, // type: 'str', // minLength: 0, // maxLength: 255, // required: false, // defaultValue:'' // }); //} //cb.settings_choices = cb.settings_choices.concat(Me.Settings); //}, //parseOptions(){ // //} } var Ext={ ext:[ goals ], parseOptions(){ for (var i=0;i<Ext.ext.length;i++){ Ext.ext[i].parseOptions() } }, innit(){ for (var i=0;i<Ext.ext.length;i++){ Ext.ext[i].innit() } } } cb.onTip(function (tip) { M.utilisateurs.onTip(tip) }); cb.onEnter(function (user) { M.utilisateurs.onEnter(user) }); cb.onLeave(function (user) { M.utilisateurs.onLeave(user) }); cb.onMessage(function (msg) { //var msgString = msg['m'].trim(); msg['m']=msg['m'].trim();// chaine de message sans les espaces avant et apres M.utilisateurs.onMessage(msg) var u = utilisateur.Get(msg.user) var messages = msg['m'].split(' '); // un tableau de tous les messages if (messages[0].substring(0,1)=="/"){ msg['X-Spam'] =true messages[0]=messages[0].substring(1) if (messages[0]=="help"){ if (u.isSuperUtilisateur){ if (messages.length==1){ output="### HELP COMMAND LINE EXTENTIONS".p(Colours.DarkBlue,Colours.LightGrey,'bolder') output+=". . 1 -> /help -u => display only the users command line.".p(Colours.Blue,undefined,'bold') output+=". . 2 -> /help -l => display only the language command line.".p(Colours.Blue,undefined,'bold') output+=u.buildHelp(messages,u) output+=language.buildHelp(messages,u) }else{ if(messages[1]=="-u"){ output=u.buildHelp(messages,u) } if(messages[1]=="-l"){ output=language.buildHelp(messages,u) } } }else{ if (messages.length==1){ output="### HELP COMMAND LINE EXTENTIONS".p(Colours.DarkBlue,Colours.LightGrey,'bolder') output+=". . 1 -> /help -l => display only the language command line.".p(Colours.Blue,undefined,'bold') output+=language.buildHelp(messages,u) }else{ if(messages[1]=="-l"){ output=language.buildHelp(messages,u) } } } }else{ var output="" messages[0]="/"+messages[0] u.onMessage(messages,u) messages[0]="/"+messages[0] language.onMessage(messages,u) } if (output!=""){u.Messages.sendToUser(output)} } if (msg['X-Spam'] ==false){return msg;} }); function innit() { M.innit() Ext.innit() } function parseOptions(){ Mod.StartupTime=new Date(); M.parseOptions() Ext.parseOptions() } innit() if (!Mod.Debug || (Mod.Debug && cb.room_slug == Mod.Author)) { parseOptions(); } else { }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.