fca-umaru-v1 40.1.23
Sign up to get free protection for your applications and to get access to all the features.
- package/.travis.yml +6 -0
- package/CHANGELOG.md +2 -0
- package/DOCS.md +1947 -0
- package/LICENSE-MIT +21 -0
- package/README.md +219 -0
- package/index.js +1 -0
- package/package.json +67 -0
- package/src/addExternalModule.js +1 -0
- package/src/addUserToGroup.js +1 -0
- package/src/changeAdminStatus.js +1 -0
- package/src/changeArchivedStatus.js +1 -0
- package/src/changeAvatar.js +1 -0
- package/src/changeBio.js +1 -0
- package/src/changeBlockedStatus.js +1 -0
- package/src/changeGroupImage.js +1 -0
- package/src/changeNickname.js +1 -0
- package/src/changeThreadColor.js +1 -0
- package/src/changeThreadEmoji.js +1 -0
- package/src/createNewGroup.js +1 -0
- package/src/createPoll.js +1 -0
- package/src/deleteMessage.js +1 -0
- package/src/deleteThread.js +1 -0
- package/src/forwardAttachment.js +1 -0
- package/src/getAccessToken.js +1 -0
- package/src/getCurrentUserID.js +1 -0
- package/src/getEmojiUrl.js +1 -0
- package/src/getFriendsList.js +1 -0
- package/src/getMessage.js +1 -0
- package/src/getThreadHistory.js +1 -0
- package/src/getThreadInfo.js +1 -0
- package/src/getThreadList.js +1 -0
- package/src/getThreadPictures.js +1 -0
- package/src/getUserID.js +1 -0
- package/src/getUserInfo.js +1 -0
- package/src/handleFriendRequest.js +1 -0
- package/src/handleMessageRequest.js +1 -0
- package/src/httpGet.js +1 -0
- package/src/httpPost.js +1 -0
- package/src/httpPostFormData.js +1 -0
- package/src/listenMqtt.js +1 -0
- package/src/logout.js +1 -0
- package/src/markAsDelivered.js +1 -0
- package/src/markAsRead.js +1 -0
- package/src/markAsReadAll.js +1 -0
- package/src/markAsSeen.js +1 -0
- package/src/muteThread.js +1 -0
- package/src/removeUserFromGroup.js +1 -0
- package/src/resolvePhotoUrl.js +1 -0
- package/src/searchForThread.js +1 -0
- package/src/sendMessage.js +1 -0
- package/src/sendTypingIndicator.js +1 -0
- package/src/setMessageReaction.js +1 -0
- package/src/setPostReaction.js +1 -0
- package/src/setTitle.js +1 -0
- package/src/threadColors.js +1 -0
- package/src/unfriend.js +1 -0
- package/src/unsendMessage.js +1 -0
- package/src/uploadAttachment.js +1 -0
- package/utils.js +1 -0
package/LICENSE-MIT
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Avery, Benjamin, David, Maude
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
This repo is a fork from main repo and will usually have new features bundled faster than main repo (and maybe bundle some bugs, too).
|
2
|
+
See main repo [here](https://github.com/Schmavery/facebook-chat-api).
|
3
|
+
|
4
|
+
# Unofficial Facebook Chat API
|
5
|
+
<a href="https://www.npmjs.com/package/fca-umaru-v1"><img alt="npm version" src="https://img.shields.io/npm/v/fb-chat-api.svg?style=flat-square"></a>
|
6
|
+
<img alt="version" src="https://img.shields.io/github/package-json/v/fb-chat-api/fb-chat-api?label=github&style=flat-square">
|
7
|
+
<a href="https://www.npmjs.com/package/fca-umaru-v1"><img src="https://img.shields.io/npm/dm/fb-chat-api.svg?style=flat-square" alt="npm downloads"></a>
|
8
|
+
|
9
|
+
Facebook now has an official API for chat bots [here](https://developers.facebook.com/docs/messenger-platform).
|
10
|
+
|
11
|
+
This API is the only way to automate chat functionalities on a user account. We do this by emulating the browser. This means doing the exact same GET/POST requests and tricking Facebook into thinking we're accessing the website normally. Because we're doing it this way, this API won't work with an auth token but requires the credentials of a Facebook account.
|
12
|
+
|
13
|
+
_Disclaimer_: We are not responsible if your account gets banned for spammy activities such as sending lots of messages to people you don't know, sending messages very quickly, sending spammy looking URLs, logging in and out very quickly... Be responsible Facebook citizens.
|
14
|
+
|
15
|
+
See [below](#projects-using-this-api) for projects using this API.
|
16
|
+
|
17
|
+
See the [full changelog](/CHANGELOG.md) for release details.
|
18
|
+
|
19
|
+
## Install
|
20
|
+
If you just want to use fca-umaru-v1, you should use this command:
|
21
|
+
```bash
|
22
|
+
npm install fca-umaru-v1
|
23
|
+
```
|
24
|
+
It will download `fca-umaru-v1` from NPM repositories
|
25
|
+
|
26
|
+
## Testing your bots
|
27
|
+
If you want to test your bots without creating another account on Facebook, you can use [Facebook Whitehat Accounts](https://www.facebook.com/whitehat/accounts/).
|
28
|
+
|
29
|
+
## Example Usage
|
30
|
+
```javascript
|
31
|
+
const login = require("fca-umaru-v1");
|
32
|
+
|
33
|
+
// Create simple echo bot
|
34
|
+
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
|
35
|
+
if(err) return console.error(err);
|
36
|
+
|
37
|
+
api.listen((err, message) => {
|
38
|
+
api.sendMessage(message.body, message.threadID);
|
39
|
+
});
|
40
|
+
});
|
41
|
+
```
|
42
|
+
|
43
|
+
Result:
|
44
|
+
|
45
|
+
<img width="517" alt="screen shot 2016-11-04 at 14 36 00" src="https://cloud.githubusercontent.com/assets/4534692/20023545/f8c24130-a29d-11e6-9ef7-47568bdbc1f2.png">
|
46
|
+
|
47
|
+
|
48
|
+
## Documentation
|
49
|
+
|
50
|
+
You can see it [here](DOCS.md).
|
51
|
+
|
52
|
+
## Main Functionality
|
53
|
+
|
54
|
+
### Sending a message
|
55
|
+
#### api.sendMessage(message, threadID, [callback], [messageID])
|
56
|
+
|
57
|
+
Various types of message can be sent:
|
58
|
+
* *Regular:* set field `body` to the desired message as a string.
|
59
|
+
* *Sticker:* set a field `sticker` to the desired sticker ID.
|
60
|
+
* *File or image:* Set field `attachment` to a readable stream or an array of readable streams.
|
61
|
+
* *URL:* set a field `url` to the desired URL.
|
62
|
+
* *Emoji:* set field `emoji` to the desired emoji as a string and set field `emojiSize` with size of the emoji (`small`, `medium`, `large`)
|
63
|
+
|
64
|
+
Note that a message can only be a regular message (which can be empty) and optionally one of the following: a sticker, an attachment or a url.
|
65
|
+
|
66
|
+
__Tip__: to find your own ID, you can look inside the cookies. The `userID` is under the name `c_user`.
|
67
|
+
|
68
|
+
__Example (Basic Message)__
|
69
|
+
```js
|
70
|
+
const login = require("fca-umaru-v1");
|
71
|
+
|
72
|
+
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
|
73
|
+
if(err) return console.error(err);
|
74
|
+
|
75
|
+
var yourID = "000000000000000";
|
76
|
+
var msg = "Hey!";
|
77
|
+
api.sendMessage(msg, yourID);
|
78
|
+
});
|
79
|
+
```
|
80
|
+
|
81
|
+
__Example (File upload)__
|
82
|
+
```js
|
83
|
+
const login = require("fca-umaru-v1");
|
84
|
+
|
85
|
+
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, (err, api) => {
|
86
|
+
if(err) return console.error(err);
|
87
|
+
|
88
|
+
// Note this example uploads an image called image.jpg
|
89
|
+
var yourID = "000000000000000";
|
90
|
+
var msg = {
|
91
|
+
body: "Hey!",
|
92
|
+
attachment: fs.createReadStream(__dirname + '/image.jpg')
|
93
|
+
}
|
94
|
+
api.sendMessage(msg, yourID);
|
95
|
+
});
|
96
|
+
```
|
97
|
+
|
98
|
+
------------------------------------
|
99
|
+
### Saving session.
|
100
|
+
|
101
|
+
To avoid logging in every time you should save AppState (cookies etc.) to a file, then you can use it without having password in your scripts.
|
102
|
+
|
103
|
+
__Example__
|
104
|
+
|
105
|
+
```js
|
106
|
+
const fs = require("fs");
|
107
|
+
const login = require("fca-umaru-v1");
|
108
|
+
|
109
|
+
var credentials = {email: "FB_EMAIL", password: "FB_PASSWORD"};
|
110
|
+
|
111
|
+
login(credentials, (err, api) => {
|
112
|
+
if(err) return console.error(err);
|
113
|
+
|
114
|
+
fs.writeFileSync('appstate.json', JSON.stringify(api.getAppState()));
|
115
|
+
});
|
116
|
+
```
|
117
|
+
|
118
|
+
Alternative: Use [c3c-fbstate](https://github.com/lequanglam/c3c-fbstate) to get fbstate.json (appstate.json)
|
119
|
+
|
120
|
+
------------------------------------
|
121
|
+
|
122
|
+
### Listening to a chat
|
123
|
+
#### api.listenMqtt(callback)
|
124
|
+
|
125
|
+
Listen watches for messages sent in a chat. By default this won't receive events (joining/leaving a chat, title change etc…) but it can be activated with `api.setOptions({listenEvents: true})`. This will by default ignore messages sent by the current account, you can enable listening to your own messages with `api.setOptions({selfListen: true})`.
|
126
|
+
|
127
|
+
__Example__
|
128
|
+
|
129
|
+
```js
|
130
|
+
const fs = require("fs");
|
131
|
+
const login = require("fca-umaru-v1");
|
132
|
+
|
133
|
+
// Simple echo bot. It will repeat everything that you say.
|
134
|
+
// Will stop when you say '/stop'
|
135
|
+
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => {
|
136
|
+
if(err) return console.error(err);
|
137
|
+
|
138
|
+
api.setOptions({listenEvents: true});
|
139
|
+
|
140
|
+
var stopListening = api.listenMqtt((err, event) => {
|
141
|
+
if(err) return console.error(err);
|
142
|
+
|
143
|
+
api.markAsRead(event.threadID, (err) => {
|
144
|
+
if(err) console.error(err);
|
145
|
+
});
|
146
|
+
|
147
|
+
switch(event.type) {
|
148
|
+
case "message":
|
149
|
+
if(event.body === '/stop') {
|
150
|
+
api.sendMessage("Goodbye…", event.threadID);
|
151
|
+
return stopListening();
|
152
|
+
}
|
153
|
+
api.sendMessage("TEST BOT: " + event.body, event.threadID);
|
154
|
+
break;
|
155
|
+
case "event":
|
156
|
+
console.log(event);
|
157
|
+
break;
|
158
|
+
}
|
159
|
+
});
|
160
|
+
});
|
161
|
+
```
|
162
|
+
|
163
|
+
## FAQS
|
164
|
+
|
165
|
+
1. How do I run tests?
|
166
|
+
> For tests, create a `test-config.json` file that resembles `example-config.json` and put it in the `test` directory. From the root >directory, run `npm test`.
|
167
|
+
|
168
|
+
2. Why doesn't `sendMessage` always work when I'm logged in as a page?
|
169
|
+
> Pages can't start conversations with users directly; this is to prevent pages from spamming users.
|
170
|
+
|
171
|
+
3. What do I do when `login` doesn't work?
|
172
|
+
> First check that you can login to Facebook using the website. If login approvals are enabled, you might be logging in incorrectly. For how to handle login approvals, read our docs on [`login`](DOCS.md#login).
|
173
|
+
|
174
|
+
4. How can I avoid logging in every time? Can I log into a previous session?
|
175
|
+
> We support caching everything relevant for you to bypass login. `api.getAppState()` returns an object that you can save and pass into login as `{appState: mySavedAppState}` instead of the credentials object. If this fails, your session has expired.
|
176
|
+
|
177
|
+
5. Do you support sending messages as a page?
|
178
|
+
> Yes, set the pageID option on login (this doesn't work if you set it using api.setOptions, it affects the login process).
|
179
|
+
> ```js
|
180
|
+
> login(credentials, {pageID: "000000000000000"}, (err, api) => { … }
|
181
|
+
> ```
|
182
|
+
|
183
|
+
6. I'm getting some crazy weird syntax error like `SyntaxError: Unexpected token [`!!!
|
184
|
+
> Please try to update your version of node.js before submitting an issue of this nature. We like to use new language features.
|
185
|
+
|
186
|
+
7. I don't want all of these logging messages!
|
187
|
+
> You can use `api.setOptions` to silence the logging. You get the `api` object from `login` (see example above). Do
|
188
|
+
> ```js
|
189
|
+
> api.setOptions({
|
190
|
+
> logLevel: "silent"
|
191
|
+
> });
|
192
|
+
> ```
|
193
|
+
|
194
|
+
<a name="projects-using-this-api"></a>
|
195
|
+
## Projects using this API:
|
196
|
+
- [c3c](https://github.com/lequanglam/c3c) - A bot that can be customizable using plugins. Support Facebook & Discord.
|
197
|
+
- [GOAT BOT 🐐](https://github.com/ntkhang03/Goat-Bot) - A bot chat Messenger can be customizable using scripts. Support .
|
198
|
+
|
199
|
+
## Projects using this API (original repository, facebook-chat-api):
|
200
|
+
|
201
|
+
- [Messer](https://github.com/mjkaufer/Messer) - Command-line messaging for Facebook Messenger
|
202
|
+
- [messen](https://github.com/tomquirk/messen) - Rapidly build Facebook Messenger apps in Node.js
|
203
|
+
- [Concierge](https://github.com/concierge/Concierge) - Concierge is a highly modular, easily extensible general purpose chat bot with a built in package manager
|
204
|
+
- [Marc Zuckerbot](https://github.com/bsansouci/marc-zuckerbot) - Facebook chat bot
|
205
|
+
- [Marc Thuckerbot](https://github.com/bsansouci/lisp-bot) - Programmable lisp bot
|
206
|
+
- [MarkovsInequality](https://github.com/logicx24/MarkovsInequality) - Extensible chat bot adding useful functions to Facebook Messenger
|
207
|
+
- [AllanBot](https://github.com/AllanWang/AllanBot-Public) - Extensive module that combines the facebook api with firebase to create numerous functions; no coding experience is required to implement this.
|
208
|
+
- [Larry Pudding Dog Bot](https://github.com/Larry850806/facebook-chat-bot) - A facebook bot you can easily customize the response
|
209
|
+
- [fbash](https://github.com/avikj/fbash) - Run commands on your computer's terminal over Facebook Messenger
|
210
|
+
- [Klink](https://github.com/KeNt178/klink) - This Chrome extension will 1-click share the link of your active tab over Facebook Messenger
|
211
|
+
- [Botyo](https://github.com/ivkos/botyo) - Modular bot designed for group chat rooms on Facebook
|
212
|
+
- [matrix-puppet-facebook](https://github.com/matrix-hacks/matrix-puppet-facebook) - A facebook bridge for [matrix](https://matrix.org)
|
213
|
+
- [facebot](https://github.com/Weetbix/facebot) - A facebook bridge for Slack.
|
214
|
+
- [Botium](https://github.com/codeforequity-at/botium-core) - The Selenium for Chatbots
|
215
|
+
- [Messenger-CLI](https://github.com/AstroCB/Messenger-CLI) - A command-line interface for sending and receiving messages through Facebook Messenger.
|
216
|
+
- [AssumeZero-Bot](https://github.com/AstroCB/AssumeZero-Bot) – A highly customizable Facebook Messenger bot for group chats.
|
217
|
+
- [Miscord](https://github.com/Bjornskjald/miscord) - An easy-to-use Facebook bridge for Discord.
|
218
|
+
- [chat-bridge](https://github.com/rexx0520/chat-bridge) - A Messenger, Telegram and IRC chat bridge.
|
219
|
+
- [messenger-auto-reply](https://gitlab.com/theSander/messenger-auto-reply) - An auto-reply service for Messenger.
|
package/index.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("./utils"),t=require("cheerio"),o=require("npmlog"),$ = logger;let n=null;function i(t,n){Object.keys(n).map((function(i){switch(i){case"online":t.online=Boolean(n.online);break;case"logLevel":o.level=n.logLevel,t.logLevel=n.logLevel;break;case"logRecordSize":o.maxRecordSize=n.logRecordSize,t.logRecordSize=n.logRecordSize;break;case"selfListen":t.selfListen=Boolean(n.selfListen);break;case"selfListenEvent":t.selfListenEvent=n.selfListenEvent;break;case"listenEvents":t.listenEvents=Boolean(n.listenEvents);break;case"pageID":t.pageID=n.pageID.toString();break;case"updatePresence":t.updatePresence=Boolean(n.updatePresence);break;case"forceLogin":t.forceLogin=Boolean(n.forceLogin);break;case"userAgent":t.userAgent=n.userAgent;break;case"autoMarkDelivery":t.autoMarkDelivery=Boolean(n.autoMarkDelivery);break;case"autoMarkRead":t.autoMarkRead=Boolean(n.autoMarkRead);break;case"listenTyping":t.listenTyping=Boolean(n.listenTyping);break;case"proxy":"string"!=typeof n.proxy?(delete t.proxy,e.setProxy()):(t.proxy=n.proxy,e.setProxy(t.proxy));break;case"autoReconnect":t.autoReconnect=Boolean(n.autoReconnect);break;case"emitReady":t.emitReady=Boolean(n.emitReady);break;default:$.log("setOptions","Unrecognized option given to setOptions: "+i)}}))}function r(a,s,c,l,g,u){let p=null;const h=e.getJar();var d,f,m,w,k,b;a?(a.map((function(e){h.setCookie(e.key+"="+e.value+"; expires="+e.expires+"; domain="+e.domain+"; path="+e.path+";","http://"+e.domain)})),p=e.get("https://www.facebook.com/",h,null,l,{noRef:!0}).then(e.saveCookies(h))):p=e.get("https://www.facebook.com/",null,null,l,{noRef:!0}).then(e.saveCookies(h)).then((d=h,f=s,m=c,w=l,k=g,b=u,function(i){const a=i.body,s=t.load(a);let c=[];s("#login_form input").map((function(e,t){c.push({val:s(t).val(),name:s(t).attr("name")})})),c=c.filter((function(e){return e.val&&e.val.length}));const l=e.arrToForm(c);return l.lsd=e.getFrom(a,'["LSD",[],{"token":"','"}'),l.lgndim=Buffer.from('{"w":1440,"h":900,"aw":1440,"ah":834,"c":24}').toString("base64"),l.email=f,l.pass=m,l.default_persistent="0",l.lgnrnd=e.getFrom(a,'name="lgnrnd" value="','"'),l.locale="en_US",l.timezone="240",l.lgnjs=~~(Date.now()/1e3),a.split('"_js_').slice(1).map((function(t){const o=JSON.parse('["'+e.getFrom(t,"","]")+"]");d.setCookie(e.formatCookie(o,"facebook"),"https://www.facebook.com")})),$.log("Umaru","Logging in..."),e.post("https://www.facebook.com/login/device-based/regular/login/?login_attempt=1&lwv=110",d,l,w).then(e.saveCookies(d)).then((function(i){const a=i.headers;if(!a.location)throw{error:"Wrong username/password."};if(a.location.indexOf("https://www.facebook.com/checkpoint/")>-1){$.log("Umaru","You have login approvals turned on.");const i="https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php";return e.get(a.location,d,null,w).then(e.saveCookies(d)).then((function(a){const s=a.body,c=t.load(s);let l=[];c("form input").map((function(e,t){l.push({val:c(t).val(),name:c(t).attr("name")})})),l=l.filter((function(e){return e.val&&e.val.length}));const g=e.arrToForm(l);if(s.indexOf("checkpoint/?next")>-1)throw setTimeout((()=>{n=setInterval((e=>{}),5e3,{fb_dtsg:g.fb_dtsg,jazoest:g.jazoest,dpr:1})}),2500),{error:"login-approval",continue:function a(s){g.approvals_code=s,g["submit[Continue]"]=c("#checkpointSubmitButton").html();let l=null,u=null;const p=new Promise((function(e,t){l=e,u=t}));return"string"==typeof s?e.post(i,d,g,w).then(e.saveCookies(d)).then((function(e){const o=t.load(e.body)("#approvals_code").parent().attr("data-xui-error");if(o)throw{error:"login-approval",errordesc:"Invalid 2FA code.",lerror:o,continue:a}})).then((function(){return delete g.no_fido,delete g.approvals_code,g.name_action_selected="dont_save",e.post(i,d,g,w).then(e.saveCookies(d))})).then((function(t){if(!t.headers.location&&t.body.indexOf("Review Recent Login")>-1)throw{error:"Something went wrong with login approvals."};const o=e.getAppState(d);return k===b&&(k=function(e,t){return e?u(e):l(t)}),r(o,f,m,w,k)})).catch((function(e){k===b?u(e):k(e)})):e.post("https://www.facebook.com/checkpoint/?next=https%3A%2F%2Fwww.facebook.com%2Fhome.php",d,g,w,null,{Referer:"https://www.facebook.com/checkpoint/?next"}).then(e.saveCookies(d)).then((t=>{try{JSON.parse(t.body.replace(/for\s*\(\s*;\s*;\s*\)\s*;\s*/,""))}catch(t){return clearInterval(n),$.log("Umaru","Verified from browser. Logging in..."),k===b&&(k=function(e,t){return e?u(e):l(t)}),r(e.getAppState(d),f,m,w,k)}})).catch((e=>{$.log("Umaru",e),k===b?u(e):k(e)})),p}};if(!w.forceLogin)throw{error:"Couldn't login. Facebook might have blocked this account. Please login with a browser or enable the option 'forceLogin' and try again."};return s.indexOf("Suspicious Login Attempt")>-1?g["submit[This was me]"]="This was me":g["submit[This Is Okay]"]="This Is Okay",e.post(i,d,g,w).then(e.saveCookies(d)).then((function(){return g.name_action_selected="save_device",e.post(i,d,g,w).then(e.saveCookies(d))})).then((function(t){if(!t.headers.location&&t.body.indexOf("Review Recent Login")>-1)throw{error:"Something went wrong with review recent login."};return r(e.getAppState(d),f,m,w,k)})).catch((function(e){k(e)}))}))}return e.get("https://www.facebook.com/",d,null,w).then(e.saveCookies(d))}))})).then((function(){return e.get("https://www.facebook.com/",h,null,l).then(e.saveCookies(h))}));let v=null,y=null,S=null;p=p.then((function(t){const o=/<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/.exec(t.body);return o&&o[1]?e.get(o[1],h,null,l).then(e.saveCookies(h)):t})).then((function(t){const r=function(t,r,a){const s=a.getCookies("https://www.facebook.com").filter((function(e){return"c_user"===e.cookieString().split("=")[0]})),c=a.getCookies("https://www.facebook.com").reduce((function(e,t){return e[t.cookieString().split("=")[0]]=t.cookieString().split("=")[1],e}),{});if(0===s.length)throw{error:"Error retrieving userID. This can be caused by a lot of things, including getting blocked by Facebook for logging in from an unknown location. Try logging in with a browser to verify."};r.indexOf("/checkpoint/block/?next")>-1&&$.log("Umaru","Checkpoint detected. Please log in with a browser to verify.");const l=s[0].cookieString().split("=")[1].toString(),g=c.i_user||null;$.log("Umaru","Logged in as "+l);try{clearInterval(n)}catch(e){}const u=(2147483648*Math.random()|0).toString(16),p=r.match(/irisSeqID:"(.+?)",appID:219994525426954,endpoint:"(.+?)"/);let h=null,d=null,f=null,m=null;if(p)f=p[1],h=p[2],d=new URL(h).searchParams.get("region").toUpperCase(),$.log("Umaru","Got this account's message region: "+d);else{const e=r.match(/{"app_id":"219994525426954","endpoint":"(.+?)","iris_seq_id":"(.+?)"}/);if(e)f=e[2],h=e[1].replace(/\\\//g,"/"),d=new URL(h).searchParams.get("region").toUpperCase(),$.log("Umaru","Got this account's message region: "+d);else{const e=r.match(/(\["MqttWebConfig",\[\],{fbid:")(.+?)(",appID:219994525426954,endpoint:")(.+?)(",pollingEndpoint:")(.+?)(3790])/);e?(h=e[4],d=new URL(h).searchParams.get("region").toUpperCase(),$.log("Umaru","Cannot get sequence ID with new RegExp. Fallback to old RegExp (without seqID)..."),$.log("Umaru","Got this account's message region: "+d),$.log("Umaru","[Unused] Polling endpoint: "+e[6])):($.log("Umaru","Cannot get MQTT region & sequence ID."),m=r)}}const w={userID:l,i_userID:g,jar:a,clientID:u,globalOptions:t,loggedIn:!0,access_token:"NONE",clientMutationId:0,mqttClient:void 0,lastSeqId:f,syncToken:void 0,mqttEndpoint:h,region:d,firstListen:!0},k={setOptions:i.bind(null,t),getAppState:function(){return e.getAppState(a).filter(((e,t,o)=>o.findIndex((t=>t.key===e.key))===t))}};m&&(k.htmlData=m);const b=e.makeDefaults(r,g||l,w);return["addExternalModule","addUserToGroup","changeAdminStatus","changeArchivedStatus","changeAvatar","changeBio","changeBlockedStatus","changeGroupImage","changeNickname","changeThreadColor","changeThreadEmoji","createNewGroup","createPoll","deleteMessage","deleteThread","forwardAttachment","getAccessToken","getCurrentUserID","getEmojiUrl","getFriendsList","getMessage","getThreadHistory","getThreadInfo","getThreadList","getThreadPictures","getUserID","getUserInfo","handleMessageRequest","listenMqtt","logout","markAsDelivered","markAsRead","markAsReadAll","markAsSeen","muteThread","removeUserFromGroup","resolvePhotoUrl","searchForThread","sendMessage","sendTypingIndicator","setMessageReaction","setPostReaction","setTitle","threadColors","unsendMessage","httpGet","httpPost","httpPostFormData","uploadAttachment"].map((function(e){k[e]=require("./src/"+e)(b,k,w)})),k.listen=k.listenMqtt,[w,b,k]}(l,t.body,h);return v=r[0],y=r[1],S=r[2],t})),l.pageID&&(p=p.then((function(){return e.get("https://www.facebook.com/"+v.globalOptions.pageID+"/messages/?section=messages&subsection=inbox",v.jar,null,l)})).then((function(t){let o=e.getFrom(t.body,'window.location.replace("https:\\/\\/www.facebook.com\\','");').split("\\").join("");return o=o.substring(0,o.length-1),e.get("https://www.facebook.com"+o,v.jar,null,l)}))),p.then((function(){return $.log("Umaru","Done logging in."),g(null,S)})).catch((function(e){$.log("Umaru",e.error||e),g(e)}))}o.maxRecordSize=100,module.exports=function(t,o,n){"Function"!==e.getType(o)&&"AsyncFunction"!==e.getType(o)||(n=o,o={});const a={selfListen:!1,selfListenEvent:!1,listenEvents:!1,listenTyping:!1,updatePresence:!1,forceLogin:!1,autoMarkDelivery:!0,autoMarkRead:!1,autoReconnect:!0,logRecordSize:100,online:!0,emitReady:!1,userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/8.0.3 Safari/600.3.18"};i(a,o);let s=null;if("Function"!==e.getType(n)&&"AsyncFunction"!==e.getType(n)){let e=null,t=null;var c=new Promise((function(o,n){t=o,e=n}));s=function(o,n){return o?e(o):t(n)},n=s}return r(t.appState,t.email,t.password,a,n,s),c};
|
package/package.json
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
{
|
2
|
+
"name": "fca-umaru-v1",
|
3
|
+
"version": "40.1.23",
|
4
|
+
"description": "A Facebook chat API that doesn't rely on XMPP",
|
5
|
+
"scripts": {
|
6
|
+
"test": "mocha",
|
7
|
+
"lint": "./node_modules/.bin/eslint **.js",
|
8
|
+
"prettier": "prettier utils.js src/* --write"
|
9
|
+
},
|
10
|
+
"keywords": [
|
11
|
+
"facebook",
|
12
|
+
"chat",
|
13
|
+
"api",
|
14
|
+
"fca",
|
15
|
+
"fca-umaru"
|
16
|
+
],
|
17
|
+
"author": "Avery, David, Maude, Benjamin, UIRI, NTKhang (rebuild), John Lester",
|
18
|
+
"license": "MIT",
|
19
|
+
"dependencies": {
|
20
|
+
"bluebird": "^3.7.2",
|
21
|
+
"cheerio": "^1.0.0-rc.12",
|
22
|
+
"https-proxy-agent": "^7.0.2",
|
23
|
+
"mqtt": "^4.3.7",
|
24
|
+
"npmlog": "^1.2.0",
|
25
|
+
"request": "^2.88.2",
|
26
|
+
"totp-generator": "^0.0.14",
|
27
|
+
"websocket-stream": "^5.5.2"
|
28
|
+
},
|
29
|
+
"engines": {
|
30
|
+
"node": ">=10.x"
|
31
|
+
},
|
32
|
+
"devDependencies": {
|
33
|
+
"eslint": "^7.5.0",
|
34
|
+
"mocha": "^7.0.1",
|
35
|
+
"prettier": "^1.11.1"
|
36
|
+
},
|
37
|
+
"eslintConfig": {
|
38
|
+
"env": {
|
39
|
+
"commonjs": true,
|
40
|
+
"es2021": true,
|
41
|
+
"node": true
|
42
|
+
},
|
43
|
+
"extends": "eslint:recommended",
|
44
|
+
"parserOptions": {
|
45
|
+
"ecmaVersion": 13
|
46
|
+
},
|
47
|
+
"rules": {
|
48
|
+
"no-prototype-builtins": 0,
|
49
|
+
"no-unused-vars": 1,
|
50
|
+
"comma-dangle": 1,
|
51
|
+
"no-redeclare": 0,
|
52
|
+
"prefer-const": 1,
|
53
|
+
"no-useless-escape": 0,
|
54
|
+
"no-mixed-spaces-and-tabs": 0,
|
55
|
+
"semi": 1,
|
56
|
+
"no-useless-catch": 0,
|
57
|
+
"no-empty": 0,
|
58
|
+
"use-isnan": 0,
|
59
|
+
"no-extra-semi": 1,
|
60
|
+
"no-async-promise-executor": 0,
|
61
|
+
"no-unreachable": 1,
|
62
|
+
"valid-typeof": 0,
|
63
|
+
"no-case-declarations": 0
|
64
|
+
}
|
65
|
+
},
|
66
|
+
"compiled": true
|
67
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils");module.exports=function(t,n,o){return function(r){if("Object"!=e.getType(r))throw new Error("moduleObj must be an object, not "+e.getType(r)+"!");for(const u in r){if("Function"!=e.getType(r[u]))throw new Error('Item "'+u+'" in moduleObj must be a function, not '+e.getType(r[u])+"!");n[u]=r[u](t,n,o)}}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),t=require("npmlog");module.exports=function(r,n,o){return function(n,i,a){let s=function(){},u=function(){};const d=new Promise((function(e,t){s=e,u=t}));if(!a&&("Function"===e.getType(i)||"AsyncFunction"===e.getType(i)))throw{error:"please pass a threadID as a second argument."};if(a||(a=function(e){if(e)return u(e);s()}),"Number"!==e.getType(i)&&"String"!==e.getType(i))throw{error:"ThreadID should be of type Number or String and not "+e.getType(i)+"."};"Array"!==e.getType(n)&&(n=[n]);const c=e.generateOfflineThreadingID(),g={client:"mercury",action_type:"ma-type:log-message",author:"fbid:"+o.userID,thread_id:"",timestamp:Date.now(),timestamp_absolute:"Today",timestamp_relative:e.generateTimestampRelative(),timestamp_time_passed:"0",is_unread:!1,is_cleared:!1,is_forward:!1,is_filtered_content:!1,is_filtered_content_bh:!1,is_filtered_content_account:!1,is_spoof_warning:!1,source:"source:chat:web","source_tags[0]":"source:chat",log_message_type:"log:subscribe",status:"0",offline_threading_id:c,message_id:c,threading_id:e.generateThreadingID(o.clientID),manual_retry_cnt:"0",thread_fbid:i};for(let t=0;t<n.length;t++){if("Number"!==e.getType(n[t])&&"String"!==e.getType(n[t]))throw{error:"Elements of userID should be of type Number or String and not "+e.getType(n[t])+"."};g["log_message_data[added_participants]["+t+"]"]="fbid:"+n[t]}return r.post("https://www.facebook.com/messaging/send/",o.jar,g).then(e.parseAndCheckLogin(o,r)).then((function(e){if(!e)throw{error:"Add to group failed."};if(e.error)throw e;return a()})).catch((function(e){return t.error("addUserToGroup",e),a(e)})),d}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const t=require("../utils"),n=require("npmlog");module.exports=function(r,e,o){return function(e,a,i,s){if("String"!==t.getType(e))throw{error:"changeAdminStatus: threadID must be a string"};if("String"===t.getType(a)&&(a=[a]),"Array"!==t.getType(a))throw{error:"changeAdminStatus: adminIDs must be an array or string"};if("Boolean"!==t.getType(i))throw{error:"changeAdminStatus: adminStatus must be a string"};let u=function(){},c=function(){};const d=new Promise((function(t,n){u=t,c=n}));if(s||(s=function(t){if(t)return c(t);u()}),"Function"!==t.getType(s)&&"AsyncFunction"!==t.getType(s))throw{error:"changeAdminStatus: callback is not a function"};const h={thread_fbid:e};let g=0;for(const t of a)h["admin_ids["+g+++"]"]=t;return h.add=i,r.post("https://www.facebook.com/messaging/save_admins/?dpr=1",o.jar,h).then(t.parseAndCheckLogin(o,r)).then((function(t){if(t.error)switch(t.error){case 1976004:throw{error:"Cannot alter admin status: you are not an admin.",rawResponse:t};case 1357031:throw{error:"Cannot alter admin status: this thread is not a group chat.",rawResponse:t};default:throw{error:"Cannot alter admin status: unknown error.",rawResponse:t}}s()})).catch((function(t){return n.error("changeAdminStatus",t),s(t)})),d}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const n=require("../utils"),t=require("npmlog");module.exports=function(e,r,o){return function(r,c,i){let u=function(){},s=function(){};const f=new Promise((function(n,t){u=n,s=t}));i||(i=function(n){if(n)return s(n);u()});const a={};if("Array"===n.getType(r))for(let n=0;n<r.length;n++)a["ids["+r[n]+"]"]=c;else a["ids["+r+"]"]=c;return e.post("https://www.facebook.com/ajax/mercury/change_archived_status.php",o.jar,a).then(n.parseAndCheckLogin(o,e)).then((function(n){if(n.error)throw n;return i()})).catch((function(n){return t.error("changeArchivedStatus",n),i(n)})),f}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),r=require("npmlog"),t=require("bluebird");module.exports=function(i,n,o){return function(n,u="",a=null,c){let s=function(){},l=function(){};const p=new Promise((function(e,r){s=e,l=r}));return a||"Number"!==e.getType(u)||(a=u,u=""),a||c||"Function"!=e.getType(u)&&"AsyncFunction"!=e.getType(u)||(c=u,u="",a=null),c||(c=function(e,r){if(e)return l(e);s(r)}),e.isReadableStream(n)?(function(n,u){const a=[];a.push(i.postFormData("https://www.facebook.com/profile/picture/upload/",o.jar,{profile_id:o.i_userID||o.userID,photo_source:57,av:o.i_userID||o.userID,file:n},{}).then(e.parseAndCheckLogin(o,i)).then((function(e){if(e.error)throw e;return e}))),t.all(a).then((function(e){u(null,e)})).catch((function(e){return r.error("handleUpload",e),u(e)}))}(n,(function(t,n){if(t)return c(t);const s={av:o.i_userID||o.userID,fb_api_req_friendly_name:"ProfileCometProfilePictureSetMutation",fb_api_caller_class:"RelayModern",doc_id:"5066134240065849",variables:JSON.stringify({input:{caption:u,existing_photo_id:n[0].payload.fbid,expiration_time:a,profile_id:o.i_userID||o.userID,profile_pic_method:"EXISTING",profile_pic_source:"TIMELINE",scaled_crop_rect:{height:1,width:1,x:0,y:0},skip_cropping:!0,actor_id:o.i_userID||o.userID,client_mutation_id:Math.round(19*Math.random()).toString()},isPage:!1,isProfile:!0,scale:3})};i.post("https://www.facebook.com/api/graphql/",o.jar,s).then(e.parseAndCheckLogin(o,i)).then((function(e){if(e.errors)throw e;return c(null,e[0].data.profile_picture_set)})).catch((function(e){return r.error("changeAvatar",e),c(e)}))})),p):c("Image is not a readable stream")}};
|
package/src/changeBio.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),n=require("npmlog");module.exports=function(t,i,r){return function(i,o,u){let c=function(){},a=function(){};const s=new Promise((function(e,n){c=e,a=n}));u||(u="Function"==e.getType(o)||"AsyncFunction"==e.getType(o)?o:function(e){if(e)return a(e);c()}),"Boolean"!=e.getType(o)&&(o=!1),"String"!=e.getType(i)&&(i="",o=!1);const l={fb_api_caller_class:"RelayModern",fb_api_req_friendly_name:"ProfileCometSetBioMutation",doc_id:"2725043627607610",variables:JSON.stringify({input:{bio:i,publish_bio_feed_story:o,actor_id:r.i_userID||r.userID,client_mutation_id:Math.round(1024*Math.random()).toString()},hasProfileTileViewID:!1,profileTileViewID:null,scale:1}),av:r.i_userID||r.userID};return t.post("https://www.facebook.com/api/graphql/",r.jar,l).then(e.parseAndCheckLogin(r,t)).then((function(e){if(e.errors)throw e;return u()})).catch((function(e){return n.error("changeBio",e),u(e)})),s}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const n=require("../utils"),e=require("npmlog");module.exports=function(t,o,r){return function(o,u,c){let i=function(){},s=function(){};const f=new Promise((function(n,e){i=n,s=e}));return c||(c=function(n){if(n)return s(n);i()}),t.post("https://www.facebook.com/messaging/"+(u?"":"un")+"block_messages/",r.jar,{fbid:o}).then(n.saveCookies(r.jar)).then(n.parseAndCheckLogin(r,t)).then((function(n){if(n.error)throw n;return c()})).catch((function(n){return e.error("changeBlockedStatus",n),c(n)})),f}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),t=require("npmlog"),r=require("bluebird");module.exports=function(a,n,i){return function(n,o,s){if(!s&&("Function"===e.getType(o)||"AsyncFunction"===e.getType(o)))throw{error:"please pass a threadID as a second argument."};if(!e.isReadableStream(n))throw{error:"please pass a readable stream as a first argument."};let u=function(){},c=function(){};const _=new Promise((function(e,t){u=e,c=t}));s||(s=function(e){if(e)return c(e);u()});const d=e.generateOfflineThreadingID(),m={client:"mercury",action_type:"ma-type:log-message",author:"fbid:"+(i.i_userID||i.userID),author_email:"",ephemeral_ttl_mode:"0",is_filtered_content:!1,is_filtered_content_account:!1,is_filtered_content_bh:!1,is_filtered_content_invalid_app:!1,is_filtered_content_quasar:!1,is_forward:!1,is_spoof_warning:!1,is_unread:!1,log_message_type:"log:thread-image",manual_retry_cnt:"0",message_id:d,offline_threading_id:d,source:"source:chat:web","source_tags[0]":"source:chat",status:"0",thread_fbid:o,thread_id:"",timestamp:Date.now(),timestamp_absolute:"Today",timestamp_relative:e.generateTimestampRelative(),timestamp_time_passed:"0"};return function(n,o){const s=[];s.push(a.postFormData("https://upload.facebook.com/ajax/mercury/upload.php",i.jar,{images_only:"true","attachment[]":n},{}).then(e.parseAndCheckLogin(i,a)).then((function(e){if(e.error)throw e;return e.payload.metadata[0]}))),r.all(s).then((function(e){o(null,e)})).catch((function(e){return t.error("handleUpload",e),o(e)}))}(n,(function(r,n){if(r)return s(r);m.thread_image_id=n[0].image_id,m.thread_id=o,a.post("https://www.facebook.com/messaging/set_thread_image/",i.jar,m).then(e.parseAndCheckLogin(i,a)).then((function(e){if(e.error)throw e;return s()})).catch((function(e){return t.error("changeGroupImage",e),s(e)}))})),_}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),r=require("npmlog");module.exports=function(n,t,o){return function(t,i,a,c){let s=function(){},h=function(){};const u=new Promise((function(e,r){s=e,h=r}));return c||(c=function(e){if(e)return h(e);s()}),n.post("https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1",o.jar,{nickname:t,participant_id:a,thread_or_other_fbid:i}).then(e.parseAndCheckLogin(o,n)).then((function(e){if(1545014===e.error)throw{error:"Trying to change nickname of user isn't in thread"};if(1357031===e.error)throw{error:"Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname."};if(e.error)throw e;return c()})).catch((function(e){return r.error("changeNickname",e),c(e)})),u}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const r=require("../utils"),t=require("npmlog");module.exports=function(e,n,o){return function(n,i,u){let c=function(){},s=function(){};const a=new Promise((function(r,t){c=r,s=t}));u||(u=function(r){if(r)return s(r);c(r)}),isNaN(n)||(n=n.toString());const h=null!==n?n.toLowerCase():n,d={dpr:1,queries:JSON.stringify({o0:{doc_id:"1727493033983591",query_params:{data:{actor_id:o.i_userID||o.userID,client_mutation_id:"0",source:"SETTINGS",theme_id:h,thread_id:i}}}})};return e.post("https://www.facebook.com/api/graphqlbatch/",o.jar,d).then(r.parseAndCheckLogin(o,e)).then((function(r){if(r[r.length-1].error_results>0)throw r[0].o0.errors;return u()})).catch((function(r){return t.error("changeThreadColor",r),u(r)})),a}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),t=require("npmlog");module.exports=function(r,o,n){return function(o,i,c){let a=function(){},h=function(){};const s=new Promise((function(e,t){a=e,h=t}));return c||(c=function(e){if(e)return h(e);a()}),r.post("https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg",n.jar,{emoji_choice:o,thread_or_other_fbid:i}).then(e.parseAndCheckLogin(n,r)).then((function(e){if(1357031===e.error)throw{error:"Trying to change emoji of a chat that doesn't exist. Have at least one message in the thread before trying to change the emoji."};if(e.error)throw e;return c()})).catch((function(e){return t.error("changeThreadEmoji",e),c(e)})),s}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),r=require("npmlog");module.exports=function(t,n,i){return function(n,a,o){if("Function"==e.getType(a)&&(o=a,a=null),"Array"!==e.getType(n))throw{error:"createNewGroup: participantIDs should be an array."};if(n.length<2)throw{error:"createNewGroup: participantIDs should have at least 2 IDs."};let u=function(){},s=function(){};const c=new Promise((function(e,r){u=e,s=r}));o||(o=function(e,r){if(e)return s(e);u(r)});const p=[];for(const e in n)p.push({fbid:n[e]});p.push({fbid:i.i_userID||i.userID});const _={fb_api_caller_class:"RelayModern",fb_api_req_friendly_name:"MessengerGroupCreateMutation",av:i.i_userID||i.userID,doc_id:"577041672419534",variables:JSON.stringify({input:{entry_point:"jewel_new_group",actor_id:i.i_userID||i.userID,participants:p,client_mutation_id:Math.round(1024*Math.random()).toString(),thread_settings:{name:a,joinable_mode:"PRIVATE",thread_image_fbid:null}}})};return t.post("https://www.facebook.com/api/graphql/",i.jar,_).then(e.parseAndCheckLogin(i,t)).then((function(e){if(e.errors)throw e;return o(null,e.data.messenger_group_thread_create.thread.thread_key.thread_fbid)})).catch((function(e){return r.error("createNewGroup",e),o(e)})),c}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const t=require("../utils"),n=require("npmlog");module.exports=function(e,o,r){return function(o,i,c,u){let s=function(){},a=function(){};const l=new Promise((function(t,n){s=t,a=n}));u||("Function"==t.getType(c)?(u=c,c=null):u=function(t){if(t)return a(t);s()}),c||(c={});const p={target_id:i,question_text:o};let f=0;for(const t in c)c.hasOwnProperty(t)&&(p["option_text_array["+f+"]"]=t,p["option_is_selected_array["+f+"]"]=c[t]?"1":"0",f++);return e.post("https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1",r.jar,p).then(t.parseAndCheckLogin(r,e)).then((function(t){if("success"!=t.payload.status)throw t;return u()})).catch((function(t){return n.error("createPoll",t),u(t)})),l}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),n=require("npmlog");module.exports=function(r,t,o){return function(t,c){let u=function(){},i=function(){};const s=new Promise((function(e,n){u=e,i=n}));c||(c=function(e){if(e)return i(e);u()});const f={client:"mercury"};"Array"!==e.getType(t)&&(t=[t]);for(let e=0;e<t.length;e++)f["message_ids["+e+"]"]=t[e];return r.post("https://www.facebook.com/ajax/mercury/delete_messages.php",o.jar,f).then(e.parseAndCheckLogin(o,r)).then((function(e){if(e.error)throw e;return c()})).catch((function(e){return n.error("deleteMessage",e),c(e)})),s}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),r=require("npmlog");module.exports=function(t,n,o){return function(n,c){let u=function(){},i=function(){};const f=new Promise((function(e,r){u=e,i=r}));c||(c=function(e){if(e)return i(e);u()});const h={client:"mercury"};"Array"!==e.getType(n)&&(n=[n]);for(let e=0;e<n.length;e++)h["ids["+e+"]"]=n[e];return t.post("https://www.facebook.com/ajax/mercury/delete_thread.php",o.jar,h).then(e.parseAndCheckLogin(o,t)).then((function(e){if(e.error)throw e;return c()})).catch((function(e){return r.error("deleteThread",e),c(e)})),f}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const t=require("../utils"),n=require("npmlog");module.exports=function(r,e,o){return function(e,c,i){let u=function(){},a=function(){};const f=new Promise((function(t,n){u=t,a=n}));i||(i=function(t){if(t)return a(t);u()});const h={attachment_id:e};"Array"!==t.getType(c)&&(c=[c]);const s=Math.floor(Date.now()/1e3);for(let t=0;t<c.length;t++)h["recipient_map["+(s+t)+"]"]=c[t];return r.post("https://www.facebook.com/mercury/attachments/forward/",o.jar,h).then(t.parseAndCheckLogin(o.jar,r)).then((function(t){if(t.error)throw t;return i()})).catch((function(t){return n.error("forwardAttachment",t),i(t)})),f}};
|
@@ -0,0 +1 @@
|
|
1
|
+
module.exports=function(e,n,r){return async function(){return await require("../lib/getToken").getAccessToken(r.jar,r,e)}};
|
@@ -0,0 +1 @@
|
|
1
|
+
module.exports=function(r,u,e){return function(){return e.i_userID||e.userID}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const t=require("util");module.exports=function(){return function(n,o,e){const r=t.format("%s/%s/%s.png",e=e||"1.0",o,n.codePointAt(0).toString(16));let s=317426846;for(let t=0;t<r.length;t++)s=(s<<5)-s+r.charCodeAt(t);const i=(255&s).toString(16);return t.format("https://static.xx.fbcdn.net/images/emoji.php/v8/z%s/%s",i,r)}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),r=require("npmlog"),n={0:"unknown",1:"female_singular",2:"male_singular",3:"female_singular_guess",4:"male_singular_guess",5:"mixed",6:"neuter_singular",7:"unknown_singular",8:"female_plural",9:"male_plural",10:"neuter_plural",11:"unknown_plural"};module.exports=function(t,i,u){return function(i){let a=function(){},l=function(){};const o=new Promise((function(e,r){a=e,l=r}));return i||(i=function(e,r){if(e)return l(e);a(r)}),t.postFormData("https://www.facebook.com/chat/user_info_all",u.jar,{},{viewer:u.i_userID||u.userID}).then(e.parseAndCheckLogin(u,t)).then((function(r){if(!r)throw{error:"getFriendsList returned empty object."};if(r.error)throw r;var t;i(null,(t=r.payload,Object.keys(t).map((function(r){const i=t[r];return{alternateName:i.alternateName,firstName:i.firstName,gender:n[i.gender],userID:e.formatID(i.id.toString()),isFriend:!(null==i.is_friend||!i.is_friend),fullName:i.name,profilePicture:i.thumbSrc,type:i.type,profileUrl:i.uri,vanity:i.vanity,isBirthday:!!i.is_birthday}}))))})).catch((function(e){return r.error("getFriendsList",e),i(e)})),o}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),t=require("npmlog");function _(t,_){switch(_.__typename){case"ThreadNameMessage":return{type:"event",threadID:t,messageID:_.message_id,logMessageType:"log:thread-name",logMessageData:{name:_.thread_name},logMessageBody:_.snippet,timestamp:_.timestamp_precise,author:_.message_sender.id};case"ThreadImageMessage":const o=_.image_with_metadata;return{type:"event",threadID:t,messageID:_.message_id,logMessageType:"log:thread-image",logMessageData:o?{attachmentID:o.legacy_attachment_id,width:o.original_dimensions.x,height:o.original_dimensions.y,url:o.preview.uri}:{attachmentID:null,width:null,height:null,url:null},logMessageBody:_.snippet,timestamp:_.timestamp_precise,author:_.message_sender.id};case"GenericAdminTextMessage":switch(_.extensible_message_admin_text_type){case"CHANGE_THREAD_THEME":return{type:"event",threadID:t,messageID:_.message_id,logMessageType:"log:thread-color",logMessageData:i.find((e=>e.theme_color===_.extensible_message_admin_text.theme_color))||{theme_color:_.extensible_message_admin_text.theme_color,theme_id:null,theme_emoji:null,gradient:null,should_show_icon:null,theme_name_with_subtitle:null},logMessageBody:_.snippet,timestamp:_.timestamp_precise,author:_.message_sender.id};case"CHANGE_THREAD_ICON":const e=_.extensible_message_admin_text.thread_icon;return{type:"event",threadID:t,messageID:_.message_id,logMessageType:"log:thread-icon",logMessageData:{thread_icon_url:"https://static.xx.fbcdn.net/images/emoji.php/v9/t3c/1/16/"+e.codePointAt(0).toString(16)+".png",thread_icon:e},logMessageBody:_.snippet,timestamp:_.timestamp_precise,author:_.message_sender.id};case"CHANGE_THREAD_NICKNAME":return{type:"event",threadID:t,messageID:_.message_id,logMessageType:"log:user-nickname",logMessageData:{nickname:_.extensible_message_admin_text.nickname,participant_id:_.extensible_message_admin_text.participant_id},logMessageBody:_.snippet,timestamp:_.timestamp_precise,author:_.message_sender.id};case"GROUP_POLL":const o=_.extensible_message_admin_text.question;return{type:"event",threadID:t,messageID:_.message_id,logMessageType:"log:thread-poll",logMessageData:{question_json:JSON.stringify({id:o.id,text:o.text,total_count:_.extensible_message_admin_text.total_count,viewer_has_voted:o.viewer_has_voted,question_type:"",creator_id:_.message_sender.id,options:o.options.nodes.map((e=>({id:e.id,text:e.text,total_count:e.voters.nodes.length,viewer_has_voted:e.viewer_has_voted,voters:e.voters.nodes.map((e=>e.id))})))}),event_type:_.extensible_message_admin_text.event_type.toLowerCase(),question_id:o.id},logMessageBody:_.snippet,timestamp:_.timestamp_precise,author:_.message_sender.id};default:throw new Error('Unknown admin text type: "'+_.extensible_message_admin_text_type+'", if this happens to you let me know when it happens. Please open an issue at https://github.com/ntkhang03/fb-chat-api/issues.')}case"UserMessage":return{senderID:_.message_sender.id,body:_.message.text,threadID:t,messageID:_.message_id,reactions:_.message_reactions.map((e=>({[e.user.id]:e.reaction}))),attachments:_.blob_attachments&&_.blob_attachments.length>0?_.blob_attachments.length.map((t=>{let _;try{_=e._formatAttachment(t)}catch(e){_=t,_.error=e,_.type="unknown"}return _})):_.extensible_attachment&&Object.keys(_.extensible_attachment).length>0?[{type:"share",ID:_.extensible_attachment.legacy_attachment_id,url:_.extensible_attachment.story_attachment.url,title:_.extensible_attachment.story_attachment.title_with_entities.text,description:_.extensible_attachment.story_attachment.description.text,source:_.extensible_attachment.story_attachment.source,image:((_.extensible_attachment.story_attachment.media||{}).image||{}).uri,width:((_.extensible_attachment.story_attachment.media||{}).image||{}).width,height:((_.extensible_attachment.story_attachment.media||{}).image||{}).height,playable:(_.extensible_attachment.story_attachment.media||{}).is_playable||!1,duration:(_.extensible_attachment.story_attachment.media||{}).playable_duration_in_ms||0,subattachments:_.extensible_attachment.subattachments,properties:_.extensible_attachment.story_attachment.properties}]:[],mentions:_.message.ranges.map((e=>({[e.entity.id]:_.message.text.substring(e.offset,e.offset+e.length)}))),timestamp:_.timestamp_precise};default:throw new Error('Unknown message type: "'+_.__typename+'", if this happens to you let me know when it happens. Please open an issue at https://github.com/ntkhang03/fb-chat-api/issues.')}}module.exports=function(i,o,h){return function(o,F,s){let m=function(){},n=function(){};const a=new Promise((function(e,t){m=e,n=t}));if(s||(s=function(e,t){if(e)return n(e);m(t)}),!o||!F)return s({error:"getMessage: need threadID and messageID"});const l={av:h.globalOptions.pageID,queries:JSON.stringify({o0:{doc_id:"1768656253222505",query_params:{thread_and_message_id:{thread_id:o,message_id:F}}}})};return i.post("https://www.facebook.com/api/graphqlbatch/",h.jar,l).then(e.parseAndCheckLogin(h,i)).then((e=>{if(e[e.length-1].error_results>0)throw e[0].o0.errors;if(0===e[e.length-1].successful_results)throw{error:"getMessage: there was no successful_results",res:e};const t=e[0].o0.data.message;if(!t)throw t;var i,h;s(null,(i=o,(h=t).replied_to_message?Object.assign({type:"message_reply"},_(i,h),{messageReply:_(i,h.replied_to_message.message)}):_(i,h)))})).catch((e=>{t.error("getMessage",e),s(e)})),a}};const i=[{theme_color:"FF000000",theme_id:"788274591712841",theme_emoji:"🖤",gradient:'["FFF0F0F0"]',should_show_icon:"",theme_name_with_subtitle:"Monochrome"},{theme_color:"FFFF5CA1",theme_id:"169463077092846",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Hot Pink"},{theme_color:"FF2825B5",theme_id:"271607034185782",theme_emoji:null,gradient:'["FF5E007E","FF331290","FF2825B5"]',should_show_icon:"1",theme_name_with_subtitle:"Shadow"},{theme_color:"FFD9A900",theme_id:"2533652183614000",theme_emoji:null,gradient:'["FF550029","FFAA3232","FFD9A900"]',should_show_icon:"1",theme_name_with_subtitle:"Maple"},{theme_color:"FFFB45DE",theme_id:"2873642949430623",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Tulip"},{theme_color:"FF5E007E",theme_id:"193497045377796",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Grape"},{theme_color:"FF7AA286",theme_id:"1455149831518874",theme_emoji:"🌑",gradient:'["FF25C0E1","FFCE832A"]',should_show_icon:"",theme_name_with_subtitle:"Dune"},{theme_color:"FFFAAF00",theme_id:"672058580051520",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Honey"},{theme_color:"FF0084FF",theme_id:"196241301102133",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Default Blue"},{theme_color:"FFFFC300",theme_id:"174636906462322",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Yellow"},{theme_color:"FF44BEC7",theme_id:"1928399724138152",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Teal Blue"},{theme_color:"FF7646FF",theme_id:"234137870477637",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Bright Purple"},{theme_color:"FFF25C54",theme_id:"3022526817824329",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Peach"},{theme_color:"FFF01D6A",theme_id:"724096885023603",theme_emoji:null,gradient:'["FF005FFF","FF9200FF","FFFF2E19"]',should_show_icon:"1",theme_name_with_subtitle:"Berry"},{theme_color:"FFFF7CA8",theme_id:"624266884847972",theme_emoji:null,gradient:'["FFFF8FB2","FFA797FF","FF00E5FF"]',should_show_icon:"1",theme_name_with_subtitle:"Candy"},{theme_color:"FF6E5B04",theme_id:"365557122117011",theme_emoji:"💛",gradient:'["FFED9F9A","FFED9F9A","FFED9F9A"]',should_show_icon:"",theme_name_with_subtitle:"Support"},{theme_color:"FF0052CD",theme_id:"230032715012014",theme_emoji:"✌️",gradient:'["FF0052CD","FF00A1E6","FF0052CD"]',should_show_icon:"",theme_name_with_subtitle:"Tie-Dye"},{theme_color:"FF601DDD",theme_id:"1060619084701625",theme_emoji:"☁️",gradient:'["FFCA34FF","FF302CFF","FFBA009C"]',should_show_icon:"",theme_name_with_subtitle:"Lo-Fi"},{theme_color:"FF0099FF",theme_id:"3273938616164733",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Classic"},{theme_color:"FF1ADB5B",theme_id:"370940413392601",theme_emoji:null,gradient:'["FFFFD200","FF6EDF00","FF00DFBB"]',should_show_icon:"1",theme_name_with_subtitle:"Citrus"},{theme_color:"FFD696BB",theme_id:"2058653964378557",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Lavender Purple"},{theme_color:"FFC03232",theme_id:"1059859811490132",theme_emoji:"🙃",gradient:'["FFDB4040","FFA32424"]',should_show_icon:"",theme_name_with_subtitle:"Stranger Things"},{theme_color:"FFFA3C4C",theme_id:"2129984390566328",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Red"},{theme_color:"FF13CF13",theme_id:"2136751179887052",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Green"},{theme_color:"FFFF7E29",theme_id:"175615189761153",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Orange"},{theme_color:"FFE68585",theme_id:"980963458735625",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Coral Pink"},{theme_color:"FF20CEF5",theme_id:"2442142322678320",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Aqua Blue"},{theme_color:"FF0EDCDE",theme_id:"417639218648241",theme_emoji:null,gradient:'["FF19C9FF","FF00E6D2","FF0EE6B7"]',should_show_icon:"1",theme_name_with_subtitle:"Aqua"},{theme_color:"FFFF9C19",theme_id:"930060997172551",theme_emoji:null,gradient:'["FFFFDC2D","FFFF9616","FFFF4F00"]',should_show_icon:"1",theme_name_with_subtitle:"Mango"},{theme_color:"FFF01D6A",theme_id:"164535220883264",theme_emoji:null,gradient:'["FF005FFF","FF9200FF","FFFF2E19"]',should_show_icon:"1",theme_name_with_subtitle:"Berry"},{theme_color:"FFFF7CA8",theme_id:"205488546921017",theme_emoji:null,gradient:'["FFFF8FB2","FFA797FF","FF00E5FF"]',should_show_icon:"1",theme_name_with_subtitle:"Candy"},{theme_color:"FFFF6F07",theme_id:"1833559466821043",theme_emoji:"🌎",gradient:'["FFFF6F07"]',should_show_icon:"",theme_name_with_subtitle:"Earth"},{theme_color:"FF0B0085",theme_id:"339021464972092",theme_emoji:"🔈",gradient:'["FF2FA9E4","FF648FEB","FF9B73F2"]',should_show_icon:"",theme_name_with_subtitle:"Music"},{theme_color:"FF8A39EF",theme_id:"1652456634878319",theme_emoji:"🏳️🌈",gradient:'["FFFF0018","FFFF0417","FFFF310E","FFFF5D06","FFFF7A01","FFFF8701","FFFFB001","FFD9C507","FF79C718","FF01C92D","FF01BE69","FF01B3AA","FF0BA1DF","FF3F77E6","FF724CEC","FF8A39EF","FF8A39EF"]',should_show_icon:"",theme_name_with_subtitle:"Pride"},{theme_color:"FF004D7C",theme_id:"538280997628317",theme_emoji:"🌀",gradient:'["FF931410","FF931410","FF931410"]',should_show_icon:"",theme_name_with_subtitle:"Doctor Strange"},{theme_color:"FF4F4DFF",theme_id:"3190514984517598",theme_emoji:"🌤",gradient:'["FF0080FF","FF9F1AFF"]',should_show_icon:"",theme_name_with_subtitle:"Sky"},{theme_color:"FFE84B28",theme_id:"357833546030778",theme_emoji:"🐯",gradient:'["FFF69500","FFDA0050"]',should_show_icon:"1",theme_name_with_subtitle:"Lunar New Year"},{theme_color:"FFB24B77",theme_id:"627144732056021",theme_emoji:"🥳",gradient:'["FFF1614E","FF660F84"]',should_show_icon:"",theme_name_with_subtitle:"Celebration!"},{theme_color:"FF66A9FF",theme_id:"390127158985345",theme_emoji:"🥶",gradient:'["FF8CB3FF","FF409FFF"]',should_show_icon:"",theme_name_with_subtitle:"Chill"},{theme_color:"FF5797FC",theme_id:"275041734441112",theme_emoji:"😌",gradient:'["FF4AC9E4","FF5890FF","FF8C91FF"]',should_show_icon:"",theme_name_with_subtitle:"Care"},{theme_color:"FFFF595C",theme_id:"3082966625307060",theme_emoji:"💫",gradient:'["FFFF239A","FFFF8C21"]',should_show_icon:"",theme_name_with_subtitle:"Astrology"},{theme_color:"FF0171FF",theme_id:"184305226956268",theme_emoji:"☁️",gradient:'["FF0026ee","FF00b2ff"]',should_show_icon:"",theme_name_with_subtitle:"J Balvin"},{theme_color:"FFA033FF",theme_id:"621630955405500",theme_emoji:"🎉",gradient:'["FFFF7061","FFFF5280","FFA033FF","FF0099FF"]',should_show_icon:"",theme_name_with_subtitle:"Birthday"},{theme_color:"FF006528",theme_id:"539927563794799",theme_emoji:"🍄",gradient:'["FF00d52f","FF006528"]',should_show_icon:"",theme_name_with_subtitle:"Cottagecore"},{theme_color:"FF4D3EC2",theme_id:"736591620215564",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Ocean"},{theme_color:"FF4e4bf5",theme_id:"3259963564026002",theme_emoji:null,gradient:'["FFAA00FF","FF0080FF"]',should_show_icon:"1",theme_name_with_subtitle:"Default"},{theme_color:"FF3A12FF",theme_id:"582065306070020",theme_emoji:null,gradient:'["FFFAAF00","FFFF2E2E","FF3A12FF"]',should_show_icon:"1",theme_name_with_subtitle:"Rocket"},{theme_color:"FF3A1D8A",theme_id:"273728810607574",theme_emoji:null,gradient:'["FFFB45DE","FF841DD5","FF3A1D8A"]',should_show_icon:"1",theme_name_with_subtitle:"Unicorn"},{theme_color:"FF9FD52D",theme_id:"262191918210707",theme_emoji:null,gradient:'["FF2A7FE3","FF00BF91","FF9FD52D"]',should_show_icon:"1",theme_name_with_subtitle:"Tropical"},{theme_color:"FFF7B267",theme_id:"909695489504566",theme_emoji:null,gradient:'["FFF25C54","FFF4845F","FFF7B267"]',should_show_icon:"1",theme_name_with_subtitle:"Sushi"},{theme_color:"FF1ADB5B",theme_id:"557344741607350",theme_emoji:null,gradient:'["FFFFD200","FF6EDF00","FF00DFBB"]',should_show_icon:"1",theme_name_with_subtitle:"Citrus"},{theme_color:"FF4D3EC2",theme_id:"280333826736184",theme_emoji:null,gradient:'["FFFF625B","FFC532AD","FF4D3EC2"]',should_show_icon:"1",theme_name_with_subtitle:"Lollipop"},{theme_color:"FFFF311E",theme_id:"1257453361255152",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Rose"},{theme_color:"FFA797FF",theme_id:"571193503540759",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Lavender"},{theme_color:"FF6EDF00",theme_id:"3151463484918004",theme_emoji:null,gradient:null,should_show_icon:"1",theme_name_with_subtitle:"Kiwi"},{theme_color:"FF9D59D2",theme_id:"737761000603635",theme_emoji:"💛",gradient:'["FFFFD600","FFFCB37B","FF9D59D2","FF282828"]',should_show_icon:"",theme_name_with_subtitle:"Non-Binary"}];
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),t=require("npmlog");function a(e,t=""){if(e)return e;{const e=t.split(".").pop();return e===t?"":e}}function i(e){switch(e.__typename){case"MessageImage":return{type:"photo",ID:e.legacy_attachment_id,filename:e.filename,original_extension:a(e.original_extension,e.filename),thumbnailUrl:e.thumbnail.uri,previewUrl:e.preview.uri,previewWidth:e.preview.width,previewHeight:e.preview.height,largePreviewUrl:e.large_preview.uri,largePreviewHeight:e.large_preview.height,largePreviewWidth:e.large_preview.width,url:e.large_preview.uri,width:e.large_preview.width,height:e.large_preview.height,name:e.filename,attributionApp:e.attribution_app?{attributionAppID:e.attribution_app.id,name:e.attribution_app.name,logo:e.attribution_app.square_logo}:null};case"MessageAnimatedImage":return{type:"animated_image",ID:e.legacy_attachment_id,filename:e.filename,original_extension:a(e.original_extension,e.filename),previewUrl:e.preview_image.uri,previewWidth:e.preview_image.width,previewHeight:e.preview_image.height,url:e.animated_image.uri,width:e.animated_image.width,height:e.animated_image.height,thumbnailUrl:e.preview_image.uri,name:e.filename,facebookUrl:e.animated_image.uri,rawGifImage:e.animated_image.uri,animatedGifUrl:e.animated_image.uri,animatedGifPreviewUrl:e.preview_image.uri,animatedWebpUrl:e.animated_image.uri,animatedWebpPreviewUrl:e.preview_image.uri,attributionApp:e.attribution_app?{attributionAppID:e.attribution_app.id,name:e.attribution_app.name,logo:e.attribution_app.square_logo}:null};case"MessageVideo":return{type:"video",ID:e.legacy_attachment_id,filename:e.filename,original_extension:a(e.original_extension,e.filename),duration:e.playable_duration_in_ms,thumbnailUrl:e.large_image.uri,previewUrl:e.large_image.uri,previewWidth:e.large_image.width,previewHeight:e.large_image.height,url:e.playable_url,width:e.original_dimensions.x,height:e.original_dimensions.y,videoType:e.video_type.toLowerCase()};case"MessageFile":return{type:"file",ID:e.message_file_fbid,filename:e.filename,original_extension:a(e.original_extension,e.filename),url:e.url,isMalicious:e.is_malicious,contentType:e.content_type,name:e.filename,mimeType:"",fileSize:-1};case"MessageAudio":return{type:"audio",ID:e.url_shimhash,filename:e.filename,original_extension:a(e.original_extension,e.filename),duration:e.playable_duration_in_ms,audioType:e.audio_type,url:e.playable_url,isVoiceMail:e.is_voicemail};default:return{error:"Don't know about attachment type "+e.__typename}}}function n(e){return{reaction:e.reaction,userID:e.user.id}}function r(e){if(null==e)return{};switch(e.__typename){case"ThemeColorExtensibleMessageAdminText":return{color:e.theme_color};case"ThreadNicknameExtensibleMessageAdminText":return{nickname:e.nickname,participantID:e.participant_id};case"ThreadIconExtensibleMessageAdminText":return{threadIcon:e.thread_icon};case"InstantGameUpdateExtensibleMessageAdminText":return{gameID:null==e.game?null:e.game.id,update_type:e.update_type,collapsed_text:e.collapsed_text,expanded_text:e.expanded_text,instant_game_update_data:e.instant_game_update_data};case"GameScoreExtensibleMessageAdminText":return{game_type:e.game_type};case"RtcCallLogExtensibleMessageAdminText":return{event:e.event,is_video_call:e.is_video_call,server_info_data:e.server_info_data};case"GroupPollExtensibleMessageAdminText":return{event_type:e.event_type,total_count:e.total_count,question:e.question};case"AcceptPendingThreadExtensibleMessageAdminText":return{accepter_id:e.accepter_id,requester_id:e.requester_id};case"ConfirmFriendRequestExtensibleMessageAdminText":return{friend_request_recipient:e.friend_request_recipient,friend_request_sender:e.friend_request_sender};case"AddContactExtensibleMessageAdminText":return{contact_added_id:e.contact_added_id,contact_adder_id:e.contact_adder_id};case"AdExtensibleMessageAdminText":return{ad_client_token:e.ad_client_token,ad_id:e.ad_id,ad_preferences_link:e.ad_preferences_link,ad_properties:e.ad_properties};case"ParticipantJoinedGroupCallExtensibleMessageAdminText":case"ThreadEphemeralTtlModeExtensibleMessageAdminText":case"StartedSharingVideoExtensibleMessageAdminText":case"LightweightEventCreateExtensibleMessageAdminText":case"LightweightEventNotifyExtensibleMessageAdminText":case"LightweightEventNotifyBeforeEventExtensibleMessageAdminText":case"LightweightEventUpdateTitleExtensibleMessageAdminText":case"LightweightEventUpdateTimeExtensibleMessageAdminText":case"LightweightEventUpdateLocationExtensibleMessageAdminText":case"LightweightEventDeleteExtensibleMessageAdminText":return{};default:return{error:"Don't know what to with event data type "+e.__typename}}}module.exports=function(a,s,m){return function(s,d,_,l){let o=function(){},p=function(){};const g=new Promise((function(e,t){o=e,p=t}));l||(l=function(e,t){if(e)return p(e);o(t)});const c={av:m.globalOptions.pageID,queries:JSON.stringify({o0:{doc_id:"1498317363570230",query_params:{id:s,message_limit:d,load_messages:1,load_read_receipts:!1,before:_}}})};return a.post("https://www.facebook.com/api/graphqlbatch/",m.jar,c).then(e.parseAndCheckLogin(m,a)).then((function(t){if(t.error)throw t;if(0!==t[t.length-1].error_results)throw new Error("There was an error_result.");l(null,function(t){const a=t.o0.data.message_thread,s=a.thread_key.thread_fbid?a.thread_key.thread_fbid:a.thread_key.other_user_id;return a.messages.nodes.map((function(t){switch(t.__typename){case"UserMessage":var m;t.sticker&&(m=[{type:"sticker",ID:t.sticker.id,url:t.sticker.url,packID:t.sticker.pack?t.sticker.pack.id:null,spriteUrl:t.sticker.sprite_image,spriteUrl2x:t.sticker.sprite_image_2x,width:t.sticker.width,height:t.sticker.height,caption:t.snippet,description:t.sticker.label,frameCount:t.sticker.frame_count,frameRate:t.sticker.frame_rate,framesPerRow:t.sticker.frames_per_row,framesPerCol:t.sticker.frames_per_col,stickerID:t.sticker.id,spriteURI:t.sticker.sprite_image,spriteURI2x:t.sticker.sprite_image_2x}]);var d={};return null!==t.message&&t.message.ranges.forEach((e=>{d[e.entity.id]=t.message.text.substr(e.offset,e.length)})),{type:"message",attachments:m||(t.blob_attachments&&t.blob_attachments.length>0?t.blob_attachments.map(i):t.extensible_attachment?[(_=t.extensible_attachment,_.story_attachment?{type:"share",ID:_.legacy_attachment_id,url:_.story_attachment.url,title:_.story_attachment.title_with_entities.text,description:_.story_attachment.description&&_.story_attachment.description.text,source:null==_.story_attachment.source?null:_.story_attachment.source.text,image:null==_.story_attachment.media||null==_.story_attachment.media.animated_image&&null==_.story_attachment.media.image?null:(_.story_attachment.media.animated_image||_.story_attachment.media.image).uri,width:null==_.story_attachment.media||null==_.story_attachment.media.animated_image&&null==_.story_attachment.media.image?null:(_.story_attachment.media.animated_image||_.story_attachment.media.image).width,height:null==_.story_attachment.media||null==_.story_attachment.media.animated_image&&null==_.story_attachment.media.image?null:(_.story_attachment.media.animated_image||_.story_attachment.media.image).height,playable:null==_.story_attachment.media?null:_.story_attachment.media.is_playable,duration:null==_.story_attachment.media?null:_.story_attachment.media.playable_duration_in_ms,playableUrl:null==_.story_attachment.media?null:_.story_attachment.media.playable_url,subattachments:_.story_attachment.subattachments,properties:_.story_attachment.properties.reduce((function(e,t){return e[t.key]=t.value.text,e}),{}),animatedImageSize:"",facebookUrl:"",styleList:"",target:"",thumbnailUrl:null==_.story_attachment.media||null==_.story_attachment.media.animated_image&&null==_.story_attachment.media.image?null:(_.story_attachment.media.animated_image||_.story_attachment.media.image).uri,thumbnailWidth:null==_.story_attachment.media||null==_.story_attachment.media.animated_image&&null==_.story_attachment.media.image?null:(_.story_attachment.media.animated_image||_.story_attachment.media.image).width,thumbnailHeight:null==_.story_attachment.media||null==_.story_attachment.media.animated_image&&null==_.story_attachment.media.image?null:(_.story_attachment.media.animated_image||_.story_attachment.media.image).height}:{error:"Don't know what to do with extensible_attachment."})]:[]),body:null!==t.message?t.message.text:"",isGroup:"GROUP"===a.thread_type,messageID:t.message_id,senderID:t.message_sender.id,threadID:s,timestamp:t.timestamp_precise,mentions:d,isUnread:t.unread,messageReactions:t.message_reactions?t.message_reactions.map(n):null,isSponsored:t.is_sponsored,snippet:t.snippet};case"ThreadNameMessage":return{type:"event",messageID:t.message_id,threadID:s,isGroup:"GROUP"===a.thread_type,senderID:t.message_sender.id,timestamp:t.timestamp_precise,eventType:"change_thread_name",snippet:t.snippet,eventData:{threadName:t.thread_name},author:t.message_sender.id,logMessageType:"log:thread-name",logMessageData:{name:t.thread_name}};case"ThreadImageMessage":return{type:"event",messageID:t.message_id,threadID:s,isGroup:"GROUP"===a.thread_type,senderID:t.message_sender.id,timestamp:t.timestamp_precise,eventType:"change_thread_image",snippet:t.snippet,eventData:null==t.image_with_metadata?{}:{threadImage:{attachmentID:t.image_with_metadata.legacy_attachment_id,width:t.image_with_metadata.original_dimensions.x,height:t.image_with_metadata.original_dimensions.y,url:t.image_with_metadata.preview.uri}},logMessageType:"log:thread-icon",logMessageData:{thread_icon:t.image_with_metadata?t.image_with_metadata.preview.uri:null}};case"ParticipantLeftMessage":return{type:"event",messageID:t.message_id,threadID:s,isGroup:"GROUP"===a.thread_type,senderID:t.message_sender.id,timestamp:t.timestamp_precise,eventType:"remove_participants",snippet:t.snippet,eventData:{participantsRemoved:t.participants_removed.map((function(e){return e.id}))},logMessageType:"log:unsubscribe",logMessageData:{leftParticipantFbId:t.participants_removed.map((function(e){return e.id}))}};case"ParticipantsAddedMessage":return{type:"event",messageID:t.message_id,threadID:s,isGroup:"GROUP"===a.thread_type,senderID:t.message_sender.id,timestamp:t.timestamp_precise,eventType:"add_participants",snippet:t.snippet,eventData:{participantsAdded:t.participants_added.map((function(e){return e.id}))},logMessageType:"log:subscribe",logMessageData:{addedParticipants:t.participants_added.map((function(e){return e.id}))}};case"VideoCallMessage":return{type:"event",messageID:t.message_id,threadID:s,isGroup:"GROUP"===a.thread_type,senderID:t.message_sender.id,timestamp:t.timestamp_precise,eventType:"video_call",snippet:t.snippet,logMessageType:"other"};case"VoiceCallMessage":return{type:"event",messageID:t.message_id,threadID:s,isGroup:"GROUP"===a.thread_type,senderID:t.message_sender.id,timestamp:t.timestamp_precise,eventType:"voice_call",snippet:t.snippet,logMessageType:"other"};case"GenericAdminTextMessage":return{type:"event",messageID:t.message_id,threadID:s,isGroup:"GROUP"===a.thread_type,senderID:t.message_sender.id,timestamp:t.timestamp_precise,snippet:t.snippet,eventType:t.extensible_message_admin_text_type.toLowerCase(),eventData:r(t.extensible_message_admin_text),logMessageType:e.getAdminTextMessageType(t.extensible_message_admin_text_type),logMessageData:t.extensible_message_admin_text};default:return{error:"Don't know about message type "+t.__typename}}var _}))}(t[0]))})).catch((function(e){return t.error("getThreadHistoryGraphQL",e),l(e)})),g}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),t=require("npmlog");function n(e){return{reminderID:e.id,eventCreatorID:e.lightweight_event_creator.id,time:e.time,eventType:e.lightweight_event_type.toLowerCase(),locationName:e.location_name,locationCoordinates:e.location_coordinates,locationPage:e.location_page,eventStatus:e.lightweight_event_status.toLowerCase(),note:e.note,repeatMode:e.repeat_mode.toLowerCase(),eventTitle:e.event_title,triggerMessage:e.trigger_message,secondsToNotifyBefore:e.seconds_to_notify_before,allowsRsvp:e.allows_rsvp,relatedEvent:e.related_event,members:e.event_reminder_members.edges.map((function(e){return{memberID:e.node.id,state:e.guest_list_state.toLowerCase()}}))}}function a(e){if(e.errors)return e.errors;const t=e.message_thread;if(!t)return null;const a=t.last_message,i=a&&a.nodes&&a.nodes[0]&&a.nodes[0].message_sender&&a.nodes[0].message_sender.messaging_actor?a.nodes[0].message_sender.messaging_actor.id:null,s=a&&a.nodes&&a.nodes[0]?a.nodes[0].snippet:null,o=t.last_read_receipt,r=o&&o.nodes&&o.nodes[0]&&o.nodes[0].timestamp_precise?o.nodes[0].timestamp_precise:null;return{threadID:t.thread_key.thread_fbid?t.thread_key.thread_fbid:t.thread_key.other_user_id,threadName:t.name,participantIDs:t.all_participants.edges.map((e=>e.node.messaging_actor.id)),userInfo:t.all_participants.edges.map((e=>({id:e.node.messaging_actor.id,name:e.node.messaging_actor.name,firstName:e.node.messaging_actor.short_name,vanity:e.node.messaging_actor.username,url:e.node.messaging_actor.url,thumbSrc:e.node.messaging_actor.big_image_src.uri,profileUrl:e.node.messaging_actor.big_image_src.uri,gender:e.node.messaging_actor.gender,type:e.node.messaging_actor.__typename,isFriend:e.node.messaging_actor.is_viewer_friend,isBirthday:!!e.node.messaging_actor.is_birthday}))),unreadCount:t.unread_count,messageCount:t.messages_count,timestamp:t.updated_time_precise,muteUntil:t.mute_until,isGroup:"GROUP"==t.thread_type,isSubscribed:t.is_viewer_subscribed,isArchived:t.has_viewer_archived,folder:t.folder,cannotReplyReason:t.cannot_reply_reason,eventReminders:t.event_reminders?t.event_reminders.nodes.map(n):null,emoji:t.customization_info?t.customization_info.emoji:null,color:t.customization_info&&t.customization_info.outgoing_bubble_color?t.customization_info.outgoing_bubble_color.slice(2):null,threadTheme:t.thread_theme,nicknames:t.customization_info&&t.customization_info.participant_customizations?t.customization_info.participant_customizations.reduce((function(e,t){return t.nickname&&(e[t.participant_id]=t.nickname),e}),{}):{},adminIDs:t.thread_admins,approvalMode:Boolean(t.approval_mode),approvalQueue:t.group_approval_queue.nodes.map((e=>({inviterID:e.inviter.id,requesterID:e.requester.id,timestamp:e.request_timestamp,request_source:e.request_source}))),reactionsMuteMode:t.reactions_mute_mode.toLowerCase(),mentionsMuteMode:t.mentions_mute_mode.toLowerCase(),isPinProtected:t.is_pin_protected,relatedPageThread:t.related_page_thread,name:t.name,snippet:s,snippetSender:i,snippetAttachments:[],serverTimestamp:t.updated_time_precise,imageSrc:t.image?t.image.uri:null,isCanonicalUser:t.is_canonical_neo_user,isCanonical:"GROUP"!=t.thread_type,recipientsLoadable:!0,hasEmailParticipant:!1,readOnly:!1,canReply:null==t.cannot_reply_reason,lastMessageTimestamp:t.last_message?t.last_message.timestamp_precise:null,lastMessageType:"message",lastReadTimestamp:r,threadType:"GROUP"==t.thread_type?2:1,inviteLink:{enable:!!t.joinable_mode&&1==t.joinable_mode.mode,link:t.joinable_mode?t.joinable_mode.link:null}}}module.exports=function(n,i,s){return function(i,o){let r=function(){},_=function(){};const d=new Promise((function(e,t){r=e,_=t}));"Function"!=e.getType(o)&&"AsyncFunction"!=e.getType(o)&&(o=function(e,t){if(e)return _(e);r(t)}),"Array"!==e.getType(i)&&(i=[i]);let m={};return i.map((function(e,t){m["o"+t]={doc_id:"3449967031715030",query_params:{id:e,message_limit:0,load_messages:!1,load_read_receipts:!1,before:null}}})),m={queries:JSON.stringify(m),batch_name:"MessengerGraphQLThreadFetcher"},n.post("https://www.facebook.com/api/graphqlbatch/",s.jar,m).then(e.parseAndCheckLogin(s,n)).then((function(e){if(e.error)throw e;const t={};for(let n=e.length-2;n>=0;n--){const s=a(e[n][Object.keys(e[n])[0]].data);t[s?.threadID||i[i.length-1-n]]=s}1==Object.values(t).length?o(null,Object.values(t)[0]):o(null,t)})).catch((function(e){return t.error("getThreadInfoGraphQL",e),o(e)})),d}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),t=require("npmlog");function n(e){return{reminderID:e.id,eventCreatorID:e.lightweight_event_creator.id,time:e.time,eventType:e.lightweight_event_type.toLowerCase(),locationName:e.location_name,locationCoordinates:e.location_coordinates,locationPage:e.location_page,eventStatus:e.lightweight_event_status.toLowerCase(),note:e.note,repeatMode:e.repeat_mode.toLowerCase(),eventTitle:e.event_title,triggerMessage:e.trigger_message,secondsToNotifyBefore:e.seconds_to_notify_before,allowsRsvp:e.allows_rsvp,relatedEvent:e.related_event,members:e.event_reminder_members.edges.map((function(e){return{memberID:e.node.id,state:e.guest_list_state.toLowerCase()}}))}}module.exports=function(s,i,a){return function(i,r,o,m){if(m||"Function"!==e.getType(o)&&"AsyncFunction"!==e.getType(o)||(m=o,o=[""]),"Number"!==e.getType(i)||!Number.isInteger(i)||i<=0)throw{error:"getThreadList: limit must be a positive integer"};if("Null"!==e.getType(r)&&("Number"!==e.getType(r)||!Number.isInteger(r)))throw{error:"getThreadList: timestamp must be an integer or null"};if("String"===e.getType(o)&&(o=[o]),"Array"!==e.getType(o))throw{error:"getThreadList: tags must be an array"};let d=function(){},_=function(){};const c=new Promise((function(e,t){d=e,_=t}));"Function"!==e.getType(m)&&"AsyncFunction"!==e.getType(m)&&(m=function(e,t){if(e)return _(e);d(t)});const u={av:a.globalOptions.pageID,queries:JSON.stringify({o0:{doc_id:"3336396659757871",query_params:{limit:i+(r?1:0),before:r,tags:o,includeDeliveryReceipts:!0,includeSeqID:!1}}}),batch_name:"MessengerGraphQLThreadlistFetcher"};return s.post("https://www.facebook.com/api/graphqlbatch/",a.jar,u).then(e.parseAndCheckLogin(a,s)).then((e=>{if(e[e.length-1].error_results>0)throw e[0].o0.errors;if(0===e[e.length-1].successful_results)throw{error:"getThreadList: there was no successful_results",res:e};r&&e[0].o0.data.viewer.message_threads.nodes.shift(),m(null,e[0].o0.data.viewer.message_threads.nodes.map((e=>function(e){const t=e.last_message,s=t&&t.nodes&&t.nodes[0]&&t.nodes[0].message_sender&&t.nodes[0].message_sender.messaging_actor?t.nodes[0].message_sender.messaging_actor.id:null,i=t&&t.nodes&&t.nodes[0]?t.nodes[0].snippet:null,a=e.last_read_receipt,r=a&&a.nodes&&a.nodes[0]&&a.nodes[0].timestamp_precise?a.nodes[0].timestamp_precise:null;return{threadID:e.thread_key.thread_fbid?e.thread_key.thread_fbid:e.thread_key.other_user_id,threadName:e.name,participantIDs:e.all_participants.edges.map((e=>e.node.messaging_actor.id)),userInfo:e.all_participants.edges.map((e=>({id:e.node.messaging_actor.id,name:e.node.messaging_actor.name,firstName:e.node.messaging_actor.short_name,vanity:e.node.messaging_actor.username,url:e.node.messaging_actor.url,thumbSrc:e.node.messaging_actor.big_image_src.uri,profileUrl:e.node.messaging_actor.big_image_src.uri,gender:e.node.messaging_actor.gender,type:e.node.messaging_actor.__typename,isFriend:e.node.messaging_actor.is_viewer_friend,isBirthday:!!e.node.messaging_actor.is_birthday}))),unreadCount:e.unread_count,messageCount:e.messages_count,timestamp:e.updated_time_precise,muteUntil:e.mute_until,isGroup:"GROUP"==e.thread_type,isSubscribed:e.is_viewer_subscribed,isArchived:e.has_viewer_archived,folder:e.folder,cannotReplyReason:e.cannot_reply_reason,eventReminders:e.event_reminders?e.event_reminders.nodes.map(n):null,emoji:e.customization_info?e.customization_info.emoji:null,color:e.customization_info&&e.customization_info.outgoing_bubble_color?e.customization_info.outgoing_bubble_color.slice(2):null,threadTheme:e.thread_theme,nicknames:e.customization_info&&e.customization_info.participant_customizations?e.customization_info.participant_customizations.reduce((function(e,t){return t.nickname&&(e[t.participant_id]=t.nickname),e}),{}):{},adminIDs:e.thread_admins,approvalMode:Boolean(e.approval_mode),approvalQueue:e.group_approval_queue.nodes.map((e=>({inviterID:e.inviter.id,requesterID:e.requester.id,timestamp:e.request_timestamp,request_source:e.request_source}))),reactionsMuteMode:e.reactions_mute_mode.toLowerCase(),mentionsMuteMode:e.mentions_mute_mode.toLowerCase(),isPinProtected:e.is_pin_protected,relatedPageThread:e.related_page_thread,name:e.name,snippet:i,snippetSender:s,snippetAttachments:[],serverTimestamp:e.updated_time_precise,imageSrc:e.image?e.image.uri:null,isCanonicalUser:e.is_canonical_neo_user,isCanonical:"GROUP"!=e.thread_type,recipientsLoadable:!0,hasEmailParticipant:!1,readOnly:!1,canReply:null==e.cannot_reply_reason,lastMessageTimestamp:e.last_message?e.last_message.timestamp_precise:null,lastMessageType:"message",lastReadTimestamp:r,threadType:"GROUP"==e.thread_type?2:1,inviteLink:{enable:!!e.joinable_mode&&1==e.joinable_mode.mode,link:e.joinable_mode?e.joinable_mode.link:null}}}(e))))})).catch((e=>(t.error("getThreadList",e),m(e)))),c}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),t=require("npmlog");module.exports=function(r,n,o){return function(n,a,i,s){let u=function(){},h=function(){};const c=new Promise((function(e,t){u=e,h=t}));s||(s=function(e,t){if(e)return h(e);u(t)});let m={thread_id:n,offset:a,limit:i};return r.post("https://www.facebook.com/ajax/messaging/attachments/sharedphotos.php",o.jar,m).then(e.parseAndCheckLogin(o,r)).then((function(t){if(t.error)throw t;return Promise.all(t.payload.imagesData.map((function(t){return m={thread_id:n,image_id:t.fbid},r.post("https://www.facebook.com/ajax/messaging/attachments/sharedphotos.php",o.jar,m).then(e.parseAndCheckLogin(o,r)).then((function(e){if(e.error)throw e;return e.jsmods.require[0][3][1].query_results[e.jsmods.require[0][3][1].query_metadata.query_path[0].message_thread].message_images.edges[0].node.image2}))})))})).then((function(e){s(null,e)})).catch((function(e){t.error("Error in getThreadPictures",e),s(e)})),c}};
|
package/src/getUserID.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),r=require("npmlog");function t(r){return{userID:e.formatID(r.uid.toString()),photoUrl:r.photo,indexRank:r.index_rank,name:r.text,isVerified:r.is_verified,profileUrl:r.path,category:r.category,score:r.score,type:r.type}}module.exports=function(n,o,i){return function(o,c){let u=function(){},a=function(){};const s=new Promise((function(e,r){u=e,a=r}));c||(c=function(e,r){if(e)return a(e);u(r)});const p={value:o.toLowerCase(),viewer:i.i_userID||i.userID,rsp:"search",context:"search",path:"/home.php",request_id:e.getGUID()};return n.get("https://www.facebook.com/ajax/typeahead/search.php",i.jar,p).then(e.parseAndCheckLogin(i,n)).then((function(e){if(e.error)throw e;c(null,e.payload.entries.map(t))})).catch((function(e){return r.error("getUserID",e),c(e)})),s}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const n=require("../utils"),e=require("npmlog");module.exports=function(r,t,o){return function(t,i){let s=function(){},a=function(){};const c=new Promise((function(n,e){s=n,a=e}));i||(i=function(n,e){if(n)return a(n);s(e)}),"Array"!==n.getType(t)&&(t=[t]);const u={};return t.map((function(n,e){u["ids["+e+"]"]=n})),r.post("https://www.facebook.com/chat/user_info/",o.jar,u).then(n.parseAndCheckLogin(o,r)).then((function(n){if(n.error)throw n;return i(null,function(n){const e={};for(const r in n)if(n.hasOwnProperty(r)){const t=n[r];e[r]={name:t.name,firstName:t.firstName,vanity:t.vanity,thumbSrc:t.thumbSrc,profileUrl:t.uri,gender:t.gender,type:t.type,isFriend:t.is_friend,isBirthday:!!t.is_birthday,searchTokens:t.searchTokens,alternateName:t.alternateName}}return e}(n.payload.profiles))})).catch((function(n){return e.error("getUserInfo",n),i(n)})),c}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),r=require("npmlog");module.exports=function(n,t,o){return function(t,i,s){if("Boolean"!==e.getType(i))throw{error:"Please pass a boolean as a second argument."};let u=function(){},c=function(){};const a=new Promise((function(e,r){u=e,c=r}));return s||(s=function(e,r){if(e)return c(e);u(r)}),n.post("https://www.facebook.com/requests/friends/ajax/",o.jar,{viewer_id:o.i_userID||o.userID,"frefs[0]":"jwl",floc:"friend_center_requests",ref:"/reqs.php",action:i?"confirm":"reject"}).then(e.parseAndCheckLogin(o,n)).then((function(e){if(e.payload.err)throw{err:e.payload.err};return s()})).catch((function(e){return r.error("handleFriendRequest",e),s(e)})),a}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const e=require("../utils"),n=require("npmlog");module.exports=function(r,t,o){return function(t,c,u){if("Boolean"!==e.getType(c))throw{error:"Please pass a boolean as a second argument."};let a=function(){},i=function(){};const s=new Promise((function(e,n){a=e,i=n}));u||(u=function(e,n){if(e)return i(e);a(n)});const f={client:"mercury"};"Array"!==e.getType(t)&&(t=[t]);const h=c?"inbox":"other";for(let e=0;e<t.length;e++)f[h+"["+e+"]"]=t[e];return r.post("https://www.facebook.com/ajax/mercury/move_thread.php",o.jar,f).then(e.parseAndCheckLogin(o,r)).then((function(e){if(e.error)throw e;return u()})).catch((function(e){return n.error("handleMessageRequest",e),u(e)})),s}};
|
package/src/httpGet.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
const n=require("../utils"),t=require("npmlog");module.exports=function(e,o,r){return function(o,u,c,i,l){let f=function(){},g=function(){};const p=new Promise((function(n,t){f=n,g=t}));return"Function"!=n.getType(u)&&"AsyncFunction"!=n.getType(u)||(i=u,u={}),"Function"!=n.getType(c)&&"AsyncFunction"!=n.getType(c)||(i=c,c={}),c=c||{},i=i||function(n,t){if(n)return g(n);f(t)},l?n.get(o,r.jar,u,r.globalOptions,r,c).then((function(n){i(null,n.body)})).catch((function(n){return t.error("httpGet",n),i(n)})):e.get(o,r.jar,u,null,c).then((function(n){i(null,n.body)})).catch((function(n){return t.error("httpGet",n),i(n)})),p}};
|
package/src/httpPost.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
const n=require("../utils"),t=require("npmlog");module.exports=function(o,e,r){return function(e,u,c,i,s){let f=function(){},p=function(){};const l=new Promise((function(n,t){f=n,p=t}));return"Function"!=n.getType(u)&&"AsyncFunction"!=n.getType(u)||(i=u,u={}),"Function"!=n.getType(c)&&"AsyncFunction"!=n.getType(c)||(i=c,c={}),c=c||{},i=i||function(n,t){if(n)return p(n);f(t)},s?n.post(e,r.jar,u,r.globalOptions,r,c).then((function(n){i(null,n.body)})).catch((function(n){return t.error("httpPost",n),i(n)})):o.post(e,r.jar,u,{},c).then((function(n){i(null,n.body)})).catch((function(n){return t.error("httpPost",n),i(n)})),l}};
|
@@ -0,0 +1 @@
|
|
1
|
+
const t=require("../utils"),n=require("npmlog");module.exports=function(o,r,e){return function(r,u,c,i,l){let a=function(){},f=function(){};const p=new Promise((function(t,n){a=t,f=n}));return"Function"!=t.getType(u)&&"AsyncFunction"!=t.getType(u)||(i=u,u={}),"Function"!=t.getType(c)&&"AsyncFunction"!=t.getType(c)||(i=c,c={}),c=c||{},i=i||function(t,n){if(t)return f(t);a(n)},l?t.postFormData(r,e.jar,u,e.globalOptions,e,c).then((function(t){i(null,t.body.toString())})).catch((function(t){return n.error("httpGet",t),i(t)})):o.postFormData(r,e.jar,u,null,c).then((function(t){i(null,t.body.toString())})).catch((function(t){return n.error("httpPostFormData",t),i(t)})),p}};
|