alicezetion 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.cache/replit/__replit_disk_meta.json +1 -1
- package/.cache/replit/nix/env.json +1 -1
- package/alice/addExternalModule.js +19 -0
- package/alice/{add.js → addUserToGroup.js} +16 -2
- package/alice/{admin.js → changeAdminStatus.js} +17 -3
- package/alice/{archive.js → changeArchivedStatus.js} +16 -2
- package/alice/changeBio.js +77 -0
- package/alice/changeBlockedStatus.js +47 -0
- package/alice/{gcimage.js → changeGroupImage.js} +16 -2
- package/alice/{nickname.js → changeNickname.js} +17 -2
- package/alice/changeThreadColor.js +71 -0
- package/alice/{emoji.js → changeThreadEmoji.js} +16 -2
- package/alice/createNewGroup.js +86 -0
- package/alice/{poll.js → createPoll.js} +18 -2
- package/alice/{deletemsg.js → deleteMessage.js} +15 -2
- package/alice/{deletegc.js → deleteThread.js} +15 -2
- package/alice/{forward.js → forwardAttachment.js} +16 -3
- package/alice/{id.js → getCurrentUserID.js} +1 -1
- package/alice/{friend.js → getFriendsList.js} +17 -3
- package/alice/{history.js → getThreadHistory.js} +19 -6
- package/alice/{gchistorydeprecated.js → getThreadHistoryDeprecated.js} +18 -1
- package/alice/{gcinfo.js → getThreadInfo.js} +49 -13
- package/alice/{gcinfodeprecated.js → getThreadInfoDeprecated.js} +17 -2
- package/alice/{gclist.js → getThreadList.js} +27 -9
- package/alice/{gclistdeprecated.js → getThreadListDeprecated.js} +1 -1
- package/alice/{gcimg.js → getThreadPictures.js} +15 -2
- package/alice/{userid.js → getUserID.js} +16 -2
- package/alice/{userinfo.js → getUserInfo.js} +18 -3
- package/alice/handleFriendRequest.js +61 -0
- package/alice/{msgrequest.js → handleMessageRequest.js} +16 -2
- package/alice/httpGet.js +52 -0
- package/alice/httpPost.js +52 -0
- package/alice/listenMqtt.js +363 -134
- package/alice/logout.js +18 -2
- package/alice/{delivered.js → markAsDelivered.js} +19 -2
- package/alice/markAsRead.js +80 -0
- package/alice/{seen.js → markAsReadAll.js} +16 -2
- package/alice/markAsSeen.js +59 -0
- package/alice/{mute.js → muteThread.js} +16 -2
- package/alice/{kick.js → removeUserFromGroup.js} +16 -2
- package/alice/{resolveimgurl.js → resolvePhotoUrl.js} +16 -2
- package/alice/{gcsearch.js → searchForThread.js} +16 -2
- package/alice/{chat.js → sendMessage.js} +78 -34
- package/alice/sendTypingIndicator.js +103 -0
- package/alice/{react.js → setMessageReaction.js} +39 -4
- package/alice/setPostReaction.js +76 -0
- package/alice/{title.js → setTitle.js} +16 -3
- package/alice/threadColors.js +57 -0
- package/alice/unfriend.js +52 -0
- package/alice/{unsend.js → unsendMessage.js} +16 -2
- package/index.js +324 -143
- package/package.json +27 -18
- package/utils.js +137 -61
- package/.cache/replit/modules.stamp +0 -0
- package/README.md +0 -40
- package/alice/block.js +0 -72
- package/alice/color.js +0 -53
- package/alice/gcolor.js +0 -22
- package/alice/listen.js +0 -553
- package/alice/read.js +0 -52
- package/alice/typeindicator.js +0 -77
- /package/alice/{emojiurl.js → getEmojiUrl.js} +0 -0
@@ -3,10 +3,21 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function forwardAttachment(attachmentID, userOrUsers, callback) {
|
8
|
+
var resolveFunc = function(){};
|
9
|
+
var rejectFunc = function(){};
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
|
+
resolveFunc = resolve;
|
12
|
+
rejectFunc = reject;
|
13
|
+
});
|
8
14
|
if (!callback) {
|
9
|
-
callback = function() {
|
15
|
+
callback = function(err) {
|
16
|
+
if (err) {
|
17
|
+
return rejectFunc(err);
|
18
|
+
}
|
19
|
+
resolveFunc();
|
20
|
+
};
|
10
21
|
}
|
11
22
|
|
12
23
|
var form = {
|
@@ -37,11 +48,13 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
37
48
|
throw resData;
|
38
49
|
}
|
39
50
|
|
40
|
-
return callback(
|
51
|
+
return callback();
|
41
52
|
})
|
42
53
|
.catch(function(err) {
|
43
54
|
log.error("forwardAttachment", err);
|
44
55
|
return callback(err);
|
45
56
|
});
|
57
|
+
|
58
|
+
return returnPromise;
|
46
59
|
};
|
47
60
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var cheerio = require("cheerio");
|
3
|
+
//var cheerio = require("cheerio");
|
4
4
|
var utils = require("../utils");
|
5
5
|
var log = require("npmlog");
|
6
6
|
|
@@ -39,10 +39,22 @@ function formatData(obj) {
|
|
39
39
|
});
|
40
40
|
}
|
41
41
|
|
42
|
-
module.exports = function(defaultFuncs,
|
42
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
43
43
|
return function getFriendsList(callback) {
|
44
|
+
var resolveFunc = function(){};
|
45
|
+
var rejectFunc = function(){};
|
46
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
47
|
+
resolveFunc = resolve;
|
48
|
+
rejectFunc = reject;
|
49
|
+
});
|
50
|
+
|
44
51
|
if (!callback) {
|
45
|
-
|
52
|
+
callback = function (err, friendList) {
|
53
|
+
if (err) {
|
54
|
+
return rejectFunc(err);
|
55
|
+
}
|
56
|
+
resolveFunc(friendList);
|
57
|
+
};
|
46
58
|
}
|
47
59
|
|
48
60
|
defaultFuncs
|
@@ -66,5 +78,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
66
78
|
log.error("getFriendsList", err);
|
67
79
|
return callback(err);
|
68
80
|
});
|
81
|
+
|
82
|
+
return returnPromise;
|
69
83
|
};
|
70
84
|
};
|
@@ -103,7 +103,6 @@ function formatAttachmentsGraphQLResponse(attachment) {
|
|
103
103
|
duration: attachment.playable_duration_in_ms,
|
104
104
|
videoType: attachment.video_type.toLowerCase()
|
105
105
|
};
|
106
|
-
break;
|
107
106
|
case "MessageFile":
|
108
107
|
return {
|
109
108
|
type: "file",
|
@@ -364,14 +363,14 @@ function formatMessagesGraphQLResponse(data) {
|
|
364
363
|
// Give priority to stickers. They're seen as normal messages but we've
|
365
364
|
// been considering them as attachments.
|
366
365
|
var maybeStickerAttachment;
|
367
|
-
if (d.sticker
|
366
|
+
if (d.sticker) {
|
368
367
|
maybeStickerAttachment = [
|
369
368
|
{
|
370
369
|
type: "sticker",
|
371
370
|
ID: d.sticker.id,
|
372
371
|
url: d.sticker.url,
|
373
372
|
|
374
|
-
packID: d.sticker.pack
|
373
|
+
packID: d.sticker.pack.id,
|
375
374
|
spriteUrl: d.sticker.sprite_image,
|
376
375
|
spriteUrl2x: d.sticker.sprite_image_2x,
|
377
376
|
width: d.sticker.width,
|
@@ -578,15 +577,27 @@ function formatMessagesGraphQLResponse(data) {
|
|
578
577
|
return messages;
|
579
578
|
}
|
580
579
|
|
581
|
-
module.exports = function(defaultFuncs,
|
580
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
582
581
|
return function getThreadHistoryGraphQL(
|
583
582
|
threadID,
|
584
583
|
amount,
|
585
584
|
timestamp,
|
586
585
|
callback
|
587
586
|
) {
|
587
|
+
var resolveFunc = function(){};
|
588
|
+
var rejectFunc = function(){};
|
589
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
590
|
+
resolveFunc = resolve;
|
591
|
+
rejectFunc = reject;
|
592
|
+
});
|
593
|
+
|
588
594
|
if (!callback) {
|
589
|
-
|
595
|
+
callback = function (err, data) {
|
596
|
+
if (err) {
|
597
|
+
return rejectFunc(err);
|
598
|
+
}
|
599
|
+
resolveFunc(data);
|
600
|
+
};
|
590
601
|
}
|
591
602
|
|
592
603
|
// `queries` has to be a string. I couldn't tell from the dev console. This
|
@@ -619,7 +630,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
619
630
|
// failure one.
|
620
631
|
// @TODO What do we do in this case?
|
621
632
|
if (resData[resData.length - 1].error_results !== 0) {
|
622
|
-
throw new Error("
|
633
|
+
throw new Error("There was an error_result.");
|
623
634
|
}
|
624
635
|
|
625
636
|
callback(null, formatMessagesGraphQLResponse(resData[0]));
|
@@ -628,5 +639,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
628
639
|
log.error("getThreadHistoryGraphQL", err);
|
629
640
|
return callback(err);
|
630
641
|
});
|
642
|
+
|
643
|
+
return returnPromise;
|
631
644
|
};
|
632
645
|
};
|
@@ -3,8 +3,24 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function getThreadHistory(threadID, amount, timestamp, callback) {
|
8
|
+
var resolveFunc = function(){};
|
9
|
+
var rejectFunc = function(){};
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
|
+
resolveFunc = resolve;
|
12
|
+
rejectFunc = reject;
|
13
|
+
});
|
14
|
+
|
15
|
+
if (!callback) {
|
16
|
+
callback = function (err, friendList) {
|
17
|
+
if (err) {
|
18
|
+
return rejectFunc(err);
|
19
|
+
}
|
20
|
+
resolveFunc(friendList);
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
8
24
|
if (!callback) {
|
9
25
|
throw { error: "getThreadHistory: need callback" };
|
10
26
|
}
|
@@ -72,5 +88,6 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
72
88
|
return callback(err);
|
73
89
|
});
|
74
90
|
});
|
91
|
+
return returnPromise;
|
75
92
|
};
|
76
93
|
};
|
@@ -31,7 +31,12 @@ function formatEventReminders(reminder) {
|
|
31
31
|
}
|
32
32
|
|
33
33
|
function formatThreadGraphQLResponse(data) {
|
34
|
-
|
34
|
+
try{
|
35
|
+
var messageThread = data.o0.data.message_thread;
|
36
|
+
} catch (err){
|
37
|
+
console.error("GetThreadInfoGraphQL", "Can't get this thread info!");
|
38
|
+
return {err: err};
|
39
|
+
}
|
35
40
|
var threadID = messageThread.thread_key.thread_fbid
|
36
41
|
? messageThread.thread_key.thread_fbid
|
37
42
|
: messageThread.thread_key.other_user_id;
|
@@ -57,9 +62,19 @@ function formatThreadGraphQLResponse(data) {
|
|
57
62
|
return {
|
58
63
|
threadID: threadID,
|
59
64
|
threadName: messageThread.name,
|
60
|
-
participantIDs: messageThread.all_participants.
|
61
|
-
|
62
|
-
|
65
|
+
participantIDs: messageThread.all_participants.edges.map(d => d.node.messaging_actor.id),
|
66
|
+
userInfo: messageThread.all_participants.edges.map(d => ({
|
67
|
+
id: d.node.messaging_actor.id,
|
68
|
+
name: d.node.messaging_actor.name,
|
69
|
+
firstName: d.node.messaging_actor.short_name,
|
70
|
+
vanity: d.node.messaging_actor.username,
|
71
|
+
thumbSrc: d.node.messaging_actor.big_image_src.uri,
|
72
|
+
profileUrl: d.node.messaging_actor.big_image_src.uri,
|
73
|
+
gender: d.node.messaging_actor.gender,
|
74
|
+
type: d.node.messaging_actor.__typename,
|
75
|
+
isFriend: d.node.messaging_actor.is_viewer_friend,
|
76
|
+
isBirthday: !!d.node.messaging_actor.is_birthday //not sure?
|
77
|
+
})),
|
63
78
|
unreadCount: messageThread.unread_count,
|
64
79
|
messageCount: messageThread.messages_count,
|
65
80
|
timestamp: messageThread.updated_time_precise,
|
@@ -92,9 +107,15 @@ function formatThreadGraphQLResponse(data) {
|
|
92
107
|
)
|
93
108
|
: {},
|
94
109
|
adminIDs: messageThread.thread_admins,
|
110
|
+
approvalMode: Boolean(messageThread.approval_mode),
|
111
|
+
approvalQueue: messageThread.group_approval_queue.nodes.map(a => ({
|
112
|
+
inviterID: a.inviter.id,
|
113
|
+
requesterID: a.requester.id,
|
114
|
+
timestamp: a.request_timestamp,
|
115
|
+
request_source: a.request_source // @Undocumented
|
116
|
+
})),
|
95
117
|
|
96
118
|
// @Undocumented
|
97
|
-
topEmojis: messageThread.top_emojis,
|
98
119
|
reactionsMuteMode: messageThread.reactions_mute_mode.toLowerCase(),
|
99
120
|
mentionsMuteMode: messageThread.mentions_mute_mode.toLowerCase(),
|
100
121
|
isPinProtected: messageThread.is_pin_protected,
|
@@ -122,10 +143,22 @@ function formatThreadGraphQLResponse(data) {
|
|
122
143
|
};
|
123
144
|
}
|
124
145
|
|
125
|
-
module.exports = function(defaultFuncs,
|
146
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
126
147
|
return function getThreadInfoGraphQL(threadID, callback) {
|
127
|
-
|
128
|
-
|
148
|
+
var resolveFunc = function(){};
|
149
|
+
var rejectFunc = function(){};
|
150
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
151
|
+
resolveFunc = resolve;
|
152
|
+
rejectFunc = reject;
|
153
|
+
});
|
154
|
+
|
155
|
+
if (utils.getType(callback) != "Function" && utils.getType(callback) != "AsyncFunction") {
|
156
|
+
callback = function (err, data) {
|
157
|
+
if (err) {
|
158
|
+
return rejectFunc(err);
|
159
|
+
}
|
160
|
+
resolveFunc(data);
|
161
|
+
};
|
129
162
|
}
|
130
163
|
|
131
164
|
// `queries` has to be a string. I couldn't tell from the dev console. This
|
@@ -133,17 +166,18 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
133
166
|
var form = {
|
134
167
|
queries: JSON.stringify({
|
135
168
|
o0: {
|
136
|
-
// This doc_id is valid as of
|
137
|
-
doc_id: "
|
169
|
+
// This doc_id is valid as of July 20th, 2020
|
170
|
+
doc_id: "3449967031715030",
|
138
171
|
query_params: {
|
139
172
|
id: threadID,
|
140
173
|
message_limit: 0,
|
141
|
-
load_messages:
|
174
|
+
load_messages: false,
|
142
175
|
load_read_receipts: false,
|
143
176
|
before: null
|
144
177
|
}
|
145
178
|
}
|
146
|
-
})
|
179
|
+
}),
|
180
|
+
batch_name: "MessengerGraphQLThreadFetcher"
|
147
181
|
};
|
148
182
|
|
149
183
|
defaultFuncs
|
@@ -157,7 +191,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
157
191
|
// failure one.
|
158
192
|
// @TODO What do we do in this case?
|
159
193
|
if (resData[resData.length - 1].error_results !== 0) {
|
160
|
-
|
194
|
+
console.error("GetThreadInfo", "Well darn there was an error_result");
|
161
195
|
}
|
162
196
|
|
163
197
|
callback(null, formatThreadGraphQLResponse(resData[0]));
|
@@ -166,5 +200,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
166
200
|
log.error("getThreadInfoGraphQL", err);
|
167
201
|
return callback(err);
|
168
202
|
});
|
203
|
+
|
204
|
+
return returnPromise;
|
169
205
|
};
|
170
206
|
};
|
@@ -3,9 +3,23 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function getThreadInfo(threadID, callback) {
|
8
|
-
|
8
|
+
var resolveFunc = function(){};
|
9
|
+
var rejectFunc = function(){};
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
|
+
resolveFunc = resolve;
|
12
|
+
rejectFunc = reject;
|
13
|
+
});
|
14
|
+
|
15
|
+
if (!callback) {
|
16
|
+
callback = function (err, friendList) {
|
17
|
+
if (err) {
|
18
|
+
return rejectFunc(err);
|
19
|
+
}
|
20
|
+
resolveFunc(friendList);
|
21
|
+
};
|
22
|
+
}
|
9
23
|
|
10
24
|
var form = {
|
11
25
|
client: "mercury"
|
@@ -61,5 +75,6 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
61
75
|
return callback(err);
|
62
76
|
});
|
63
77
|
});
|
78
|
+
return returnPromise;
|
64
79
|
};
|
65
80
|
};
|
@@ -9,8 +9,8 @@ function createProfileUrl(url, username, id) {
|
|
9
9
|
}
|
10
10
|
|
11
11
|
function formatParticipants(participants) {
|
12
|
-
return participants.
|
13
|
-
p = p.messaging_actor;
|
12
|
+
return participants.edges.map((p)=>{
|
13
|
+
p = p.node.messaging_actor;
|
14
14
|
switch (p["__typename"]) {
|
15
15
|
case "User":
|
16
16
|
return {
|
@@ -66,7 +66,7 @@ function formatParticipants(participants) {
|
|
66
66
|
isMessageBlockedByViewer: p.is_message_blocked_by_viewer, // true/false
|
67
67
|
};
|
68
68
|
default:
|
69
|
-
log.warn("getThreadList", "Found participant with unsupported typename. Please open an issue at https://github.com/Schmavery/
|
69
|
+
log.warn("getThreadList", "Found participant with unsupported typename. Please open an issue at https://github.com/Schmavery/fca-unofficial/issues\n" + JSON.stringify(p, null, 2));
|
70
70
|
return {
|
71
71
|
accountType: p["__typename"],
|
72
72
|
userID: utils.formatID(p.id.toString()),
|
@@ -87,7 +87,8 @@ function formatColor(color) {
|
|
87
87
|
function getThreadName(t) {
|
88
88
|
if (t.name || t.thread_key.thread_fbid) return t.name;
|
89
89
|
|
90
|
-
for (let
|
90
|
+
for (let po of t.all_participants.edges) {
|
91
|
+
let p = po.node;
|
91
92
|
if (p.messaging_actor.id === t.thread_key.other_user_id) return p.messaging_actor.name;
|
92
93
|
}
|
93
94
|
}
|
@@ -141,6 +142,7 @@ function formatThreadList(data) {
|
|
141
142
|
? (t.last_read_receipt.nodes[0]?t.last_read_receipt.nodes[0].timestamp_precise:null)
|
142
143
|
: null, // timestamp in miliseconds
|
143
144
|
cannotReplyReason: t.cannot_reply_reason, // TODO: inspect possible values
|
145
|
+
approvalMode: Boolean(t.approval_mode),
|
144
146
|
|
145
147
|
// @Legacy
|
146
148
|
participantIDs: formatParticipants(t.all_participants).map(participant => participant.userID),
|
@@ -149,7 +151,7 @@ function formatThreadList(data) {
|
|
149
151
|
});
|
150
152
|
}
|
151
153
|
|
152
|
-
module.exports = function(defaultFuncs,
|
154
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
153
155
|
return function getThreadList(limit, timestamp, tags, callback) {
|
154
156
|
if (!callback && (utils.getType(tags) === "Function" || utils.getType(tags) === "AsyncFunction")) {
|
155
157
|
callback = tags;
|
@@ -168,16 +170,29 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
168
170
|
if (utils.getType(tags) !== "Array") {
|
169
171
|
throw {error: "getThreadList: tags must be an array"};
|
170
172
|
}
|
173
|
+
|
174
|
+
var resolveFunc = function(){};
|
175
|
+
var rejectFunc = function(){};
|
176
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
177
|
+
resolveFunc = resolve;
|
178
|
+
rejectFunc = reject;
|
179
|
+
});
|
180
|
+
|
171
181
|
if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
|
172
|
-
|
182
|
+
callback = function (err, data) {
|
183
|
+
if (err) {
|
184
|
+
return rejectFunc(err);
|
185
|
+
}
|
186
|
+
resolveFunc(data);
|
187
|
+
};
|
173
188
|
}
|
174
189
|
|
175
190
|
const form = {
|
176
191
|
"av": ctx.globalOptions.pageID,
|
177
192
|
"queries": JSON.stringify({
|
178
193
|
"o0": {
|
179
|
-
// This doc_id was valid on
|
180
|
-
"doc_id": "
|
194
|
+
// This doc_id was valid on 2020-07-20
|
195
|
+
"doc_id": "3336396659757871",
|
181
196
|
"query_params": {
|
182
197
|
"limit": limit+(timestamp?1:0),
|
183
198
|
"before": timestamp,
|
@@ -186,7 +201,8 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
186
201
|
"includeSeqID": false
|
187
202
|
}
|
188
203
|
}
|
189
|
-
})
|
204
|
+
}),
|
205
|
+
"batch_name": "MessengerGraphQLThreadlistFetcher"
|
190
206
|
};
|
191
207
|
|
192
208
|
defaultFuncs
|
@@ -216,5 +232,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
216
232
|
log.error("getThreadList", err);
|
217
233
|
return callback(err);
|
218
234
|
});
|
235
|
+
|
236
|
+
return returnPromise;
|
219
237
|
};
|
220
238
|
};
|
@@ -3,7 +3,7 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function getThreadList(start, end, type, callback) {
|
8
8
|
if (utils.getType(callback) === "Undefined") {
|
9
9
|
if (utils.getType(end) !== "Number") {
|
@@ -3,10 +3,22 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function getThreadPictures(threadID, offset, limit, callback) {
|
8
|
+
var resolveFunc = function(){};
|
9
|
+
var rejectFunc = function(){};
|
10
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
11
|
+
resolveFunc = resolve;
|
12
|
+
rejectFunc = reject;
|
13
|
+
});
|
14
|
+
|
8
15
|
if (!callback) {
|
9
|
-
|
16
|
+
callback = function (err, friendList) {
|
17
|
+
if (err) {
|
18
|
+
return rejectFunc(err);
|
19
|
+
}
|
20
|
+
resolveFunc(friendList);
|
21
|
+
};
|
10
22
|
}
|
11
23
|
|
12
24
|
var form = {
|
@@ -62,5 +74,6 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
62
74
|
log.error("Error in getThreadPictures", err);
|
63
75
|
callback(err);
|
64
76
|
});
|
77
|
+
return returnPromise;
|
65
78
|
};
|
66
79
|
};
|
@@ -17,10 +17,22 @@ function formatData(data) {
|
|
17
17
|
};
|
18
18
|
}
|
19
19
|
|
20
|
-
module.exports = function(defaultFuncs,
|
20
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
21
21
|
return function getUserID(name, callback) {
|
22
|
+
var resolveFunc = function(){};
|
23
|
+
var rejectFunc = function(){};
|
24
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
25
|
+
resolveFunc = resolve;
|
26
|
+
rejectFunc = reject;
|
27
|
+
});
|
28
|
+
|
22
29
|
if (!callback) {
|
23
|
-
|
30
|
+
callback = function (err, friendList) {
|
31
|
+
if (err) {
|
32
|
+
return rejectFunc(err);
|
33
|
+
}
|
34
|
+
resolveFunc(friendList);
|
35
|
+
};
|
24
36
|
}
|
25
37
|
|
26
38
|
var form = {
|
@@ -48,5 +60,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
48
60
|
log.error("getUserID", err);
|
49
61
|
return callback(err);
|
50
62
|
});
|
63
|
+
|
64
|
+
return returnPromise;
|
51
65
|
};
|
52
66
|
};
|
@@ -7,6 +7,7 @@ function formatData(data) {
|
|
7
7
|
var retObj = {};
|
8
8
|
|
9
9
|
for (var prop in data) {
|
10
|
+
// eslint-disable-next-line no-prototype-builtins
|
10
11
|
if (data.hasOwnProperty(prop)) {
|
11
12
|
var innerObj = data[prop];
|
12
13
|
retObj[prop] = {
|
@@ -18,7 +19,7 @@ function formatData(data) {
|
|
18
19
|
gender: innerObj.gender,
|
19
20
|
type: innerObj.type,
|
20
21
|
isFriend: innerObj.is_friend,
|
21
|
-
isBirthday:
|
22
|
+
isBirthday: innerObj.is_birthday
|
22
23
|
};
|
23
24
|
}
|
24
25
|
}
|
@@ -26,10 +27,22 @@ function formatData(data) {
|
|
26
27
|
return retObj;
|
27
28
|
}
|
28
29
|
|
29
|
-
module.exports = function(defaultFuncs,
|
30
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
30
31
|
return function getUserInfo(id, callback) {
|
32
|
+
var resolveFunc = function(){};
|
33
|
+
var rejectFunc = function(){};
|
34
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
35
|
+
resolveFunc = resolve;
|
36
|
+
rejectFunc = reject;
|
37
|
+
});
|
38
|
+
|
31
39
|
if (!callback) {
|
32
|
-
|
40
|
+
callback = function (err, friendList) {
|
41
|
+
if (err) {
|
42
|
+
return rejectFunc(err);
|
43
|
+
}
|
44
|
+
resolveFunc(friendList);
|
45
|
+
};
|
33
46
|
}
|
34
47
|
|
35
48
|
if (utils.getType(id) !== "Array") {
|
@@ -53,5 +66,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
53
66
|
log.error("getUserInfo", err);
|
54
67
|
return callback(err);
|
55
68
|
});
|
69
|
+
|
70
|
+
return returnPromise;
|
56
71
|
};
|
57
72
|
};
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
+
return function handleFriendRequest(userID, accept, callback) {
|
8
|
+
if (utils.getType(accept) !== "Boolean") {
|
9
|
+
throw {
|
10
|
+
error: "Please pass a boolean as a second argument."
|
11
|
+
};
|
12
|
+
}
|
13
|
+
|
14
|
+
var resolveFunc = function(){};
|
15
|
+
var rejectFunc = function(){};
|
16
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
17
|
+
resolveFunc = resolve;
|
18
|
+
rejectFunc = reject;
|
19
|
+
});
|
20
|
+
|
21
|
+
if (!callback) {
|
22
|
+
callback = function (err, friendList) {
|
23
|
+
if (err) {
|
24
|
+
return rejectFunc(err);
|
25
|
+
}
|
26
|
+
resolveFunc(friendList);
|
27
|
+
};
|
28
|
+
}
|
29
|
+
|
30
|
+
var form = {
|
31
|
+
viewer_id: ctx.userID,
|
32
|
+
"frefs[0]": "jwl",
|
33
|
+
floc: "friend_center_requests",
|
34
|
+
ref: "/reqs.php",
|
35
|
+
action: (accept ? "confirm" : "reject")
|
36
|
+
};
|
37
|
+
|
38
|
+
defaultFuncs
|
39
|
+
.post(
|
40
|
+
"https://www.facebook.com/requests/friends/ajax/",
|
41
|
+
ctx.jar,
|
42
|
+
form
|
43
|
+
)
|
44
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
45
|
+
.then(function(resData) {
|
46
|
+
if (resData.payload.err) {
|
47
|
+
throw {
|
48
|
+
err: resData.payload.err
|
49
|
+
};
|
50
|
+
}
|
51
|
+
|
52
|
+
return callback();
|
53
|
+
})
|
54
|
+
.catch(function(err) {
|
55
|
+
log.error("handleFriendRequest", err);
|
56
|
+
return callback(err);
|
57
|
+
});
|
58
|
+
|
59
|
+
return returnPromise;
|
60
|
+
};
|
61
|
+
};
|
@@ -3,7 +3,7 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs,
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
7
|
return function handleMessageRequest(threadID, accept, callback) {
|
8
8
|
if (utils.getType(accept) !== "Boolean") {
|
9
9
|
throw {
|
@@ -11,8 +11,20 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
11
11
|
};
|
12
12
|
}
|
13
13
|
|
14
|
+
var resolveFunc = function(){};
|
15
|
+
var rejectFunc = function(){};
|
16
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
17
|
+
resolveFunc = resolve;
|
18
|
+
rejectFunc = reject;
|
19
|
+
});
|
20
|
+
|
14
21
|
if (!callback) {
|
15
|
-
callback = function() {
|
22
|
+
callback = function (err, friendList) {
|
23
|
+
if (err) {
|
24
|
+
return rejectFunc(err);
|
25
|
+
}
|
26
|
+
resolveFunc(friendList);
|
27
|
+
};
|
16
28
|
}
|
17
29
|
|
18
30
|
var form = {
|
@@ -47,5 +59,7 @@ module.exports = function(defaultFuncs, bot, ctx) {
|
|
47
59
|
log.error("handleMessageRequest", err);
|
48
60
|
return callback(err);
|
49
61
|
});
|
62
|
+
|
63
|
+
return returnPromise;
|
50
64
|
};
|
51
65
|
};
|