@jikey/fcazero
Version:
Facebook Messenger bot, and is one of the most advanced next-generation Facebook Chat API (FCA)
2 lines (1 loc) • 1.54 kB
JavaScript
;var c=Object.create;var n=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var S=(o,t)=>{for(var e in t)n(o,e,{get:t[e],enumerable:!0})},O=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of d(t))!w.call(o,p)&&p!==e&&n(o,p,{get:()=>t[p],enumerable:!(r=b(t,p))||r.enumerable});return o};var h=(o,t,e)=>(e=o!=null?c(g(o)):{},O(t||!o||!o.__esModule?n(e,"default",{value:o,enumerable:!0}):e,o)),j=o=>O(n({},"__esModule",{value:!0}),o);var x={};S(x,{default:()=>y});module.exports=j(x);var f=require("../core/setOptions.js"),u=h(require("../utils/logger.js"),1);class y{constructor(t,e,r){this.ctx=r}call(t,e){return new Promise(async(r,p)=>{try{if(typeof t!="object"||t===null||Array.isArray(t))throw new Error("Options must be an object");if(Object.keys(t).length===0)throw new Error("Options object cannot be empty");if(e&&typeof e!="function")throw new Error("Callback must be a function");const i=Object.entries(t).reduce((a,[s,m])=>(s in this.ctx.globalOptions?a[s]=m:u.default.warn(`[SetOption] Option "${s}" is not a valid global option and will be ignored.`),a),{});Object.assign(this.ctx.globalOptions,i),await new f.SetOptions(this.ctx.globalOptions,i).execute();const l={success:!0,updated:t,globalOptions:this.ctx.globalOptions};e&&typeof e=="function"&&e(null,l),r(l)}catch(i){u.default.error({err:i},"setOption"),e&&typeof e=="function"&&e(i instanceof Error?i:new Error(String(i))),p(i)}})}}