@jikey/fcazero
Version:
Facebook Messenger bot, and is one of the most advanced next-generation Facebook Chat API (FCA)
2 lines (1 loc) • 1.83 kB
JavaScript
;var d=Object.create;var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var j=(o,e)=>{for(var t in e)a(o,t,{get:e[t],enumerable:!0})},m=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of I(e))!w.call(o,r)&&r!==t&&a(o,r,{get:()=>e[r],enumerable:!(n=h(e,r))||n.enumerable});return o};var b=(o,e,t)=>(t=o!=null?d(g(o)):{},m(e||!o||!o.__esModule?a(t,"default",{value:o,enumerable:!0}):t,o)),A=o=>m(a({},"__esModule",{value:!0}),o);var C={};j(C,{default:()=>p});module.exports=A(C);var y=require("../utils/clients.js"),f=require("../utils/constants.js"),l=b(require("../utils/logger.js"),1);class p{constructor(e,t,n){this.defaultFuncs=e;this.ctx=n}static formatData(e){const t={};for(const n in e)if(e.hasOwnProperty(n)){const r=e[n];t[n]={name:r.name,firstName:r.firstName,vanity:r.vanity,thumbSrc:r.thumbSrc,profileUrl:r.uri,gender:r.gender,type:r.type,isFriend:r.is_friend,isBirthday:!!r.is_birthday,searchTokens:r.searchTokens,alternateName:r.alternateName}}return t}call(e,t){return new Promise((n,r)=>{try{if(!e.userID)throw new Error("Please pass a userID as an argument.");if(f.Constants.getType(e.userID)!=="Number"&&f.Constants.getType(e.userID)!=="String")throw new Error("userID must be a number or a string");const i=[e.userID],u={};return i.map(function(s,c){u["ids["+c+"]"]=s}),this.defaultFuncs.post("https://www.facebook.com/chat/user_info/",this.ctx.jar,u).then(y.Clients.parseAndCheckLogin(this.ctx,this.defaultFuncs)).then(function(s){if(s&&s.error)throw s;return t&&typeof t=="function"&&t(null,p.formatData(s&&s.payload.profiles)),n(p.formatData(s&&s.payload.profiles))})}catch(i){return l.default.error({error:i},"GetUserInfo:"),t&&typeof t=="function"&&t(i),r(i)}})}}