Apps Home
|
Create an App
sdfeds
Author:
kothique_test2
Description
Source Code
Launch App
Current Users
Created by:
Kothique_Test2
"use strict";function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var ReflectOwnKeys,dist=createCommonjsModule(function(e){const t=[];cb.onMessage(e=>{for(const n of t){const t=n(e);t&&(e=t)}return e}),cb.onMessage=function(e){t.push(e)},e.exports={}}),R="object"==typeof Reflect?Reflect:null,ReflectApply=R&&"function"==typeof R.apply?R.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};function ProcessEmitWarning(e){console&&console.warn&&console.warn(e)}ReflectOwnKeys=R&&"function"==typeof R.ownKeys?R.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var NumberIsNaN=Number.isNaN||function(e){return e!=e};function EventEmitter(){EventEmitter.init.call(this)}var events=EventEmitter;EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._eventsCount=0,EventEmitter.prototype._maxListeners=void 0;var defaultMaxListeners=10;function $getMaxListeners(e){return void 0===e._maxListeners?EventEmitter.defaultMaxListeners:e._maxListeners}function _addListener(e,t,n,s){var r,i,o;if("function"!=typeof n)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n);if(void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),o=i[t]),void 0===o)o=i[t]=n,++e._eventsCount;else if("function"==typeof o?o=i[t]=s?[n,o]:[o,n]:s?o.unshift(n):o.push(n),(r=$getMaxListeners(e))>0&&o.length>r&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,ProcessEmitWarning(u)}return e}function onceWrapper(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,ReflectApply(this.listener,this.target,e))}function _onceWrap(e,t,n){var s={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=onceWrapper.bind(s);return r.listener=n,s.wrapFn=r,r}function _listeners(e,t,n){var s=e._events;if(void 0===s)return[];var r=s[t];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?unwrapListeners(r):arrayClone(r,r.length)}function listenerCount(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function arrayClone(e,t){for(var n=new Array(t),s=0;s<t;++s)n[s]=e[s];return n}function spliceOne(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function unwrapListeners(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:!0,get:function(){return defaultMaxListeners},set:function(e){if("number"!=typeof e||e<0||NumberIsNaN(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");defaultMaxListeners=e}}),EventEmitter.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},EventEmitter.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||NumberIsNaN(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},EventEmitter.prototype.getMaxListeners=function(){return $getMaxListeners(this)},EventEmitter.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var s="error"===e,r=this._events;if(void 0!==r)s=s&&void 0===r.error;else if(!s)return!1;if(s){var i;if(t.length>0&&(i=t[0]),i instanceof Error)throw i;var o=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw o.context=i,o}var u=r[e];if(void 0===u)return!1;if("function"==typeof u)ReflectApply(u,this,t);else{var l=u.length,c=arrayClone(u,l);for(n=0;n<l;++n)ReflectApply(c[n],this,t)}return!0},EventEmitter.prototype.addListener=function(e,t){return _addListener(this,e,t,!1)},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.prependListener=function(e,t){return _addListener(this,e,t,!0)},EventEmitter.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,_onceWrap(this,e,t)),this},EventEmitter.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,_onceWrap(this,e,t)),this},EventEmitter.prototype.removeListener=function(e,t){var n,s,r,i,o;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(void 0===(s=this._events))return this;if(void 0===(n=s[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(r=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){o=n[i].listener,r=i;break}if(r<0)return this;0===r?n.shift():spliceOne(n,r),1===n.length&&(s[e]=n[0]),void 0!==s.removeListener&&this.emit("removeListener",e,o||t)}return this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.removeAllListeners=function(e){var t,n,s;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var r,i=Object.keys(n);for(s=0;s<i.length;++s)"removeListener"!==(r=i[s])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(s=t.length-1;s>=0;s--)this.removeListener(e,t[s]);return this},EventEmitter.prototype.listeners=function(e){return _listeners(this,e,!0)},EventEmitter.prototype.rawListeners=function(e){return _listeners(this,e,!1)},EventEmitter.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):listenerCount.call(e,t)},EventEmitter.prototype.listenerCount=listenerCount,EventEmitter.prototype.eventNames=function(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};class RequestTarget{constructor(e={}){this._options={callAllHandlers:"boolean"==typeof e.callAllHandlers&&e.callAllHandlers,getAllResults:"boolean"==typeof e.getAllResults&&e.getAllResults,autoPromiseAll:"boolean"!=typeof e.autoPromiseAll||e.autoPromiseAll,byRequest:e.byRequest||{}},this._handlers={}}_getRequestOption(e,t){const n=this._options.byRequest[e]||{},s=this._options;return void 0!==n[t]?n[t]:s[t]}setOptions(e,t){if(void 0===t){const t=e;Object.assign(this._options,t)}else{const n=e,s=t;this._options.byRequest[n]?Object.assign(this._options.byRequest[n],s):this._options.byRequest[n]=s}return this}on(e,t){return(this._handlers[e]||(this._handlers[e]=[])).push(t),this}off(e,t){const n=this._handlers[e];if(!n)return this;const s=n.indexOf(t);return-1!==s&&n.splice(s,1),this}request(e,...t){const n=this._handlers[e];if(!n||0===n.length)return;const s=this._getRequestOption(e,"callAllHandlers"),r=this._getRequestOption(e,"getAllResults"),i=this._getRequestOption(e,"autoPromiseAll");if(r){const e=[];let s=!1;return n.forEach(n=>{const r=n(...t);e.push(r),"object"==typeof r&&"function"==typeof r.then&&(s=!0)}),s&&i?Promise.all(e):e}let o=void 0;for(const e of n){const n=e(...t);if(void 0!==n&&void 0===o&&(o=n,!s))return o}return o}}var dist$2=RequestTarget;class Failure extends Error{constructor(e={}){super(e.message||""),Error.captureStackTrace(this,Failure),this.name="Failure",this.type="ERR_FAILURE",this.data=e}}var errors={Failure:Failure},src$1=createCommonjsModule(function(e){const{Failure:t}=errors,n=new events;cb.onMessage(e=>{const t=e.user,s=e.m;if(t!==cb.room_slug)return e;if(!s.startsWith("/fb/channel/"))return e;e["X-Spam"]=!0;const r=JSON.parse(s.substr("/fb/channel/".length)),[i,o]=r;if("event"===o){const[,,e,t]=r;n.emit("event",i,e,t)}else if("request"===o){const[,,e,t,s]=r;n.emit("request",i,e,t,s)}else if("success"===o){const[,,e,t]=r;n.emit("success",i,e,t)}else if("failure"===o){const[,,e,t]=r;n.emit("failure",i,e,t)}return e});class s{constructor(e){this._name=e.name,this._nextRequestId=0,this._requests={},this._eventHandlers=new events,this._requestHandlers=new dist$2,this.onEvent={addListener:(e,t)=>this._eventHandlers.on(e,t),removeListener:(e,t)=>this._eventHandlers.removeListener(e,t)},this.onRequest={addHandler:(e,t)=>this._requestHandlers.on(e,t),removeHandler:(e,t)=>this._requestHandlers.off(e,t)},this._listeners={},n.on("event",this._listeners.event=((e,t,n)=>{e===this._name&&this._eventHandlers.emit(t,n)})),n.on("request",this._listeners.request=((e,t,n,s)=>{if(e!==this._name)return;const r=e=>cb.sendNotice(this._createFailingResponse(t,e),cb.room_slug),i=e=>cb.sendNotice(this._createSuccessfulResponse(t,e),cb.room_slug);try{Promise.resolve(this._requestHandlers.request(n,s)).then(i).catch(r)}catch(e){r(e)}})),n.on("success",this._listeners.success=((e,t,n)=>{e===this._name&&this._requests[t].resolve(n)})),n.on("failure",this._listeners.failure=((e,t,n)=>{e==this._name&&this._requests[t].reject(n)}))}close(){n.removeListener("failure",this._listeners.failure),n.removeListener("success",this._listeners.success),n.removeListener("request",this._listeners.request),n.removeListener("event",this._listeners.event)}get name(){return this._name}emit(e,t){cb.sendNotice(this._createEvent(e,t),cb.room_slug)}request(e,n){const s=this._nextRequestId++,r=new Promise((e,n)=>{this._requests[s]={resolve:t=>{e(t),delete this._requests[s]},reject:e=>{n(new t(e)),delete this._requests[s]}}});return cb.sendNotice(this._createRequest(s,e,n),cb.room_slug),r}_createEvent(e,t){return"/fb/channel/"+JSON.stringify([this._name,"event",e,t])}_createRequest(e,t,n){return"/fb/channel/"+JSON.stringify([this._name,"request",e,t,n])}_createSuccessfulResponse(e,t){return"/fb/channel/"+JSON.stringify([this._name,"success",e,t])}_createFailingResponse(e,t){return"/fb/channel/"+JSON.stringify([this._name,"failure",e,t])}}s.Channel=s,s.Failure=t,e.exports=s}),dist_1=src$1;const channel=new dist_1({name:"test-channel"});cb.onMessage(e=>{if(!e.m.startsWith("/fb")&&(channel.emit("user-msg",{content:e.m}),"/whoisit"===e.m)){cb.sendNotice("got whoisit command");const e=channel.request("whoisit");cb.sendNotice("res type is "+typeof e),cb.sendNotice(typeof e.then),e.then(e=>cb.sendNotice(`I know its name is ${e}`)).catch(e=>cb.sendNotice(`Error: ${e}`))}});
© Copyright Chaturbate 2011- 2025. All Rights Reserved.