UNPKG

@jikey/fcazero

Version:

Facebook Messenger bot, and is one of the most advanced next-generation Facebook Chat API (FCA)

2 lines (1 loc) 1.91 kB
"use strict";var O=Object.create;var d=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var b=(r,t)=>{for(var s in t)d(r,s,{get:t[s],enumerable:!0})},R=(r,t,s,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of w(t))!J.call(r,a)&&a!==s&&d(r,a,{get:()=>t[a],enumerable:!(e=j(t,a))||e.enumerable});return r};var l=(r,t,s)=>(s=r!=null?O(D(r)):{},R(t||!r||!r.__esModule?d(s,"default",{value:r,enumerable:!0}):s,r)),A=r=>R(d({},"__esModule",{value:!0}),r);var P={};b(P,{MakeDefaults:()=>G});module.exports=A(P);var T=l(require("cheerio"),1),k=l(require("pify"),1),g=require("./axios.js"),C=require("./constants.js"),f=l(require("./logger.js"),1);class G{static async json(t,s,e,a,u,y){try{const i=(await g.Axios.get(t,s,e,a,u,y)).body,n=T.load(i),p=n('script[type="application/json"]');if(p.length===0)return f.default.warn(`No <script type="application/json"> tags found on ${t}`),[];const m=[];return p.each((c,h)=>{try{const _=n(h).html();_&&m.push(JSON.parse(_))}catch{f.default.warn(`Could not parse JSON from script #${c+1} on ${t}`)}}),m}catch(o){throw f.default.error({err:o},`Error in utils.json fetching from ${t}:`),o}}static makeDefaults(t,s,e){let a=1;const u=C.Constants.getFrom(t,'revision":',",");function y(o){const i={av:s,__user:s,__req:(a++).toString(36),__rev:u,__a:1,...e&&{fb_dtsg:e.fb_dtsg,jazoest:e.jazoest,lsd:e.lsd,__spin_r:e.master?.__spin_r,__spin_b:e.master?.__spin_b,__spin_t:e.master?.__spin_t}};if(!o)return i;for(const n in o)Object.prototype.hasOwnProperty.call(o,n)&&!i[n]&&(i[n]=o[n]);return i}return{get:(o,i,n,p,m,c={})=>g.Axios.get(o,i,y(n),p,m||e,c),post:(o,i,n,p,m,c={})=>g.Axios.post(o,i,y(n),p,m||e,c),postFormData:(o,i,n,p,m,c)=>g.Axios.postFormData(o,i,y(n),y(p),m,c||e)}}static promisify(t){return(0,k.default)(t)}}0&&(module.exports={MakeDefaults});