Apps Home
|
Create an App
canitestapp
Author:
canigetatest
Description
Source Code
Launch App
Current Users
Created by:
Canigetatest
!function(t){var e={};function s(i){if(e[i])return e[i].exports;var a=e[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,s),a.l=!0,a.exports}s.m=t,s.c=e,s.d=function(t,e,i){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)s.d(i,a,function(e){return t[e]}.bind(null,a));return i},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=16)}([function(t,e,s){e.app=s(7),e.bot=s(2),e.constants=s(1),e.message=s(4),e.user=s(3),e.pluginAbstract=s(6),e.pluginHelp=s(5)},function(t,e){t.exports={chars:{hearts:":heart2",hearts2:":Hearts2",glitter:":pixelglitter",flowers:":tinyflower2",bow:":bluebow",smiley:":smile",text_queen:String.fromCodePoint(9813),text_queen_full:String.fromCodePoint(9819),text_heart:String.fromCodePoint(9829),text_diamond:String.fromCodePoint(9830),text_star:String.fromCodePoint(9733),text_star_pointed:String.fromCodePoint(10022),text_right:String.fromCodePoint(9658),text_left:String.fromCodePoint(9664),text_right_small:String.fromCodePoint(9656),text_left_small:String.fromCodePoint(9666),text_stopwatch:String.fromCodePoint(9200),text_clock:String.fromCodePoint(9201),text_hourglass:String.fromCodePoint(8987),text_hourglass_flowing:String.fromCodePoint(9203),text_dotted_line:String.fromCodePoint(10649)},colors:{black:"#000",white:"#fff",cream:"#f9f6ed",fan_green:"#e6f9e6",mod_red:"#ffe7e7",help:"#06140d",help_bg:"#f2ffe6",tipnote_yellow:"#ffff00",legend_purple:"#e8f4f8",legend_green:"#f3ecf9",timer_blue:"#add8e6",timer_magenta:"#ffa6ff",light_grey:"#e6e6e6",grey:"#aaa",dark_grey:"#333",light_aqua:"#adeaea",dark_aqua:"#006767",light_red:"#ff9a9a",red:"#f4c1bc",dark_red:"#cc0000",light_orange:"#ffd9b3",orange:"#F65F00",dark_orange:"#e77400",light_yellow:"#ffff94",yellow:"#f4d599",dark_yellow:"#E6D200",light_green:"#94e594",green:"#00B300",dark_green:"#006600",light_blue:"#d1eaee",blue:"#0099ff",dark_blue:"#0629AC",light_purple:"#f2cdff",purple:"#e2a2ea",dark_purple:"#3d003d",light_pink:"#FFE6EA",pink:"#FF00EE",dark_pink:"#FF6680"}}},function(t,e,s){"use strict";let i=s(8),a=s(10),n=s(15),r=s(5);t.exports=class{constructor(t){this.api=t,this.methods=["onEnter","onMessage","onTip","onLeave"],this.commands=new a(this.api),this.settings=new n(this.api),this.plugins=[],this.help=new r,this.register(this.help),this.callPlugins=function(t,e){let s,i;for(s in this.plugins)i=this.plugins[s],"function"==typeof i[t]&&i[t].apply(i,e)}}run(){this.help.discover(this.plugins),this.api.settings_choices=this.settings.fetch(),new i(this.api).initialise(this.methods,this)}register(t){return"function"==typeof t.setDependencies&&t.setDependencies(this.api),this.commands.register(t),this.settings.register(t),this.plugins.push(t),this}onStart(t){this.callPlugins.call(this,"onStart",[t])}onEnter(t){this.callPlugins.call(this,"onEnter",[t])}onMessage(t,e){return e.isCommand()?(e.hide(),this.commands.handle(t,e)):this.callPlugins.call(this,"onMessage",[t,e]),e.getResponse()}onTip(t,e,s,i){this.callPlugins.call(this,"onTip",[t,e,s,i])}onLeave(t){this.callPlugins.call(this,"onLeave",[t])}}},function(t,e,s){"use strict";class i{constructor(t,e,s,i,a,n,r){this.name=t,this.gender=e,this.isHost=!!s,this.isMod=!!i,this.isFan=!!a,this.isAnon=!!n,this.tippedRecently=!!r,this.isSilenced=!1}static createFromMessage(t,e){return new i(t.user,t.gender,t.user===e,t.is_mod,t.in_fanclub,!1,t.tipped_recently)}static createFromTip(t,e){return new i(t.from_user,t.from_user_gender,!1,t.from_user_is_mod,t.from_user_in_fanclub,t.is_anon_tip,t.from_user_tipped_recently)}static createFromUsername(t,e){return new i(t,!1,!1,t===e,!1,!1,!1)}silence(){this.isSilenced=!0}unsilence(){this.isSilenced=!1}hasPermission(t){return void 0===t||t.constructor===Array&&t.indexOf(this.getRole())>-1}getRole(){switch(!0){case this.isHost:return"host";case this.isMod:return"mod";case this.isFan:return"fan";default:return}}addRole(t){switch(t){case"mod":this.isMod=!0;break;case"fan":this.isFan=!0}return this}removeRole(t){switch(t){case"mod":this.isMod=!1;break;case"fan":this.isFan=!1}return this}}t.exports=i},function(t,e,s){"use strict";let i=function(t){-1==t.indexOf(" ")&&(t+=" ");let e=t.split(" ");return[e[0].substring(1).trim(),e.slice(1).join(" ").trim()]};class a{constructor(t,e,s){this.message=t.trim(),this.user=e,this.response=s,this.command=null,this.parsed=null}static create(t,e){return new a("","",e)}static createFromTip(t,e){return new a(t.message,e)}isEmpty(){return""===this.message}isCommand(){return"/"===this.message.charAt(0)}getCommand(){return this.isCommand()&&null===this.command&&(this.command=i(this.message)[0]),this.command}getCommandParameters(t){if(null===this.parsed){let t=i(this.message)[1];this.parsed=t}return this.parsed}isHidden(){return!0===this.response["X-Spam"]}hide(){return this.response["X-Spam"]=!0,this}show(){return this.response.hasOwnProperty("X-Spam")&&delete this.response["X-Spam"],this}setMessage(t){this.message=t,this.response.m=t}setBackground(t){this.response.background=t}getUser(){return this.user}getResponse(){return this.response}}t.exports=a},function(t,e,s){"use strict";var i=s(6),a=s(1);t.exports=class extends i{constructor(){super(),this.name="Help",this.commands={help:{scope:this,handler:this.displayHelp}},this.descriptions=[],this.app=!1}setApp(t){this.app=!!t}discover(t){for(let e in t)t[e].commands&&this.iterateCommands(t[e].commands)}iterateCommands(t){var e;for(e in t)t.hasOwnProperty(e)&&this.appendHelpMessage(e,t[e])}appendHelpMessage(t,e){e.description&&this.descriptions.push({message:`/${t}: ${e.description}`,access:e.access})}displayHelp(t,e){var s,i,n=[];for(s in this.descriptions)i=this.descriptions[s],t.hasPermission(i.access)&&n.push(i.message);n.length<1||this.api.sendNotice(n.join("\n"),t.name,a.colors.help_bg,a.colors.help,"bold")}}},function(t,e,s){"use strict";t.exports=class{constructor(){this.api=null,this.name="",this.settings=[],this.commands={}}setDependencies(t){this.api=t}getStatus(){return this.name+" - Available commands:"}}},function(t,e,s){"use strict";let i=s(2);t.exports=class extends i{constructor(t){super(t),this.methods.push("onDrawPanel")}onDrawPanel(t,e){return this.callPlugins.call(this,"onDrawPanel",[t,e]),e.getResponse()}}},function(t,e,s){"use strict";let i=s(3),a=s(9),n=s(4);t.exports=class{constructor(t){this.api=t,this.intercepts={}}initialise(t,e){for(let s in t){let i=t[s],a=e[i];"function"==typeof a&&this.api[i](this.proxy(i,e,a))}let s=i.createFromUsername(this.api.room_slug,this.api.room_slug);e.onStart(s)}proxy(t,e,s){return this[t]?function(){let i=this[t].apply(this,arguments);return"function"==typeof this.intercepts[t]&&(s=this.intercepts[t].apply(e,[s].concat(i))),s.apply(e,i)}.bind(this):function(){return this.api.log("Proxied "+t),s.apply(e,arguments)}}onEnter(t){return[i.createFromMessage(t,this.api.room_slug)]}onMessage(t){let e=i.createFromMessage(t,this.api.room_slug);return[e,new n(t.m,e,t)]}onTip(t){let e=i.createFromTip(t,this.api.room_slug),s=i.createFromUsername(t.to_user,this.api.room_slug),a=n.createFromTip(t,e);return[e,s,Number.parseInt(t.amount,10),a]}onLeave(t){return[i.createFromMessage(t,this.api.room_slug)]}onDrawPanel(t){let e=i.createFromMessage(t,this.api.room_slug);return[e,new a(e)]}}},function(t,e,s){"use strict";t.exports=class{constructor(t){this.user=t,this.templates=["3_rows_of_labels","3_rows_11_21_31","3_rows_12_21_31","3_rows_12_22_31","image_template"],this.response={template:this.templates[0],row1_label:"",row1_value:"",row2_label:"",row2_value:"",row3_label:"",row3_value:""}}setPanel(t){this.response=t}getResponse(){return this.response}}},function(t,e,s){"use strict";let i=s(1),a=s(11),n=s(12),r=s(13);t.exports=class{constructor(t){this.api=t,this.commands={},this.subcommands={}}register(t){if(!t.commands)return this;for(let e in t.commands){if(this.commands.hasOwnProperty(e))throw new a("Specified command '"+e+"' conflicts with an existing command.");if(t.commands[e].scope||(t.commands[e].scope=t),this.commands[e]=t.commands[e],this.subcommands[e]={command_names:[],handlers:{},help:[]},t.commands[e].hasOwnProperty("subcommands"))for(let s of t.commands[e].subcommands){this.subcommands[e].help.push(`${s.names.join("|")} : ${s.description}`);for(let t of s.names)this.subcommands[e].command_names.push(t),Object.assign(this.subcommands[e].handlers,{[t]:{handler:s.handler,success:s.success}})}}return this}handle(t,e){try{let s=e.getCommand(),a=s;if(!this.commands[s])return e.getResponse();if(s=this.commands[s],s.access&&!t.hasPermission(s.access))throw new r("You do not have permission to use that command");let o=[];s.params&&(o=e.getCommandParameters(s.params));let l=!0;if(s.hasOwnProperty("subcommands")){o=o.split(" ");let e=o.shift();""===e?this.api.sendNotice(("function"==typeof s.scope.getStatus?s.scope.getStatus()+"\n":"")+this.subcommands[a].help.join("\n"),t.name,i.colors.help_bg,i.colors.help,"bold"):this.subcommands[a].command_names.includes(e)&&"function"==typeof this.subcommands[a].handlers[e].handler?(l=this.subcommands[a].handlers[e].handler.apply(s.scope,[t,o]),void 0!==l&&!0!==l||this.api.sendNotice(this.subcommands[a].handlers[e].success,t.name,i.colors.light_green,i.colors.dark_green,"bold")):this.api.sendNotice("Command not implemented...",t.name,i.colors.light_yellow)}else l=s.handler.apply(s.scope,[t].concat(o));if(void 0!==l&&!0!==l)throw new n("Failed: "+l)}catch(e){this.api.sendNotice(e.toString(),t.name,i.colors.light_red,i.colors.black,"bold")}finally{return e.getResponse()}}}},function(t,e,s){"use strict";class i extends Error{}t.exports=i},function(t,e,s){"use strict";class i extends Error{}t.exports=i},function(t,e,s){"use strict";var i=s(14);t.exports=class extends i{}},function(t,e,s){"use strict";class i extends Error{}t.exports=i},function(t,e,s){"use strict";t.exports=class{constructor(t){this.api=t,this.settings=[]}register(t){let e=t.settings;if(!e||e.constructor!==Array||0===e.length)return this;this.settings.push({name:"settings_"+t.name.replace(/\s+/g,"")+"_header",type:"choice",required:!1,label:":".repeat(20)+" "+t.name.toUpperCase()+" "+":".repeat(20)});for(let t=0;t<e.length;t++)this.settings.push(e[t]);return this}fetch(){return this.settings}}},function(t,e,s){let i=s(0).app,a=s(17),n=s(18),r=new i(cb);r.register(new a),r.register(new n),r.run()},function(t,e,s){let i=s(0).constants,a=s(0).pluginAbstract;t.exports=class extends a{constructor(){super(),this.name="Goals",this.total=10,this.settings=[{type:"choice",name:"goals_enable",label:"Enable or disable goals",choice1:"Disable",choice2:"Enable",defaultValue:"Disable"},{type:"choice",name:"goals_next",label:"Automatic next goal",choice1:"Disable",choice2:"Enable",defaultValue:"Disable"},{type:"choice",name:"goals_type",label:"Goal type",choice1:"Tokens",choice2:"Tippers",defaultValue:"Tokens"},{type:"int",name:"goals_timer",label:"Goal timer (in minutes, 0 to disable)",minValue:0,maxValue:120,defaultValue:0},{type:"int",name:"goals_interval",label:"Display interval of notice (in minutes, 0 to disable)",minValue:0,maxValue:120,defaultValue:3},{type:"str",name:"goals_notice_color",label:"Goal notice text color (hex)",defaultValue:i.colors.dark_green},{type:"str",name:"goals_notice_bg",label:"Goal notice background color (hex)",defaultValue:i.colors.white},{type:"str",name:"goals_color",label:"Goal reached text color (hex)",defaultValue:i.colors.dark_green},{type:"str",name:"goals_bg",label:"Goal reached background color (hex)",defaultValue:i.colors.white}];for(let t=0;t<this.total;t++){let e={type:"str",name:"goal_"+(t+1),label:"Goal #"+(t+1),required:!1,defaultValue:0===t?"123, goal name":""};this.settings.push(e)}this.commands={goals:{access:["host","mod"],handler:this.goals,description:"Do goals stuff",params:/(.+)/,subcommands:[{names:["start","on"],description:'Start goals with "/goals start" or "/goals on"',handler:this.enable,success:"Goals started."},{names:["stop","off"],description:'Stop goals with "/goals stop" or "/goals off"',handler:this.disable,success:"Goals stopped."},{names:["next"],description:'Move to next goal with "/goals next"',handler:this.nextGoal,success:"Goals moved to next."},{names:["auto"],description:'Toggle automatic next goal with "/goals auto on" and "/goals auto off"',handler:this.autoGoal,success:"Automatic next goal updated."},{names:["timer"],description:'Edit goal timer with "/goals timer 15"',handler:this.updateTimer,success:"Goal timer updated."},{names:["type"],description:'Set goal type with "/goals type tokens", "/goals type tippers"',handler:this.goalType,success:"Goal type updated."},{names:["reset"],description:'Reset goals to default settings with "/goals reset"',handler:this.initGoals,success:"Goals reset to default settings."},{names:["list","show"],description:'List goals with "/goals list" or "/goals show"',handler:this.showGoals,success:"Goals listed."},{names:["set","update"],description:'Update a later goal with "/goals set 3 1999 hot dance"',handler:this.updateGoal,success:"Goal updated."},{names:["remove","rm","del"],description:'Remove a goal with "/goals remove 2"',handler:this.removeGoal,success:"Goal removed."},{names:["add"],description:'Add goal with "/goals add 1999 dance"',handler:this.addGoal,success:"Goal added."},{names:["edit","change"],description:'Edit current goal with "/goals edit new dance"',handler:this.editGoal,success:"Goal modified."},{names:["remain","left"],description:'Edit current goal\'s remaining total with "/goals left 999"',handler:this.remainingGoal,success:"Goal remaining modified."},{names:["total"],description:'Edit current goal total with "/goals total 2999"',handler:this.totalGoal,success:"Goal total modified."},{names:["interval"],description:'Set notice interval in minutes with "/goals interval 3"',handler:this.setInterval,success:"Goal notice interval set."}]}},Object.assign(this.commands,{goal:{access:["host","mod"],handler:this.goals,description:"Alias for /goals",params:/(.+)/,subcommands:this.commands.goals.subcommands},subject:{access:["host"],handler:this.subject,description:"Change room subject",params:/(.+)/}}),this.panel={template:"3_rows_11_21_31",row1_value:"Goal: chill",row2_value:"Tokens left: 0",row3_value:"Last: -"},this.next=0,this.items=[],this.types=["tokens","tippers"],this.timer=0,this.time_left=0,this.goals_timer=0,this.current="",this.current_type=0,this.current_left=0,this.current_total=0,this.autonext=!1,this.tippers=[],this.last_tipper="-",this.enabled=!0,this.interval=18e4}isStopped(){return!this.enabled||0===this.current_left||0===this.current_total||""===this.current}enable(){this.enabled=!0,this.time_left>0&&this.timerInterval(),this.api.drawPanel()}disable(){this.enabled=!1,this.timer&&this.api.cancelTimeout(this.timer),this.api.drawPanel()}setInterval(t,e){this.interval=6e4*Number.parseInt(e.join(""),10)}noticeInterval(){this.isStopped()||(this.showGoal(),this.api.setTimeout(function(){this.noticeInterval()}.bind(this),this.interval))}updateTimer(t,e){let s=Number.parseInt(e.join(""),10);this.goals_timer=s,this.time_left=s?s+1:0,this.enabled&&0===this.time_left&&this.api.drawPanel(),this.timerInterval()}timerInterval(){!this.isStopped()&&this.time_left&&(this.time_left-=1,0===this.time_left?(this.api.sendNotice(i.chars.text_hourglass+" Time's up! "+i.chars.text_hourglass,"",i.colors.white,i.colors.dark_red,"bold"),this.autonext&&this.nextGoal()):this.time_left<=5&&this.api.sendNotice(`${i.chars.text_hourglass_flowing} There is ${this.time_left} minute${this.time_left>1?"s":""} left to the timer!`,"",i.colors.white,i.colors.dark_orange,"bold"),this.api.drawPanel(),this.timer&&this.api.cancelTimeout(this.timer),this.timer=this.api.setTimeout(function(){this.timerInterval()}.bind(this),6e4))}initGoals(){let t=[];for(let e=0;e<this.total;e++){let s=this.api.settings["goal_"+(e+1)];if(!s)continue;s=s.split(",");let i=Number.parseInt(s.shift().trim(),10),a=s.join(" ").trim();a&&i&&t.push({name:a,total:i})}this.items=t,this.items.length>0&&(this.current=this.items[0].name,this.current_total=this.items[0].total,this.current_left=this.current_total),this.api.drawPanel()}showGoal(t){let e=t?t.name:"",s=`Goal: ${this.current} with ${this.current_left} ${this.types[this.current_type]}`;this.timer&&(s+=` and ${i.chars.text_hourglass_flowing} ${this.time_left} minute${this.time_left>1?"s":""}`),s+=" left",this.api.sendNotice(s,e,this.api.settings.goals_notice_bg,this.api.settings.goals_notice_color,"bold")}showGoals(t,e){let s=[];for(let t=0;t<this.items.length;t++)s.push("Goal #"+(t+1)+" - "+this.items[t].name+" @ "+this.items[t].total+" "+this.types[this.current_type]);1===this.current_type&&s.push("Tippers: "+this.tippers.join(", ")),this.api.sendNotice(s.join("\n"),t.name,i.colors.white,i.colors.dark_green,"bold")}autoGoal(t,e){this.autonext="on"===e.join("").toLowerCase()}goalType(t,e){"tippers"===e.join("").toLowerCase()?(0===this.current_type&&(this.tippers=[]),this.current_type=1):this.current_type=0,this.api.drawPanel()}updateGoal(t,e){let s=Number.parseInt(e.shift(),10),i=Number.parseInt(e.shift(),10),a=e.join(" "),n=', list goals with "/goal list" then update a goal with "/goal set 2 3999 hot dance"';return s>this.items.length?`Goal #${s} does not exist, list goals with "/goal list" then update a goal with "/goal set 2 3999 hot dance"`:Number.isNaN(i)?"Invalid total"+n:(1===s&&(this.current=a),this.items[s-1].name=a,this.items[s-1].total=i,void(this.enabled&&this.api.drawPanel()))}addGoal(t,e){let s=Number.parseInt(e.shift(),10),i=e.join(" "),a=', add a goal with "/goal add 1999 dance"';return Number.isNaN(s)?"Invalid total"+a:""===i?"Invalid goal name"+a:(this.items.push({name:i,total:s}),void(1===this.items.length&&this.nextGoal(t)))}editGoal(t,e){let s=e.join(" ");this.current=s,this.items.length>0&&(this.items[0].name=s),this.enabled&&this.api.drawPanel()}totalGoal(t,e){let s=Number.parseInt(e.shift(),10);if(Number.isNaN(s))return"Invalid amount, set it with /goal total 1999";this.current_total=s,this.items.length>0&&(this.items[0].total=s),s<this.current_left&&(this.current_left=s),this.enabled&&this.api.drawPanel()}remainingGoal(t,e){let s=Number.parseInt(e.shift(),10);if(Number.isNaN(s))return"Invalid amount left, set it with /goal left 1499";this.current_left=s,this.enabled&&this.api.drawPanel()}nextGoal(t){if(this.items.length<1)return'No goal left, add a goal with "/goal add 1999 dance"';this.items.length>1&&this.items.shift(),this.current=this.items[0].name,this.current_total=this.items[0].total,this.current_left=this.current_total,this.goals_timer&&(this.time_left=this.goals_timer+1,this.timerInterval()),this.enabled&&(this.showGoal(),this.api.drawPanel())}removeGoal(t,e){let s=Number.parseInt(e,10);if(Number.isNaN(s)||s>this.items.length)return`Goal #${s} does not exist.`;this.items.splice(s-1,1)}onStart(){"Enable"!==this.api.settings.goals_enable&&(this.enabled=!1),this.initGoals(),"Enable"===this.api.settings.goals_next&&(this.autonext=!0),"Tippers"===this.api.settings.goals_type&&(this.current_type=1);let t=Number.parseInt(this.api.settings.goals_timer,10);t>0&&(this.goals_timer=t,this.time_left=t+1,this.isStopped()||this.timerInterval()),this.interval=6e4*Number.parseInt(this.api.settings.goals_interval,10),this.interval>0&&this.noticeInterval(),this.api.log("Goals started.")}onTip(t,e,s,i){if(this.isStopped())return;let a=s;if(1===this.current_type){if(s=1,this.tippers.includes(t.name))return;this.tippers.push(t.name)}if(s>=this.current_left)if(this.api.sendNotice(`Goal reached! ${this.current} will start soon.`,"",this.api.settings.goals_bg,this.api.settings.goals_color,"bold"),this.autonext&&this.items.length>1){let t=this.current_left;this.nextGoal(),this.current_left=this.current_total-(s-t)}else this.current=this.current+" (reached)",this.current_left=0,this.time_left=0,this.timer&&this.api.cancelTimeout(this.timer);else this.current_left-=s;this.last_tipper=(t.isAnon?"Anonymous tip":t.name)+" ("+a+")",this.api.drawPanel()}onEnter(t){this.enabled&&""!==this.current&&0!==this.current_total&&0!==this.interval&&this.showGoal(t)}getStatus(){return`${this.name} (${this.types[this.current_type]}): ${this.enabled?"[ running ]":"[ stopped ]"} Notice every ${this.interval/6e4} minute${this.interval>1?"s":""} - Auto-next: ${this.autonext?"[ on ]":"[ off ]"} - Available commands:`}subject(t,e){this.api.changeRoomSubject(e.trim())}onDrawPanel(t,e){if(this.enabled&&""!==this.current){let t="Tokens",s=this.current_left,i="";return 1===this.current_type&&(t="Tippers"),this.time_left&&(i=this.time_left+" minute"+(this.time_left>1?"s":"")+" left"),e.setPanel({template:"3_rows_11_21_31",row1_value:"Goal: "+this.current,row2_value:t+" left: "+s,row3_value:i}),e.getResponse()}}}},function(t,e,s){let i=s(0).constants,a=s(0).pluginAbstract;t.exports=class extends a{constructor(){super(),this.name="Ticket show",this.settings=[{type:"choice",name:"tickets_enable",label:"Enable or disable ticket show on launch",choice1:"Disable",choice2:"Enable",defaultValue:"Disable"},{type:"int",name:"tickets_interval",label:"Display interval of notice (in minutes, 0 to disable)",minValue:0,maxValue:120,defaultValue:3},{type:"int",name:"tickets_price",label:"Ticket price",minValue:0,maxValue:1e5,defaultValue:250},{type:"int",name:"tickets_fan_price",label:"Ticket price for fanclub (0 to disable)",minValue:0,maxValue:1e5,defaultValue:0,required:!1},{type:"int",name:"tickets_timer",label:"Ticket sales timer (in minutes, 0 to disable)",minValue:0,maxValue:1e5,defaultValue:0,required:!1},{type:"str",name:"tickets_name",label:"Ticket show name",defaultValue:"",required:!1},{type:"str",name:"tickets_notice_color",label:"Ticket sales notice text color (hex)",defaultValue:i.colors.dark_green},{type:"str",name:"tickets_notice_bg",label:"Ticket sales notice background color (hex)",defaultValue:i.colors.white},{type:"str",name:"tickets_color",label:"Ticket show welcome text color (hex)",defaultValue:i.colors.dark_green},{type:"str",name:"tickets_bg",label:"Ticket show welcome background color (hex)",defaultValue:i.colors.white}],this.commands={tickets:{access:["host","mod"],handler:this.tickets,description:"Do tickets stuff",params:/(.+)/,subcommands:[{names:["start","on"],description:'Start ticket sales with "/tickets on", with optional price "/tickets on 250" or time "/tickets on 250 15"',handler:this.enable,success:"Ticket sales started."},{names:["stop","off"],description:'Stop ticket sales with "/tickets stop" or "/tickets off"',handler:this.disable,success:"Ticket sales stopped."},{names:["name","edit"],description:'Edit ticket show name with "/tickets name New show name"',handler:this.updateName,success:"Ticket show name updated."},{names:["price"],description:'Edit ticket price with "/tickets price 250"',handler:this.updatePrice,success:"Ticket show price updated."},{names:["timer"],description:'Edit ticket show timer with "/tickets timer 15"',handler:this.updateTimer,success:"Ticket show timer updated."},{names:["show"],description:'Start or stop the ticket show with "/tickets show start" and "/tickets show stop"',handler:this.toggleShow,success:"Ticket show status updated."},{names:["sales","sale"],description:'Display "Ticket sales is over" message with "/tickets sales stop", hide with "/tickets sales start"',handler:this.toggleSales,success:"Ticket sales message updated."},{names:["add"],description:'Add a user to the ticket show with "/tickets add username"',handler:this.addUser,success:"User added."},{names:["remove","rm","del"],description:'Remove a user from the ticket show with "/tickets remove username"',handler:this.removeUser,success:"User removed."},{names:["clear"],description:'Remove all users from the ticket show with "/tickets clear"',handler:this.removeAllUsers,success:"All users removed."},{names:["list"],description:'List ticket holders with "/tickets list"',handler:this.listHolders,success:"Ticket holders listed."},{names:["legends"],description:'Add legends to the ticket show with "/tickets legends"',handler:this.addLegends,success:"Legends added."},{names:["interval"],description:'Set notice interval in minutes with "/tickets interval 3"',handler:this.setInterval,success:"Ticket sales notice interval set."}]}},Object.assign(this.commands,{ticket:{access:["host","mod"],handler:this.tickets,description:"Alias for /tickets",params:/(.+)/,subcommands:this.commands.tickets.subcommands},timer:{access:["host","mod"],handler:this.timer,description:"Alias for /tickets timer",params:/(.+)/},show:{access:["host","mod"],handler:this.show,description:"Alias for /tickets show",params:/(.+)/},add:{access:["host","mod"],handler:this.add,description:"Alias for /tickets add",params:/(.+)/}}),this.totals={},this.since_started={},this.show_name="",this.show_price=0,this.fan_price=0,this.time_left=0,this.over=!1,this.elapsed="",this.started=null,this.timer=0,this.enabled=!1,this.interval=18e4,this.legends_minimum=1e3}enable(t,e){let s=this.show_price,i=this.time_left;e.length>0&&(s=Number.parseInt(e[0],10)),Number.isNaN(s)?s=this.show_price:e.shift(),e.length>0&&(i=Number.parseInt(e[0],10)),Number.isNaN(i)?i=this.time_left:e.shift(),e.length>0&&(this.show_name=e.join(" ")),this.time_left=i?i+1:0,this.show_price=s,this.enabled=!0,this.over=!1,this.addLegends(),this.time_left>0&&this.timerInterval(),this.api.drawPanel()}disable(t){this.time_left=0,this.show_name="",this.enabled=!1,this.api.limitCam_isRunning()&&this.api.sendNotice('Warning! Ticket show is still running, stop the ticket show with "/ticket show stop"',t.name,i.colors.light_yellow),this.timer&&this.api.cancelTimeout(this.timer),this.api.drawPanel()}setInterval(t,e){this.interval=6e4*Number.parseInt(e.join(""),10)}noticeInterval(){this.enabled&&0!==this.show_price&&0!==this.interval&&(this.showNotice(),this.api.setTimeout(function(){this.noticeInterval()}.bind(this),this.interval))}showNotice(t){let e=t?t.name:"";this.api.sendNotice(`Ticket show${this.show_name?": "+this.show_name:""} for ${this.show_price} tokens`,e,this.api.settings.tickets_notice_bg,this.api.settings.tickets_notice_color,"bold")}updateName(t,e){this.show_name=e.join(" "),this.enabled&&this.api.drawPanel()}updatePrice(t,e){this.show_price=Number.parseInt(e,10),this.enabled&&this.api.drawPanel()}updateTimer(t,e){let s=Number.parseInt(e.join(""),10);this.time_left=s?s+1:0,this.enabled&&0===this.time_left&&this.api.drawPanel(),this.timerInterval()}timerInterval(){this.enabled&&this.show_price&&this.time_left&&(this.time_left-=1,0===this.time_left?this.api.sendNotice(i.chars.text_hourglass+" Ticket show is about to start!"+i.chars.text_hourglass,"",i.colors.white,i.colors.dark_red,"bold"):this.time_left<=5&&this.api.sendNotice(i.chars.text_hourglass_flowing+" There is "+this.time_left+" minute"+(this.time_left>1?"s":"")+" left to the timer!","",i.colors.white,i.colors.dark_orange,"bold"),this.api.drawPanel(),this.timer&&this.api.cancelTimeout(this.timer),this.timer=this.api.setTimeout(function(){this.timerInterval()}.bind(this),6e4))}elapsedInterval(){this.enabled&&null!==this.started&&(this.setElapsed(),this.api.drawPanel(),this.api.setTimeout(function(){this.elapsedInterval()}.bind(this),5e3))}setElapsed(){if(null!==this.started){let t=new Date(Date.now()-this.started),e=t.getUTCHours(),s=t.getUTCMinutes(),i=t.getUTCSeconds();i<10&&(i="0"+i),e>0&&s<10&&(s="0"+s),this.elapsed=(e>0?e+":":"")+s+":"+i}}listHolders(t){this.api.sendNotice(this.api.limitCam_allUsersWithAccess().join(", "),t.name,i.colors.light_pink)}toggleShow(t,e){switch(e.join("").trim()){case"start":case"on":this.enabled||this.enable(t,[this.show_price,0,this.show_name]),this.api.limitCam_start(`Ticket show is starting! There is still time to buy your ticket for ${this.show_price} tokens`),this.started=Date.now(),this.elapsedInterval(),this.time_left=0,this.timer&&this.api.cancelTimeout(this.timer),this.api.drawPanel();break;case"stop":case"off":this.api.limitCam_stop(),this.setElapsed(),this.disable(t),null!==this.started&&(this.started=null),this.since_started={}}}toggleSales(t,e){switch(e.join("").trim()){case"over":case"stop":case"off":this.over=!0;break;default:this.over=!1}this.api.drawPanel()}addLegends(){let t=[];for(let e of Object.keys(this.totals))this.totals[e]>=this.legends_minimum&&!this.api.limitCam_userHasAccess(e)&&(t.push(e),this.api.sendNotice(`Welcome to the ticket show, legendary ${e}! (sent privately)`,e,this.api.settings.tickets_bg,this.api.settings.tickets_color,"bold"));this.api.limitCam_addUsers(t)}addUser(t,e){this.api.limitCam_addUsers(e)}removeUser(t,e){this.api.limitCam_removeUsers(e)}removeAllUsers(t,e){this.api.limitCam_removeAllUsers()}onStart(t){this.fan_price=Number.parseInt(this.api.settings.tickets_fan_price,10),"Enable"===this.api.settings.tickets_enable?this.enable(t,[this.api.settings.tickets_price,this.api.settings.tickets_timer,this.api.settings.tickets_name]):(this.show_price=Number.parseInt(this.api.settings.tickets_price,10),this.time_left=Number.parseInt(this.api.settings.tickets_timer,10),this.show_name=this.api.settings.tickets_name),this.interval=6e4*Number.parseInt(this.api.settings.tickets_interval,10),this.interval>0&&this.noticeInterval(),this.api.log("Tickets started.")}onTip(t,e,s,a){let n=0;if(this.totals.hasOwnProperty(t.name)?(n=this.totals[t.name],this.totals[t.name]+=s):Object.assign(this.totals,{[t.name]:s}),!this.enabled||0===this.show_price||this.api.limitCam_userHasAccess(t.name))return;let r=0;this.since_started.hasOwnProperty(t.name)?(r=this.since_started[t.name],this.since_started[t.name]+=s):Object.assign(this.since_started,{[t.name]:s}),(r<this.show_price&&this.since_started[t.name]>=this.show_price||this.fan_price&&t.isFan&&r<this.fan_price&&this.since_started[t.name]>=this.fan_price||n<this.legends_minimum&&this.totals[t.name]>=this.legends_minimum)&&(this.api.limitCam_addUsers([t.name]),this.over?this.api.sendNotice("You were added to the show, however, please keep in mind that ticket sales had ended earlier. (sent privately)",t.name,i.colors.yellow,i.colors.black,"bold"):this.api.sendNotice(`Welcome to the ticket show, ${t.name}!${t.isAnon?" (sent privately)":""}`,t.isAnon?t.name:"",this.api.settings.tickets_bg,this.api.settings.tickets_color,"bold"))}onEnter(t){this.enabled&&""!==this.current&&0!==this.current_total&&this.showNotice(t)}onMessage(t,e){this.enabled&&this.api.limitCam_userHasAccess(t.name)&&e.setBackground(i.colors.light_pink)}getStatus(){return`${this.name}: ${this.api.limitCam_isRunning()?"SHOW":"SALES"} ${this.enabled?"[ running ]":"[ stopped ]"} Notice every ${this.interval/6e4} minute${this.interval>1?"s":""} - Available commands:`}timer(t,e){e=e.trim().split(" "),this.updateTimer(t,e),this.api.sendNotice("Timer updated",t.name,i.colors.light_green)}show(t,e){e=e.trim().split(" "),this.toggleShow(t,e),this.api.sendNotice("Show status updated",t.name,i.colors.light_green)}add(t,e){e=e.trim().split(" "),this.addUser(t,e),this.api.sendNotice("User added",t.name,i.colors.light_green)}onDrawPanel(t,e){if(this.enabled){let t="Hidden show",s=this.show_price&&!this.over?"Tip "+this.show_price+" to watch":"Ticket sales is over",i=this.time_left?"Time left: "+this.time_left+" minute"+(this.time_left>1?"s":""):"";return this.show_name&&(t+=": "+this.show_name),this.api.limitCam_isRunning()&&(t+=" (in progress)",i="Elapsed: "+this.elapsed),e.setPanel({template:"3_rows_11_21_31",row1_value:t,row2_value:s,row3_value:i}),e.getResponse()}}}}]);
© Copyright Chaturbate 2011- 2025. All Rights Reserved.