alicezetion 1.7.0 → 1.7.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/Extra/Database/index.js +399 -0
- package/Extra/Database/methods.js +286 -0
- package/Extra/ExtraAddons.js +213 -0
- package/Extra/ExtraGetThread.js +1 -0
- package/Extra/ExtraUptimeRobot.js +59 -0
- package/Extra/PM2/ecosystem.config.js +23 -0
- package/Extra/Src/Last-Run.js +48 -0
- package/Language/index.json +151 -0
- package/StateCrypt.js +22 -0
- package/broadcast.js +42 -0
- package/index.js +755 -533
- package/logger.js +21 -0
- package/package.json +35 -21
- package/replit.nix +0 -3
- package/src/addExternalModule.js +23 -0
- package/{leiamnash → src}/addUserToGroup.js +11 -23
- package/{leiamnash → src}/changeAdminStatus.js +32 -16
- package/{leiamnash → src}/changeArchivedStatus.js +9 -17
- package/src/changeAvt.js +91 -0
- package/{leiamnash → src}/changeBio.js +16 -24
- package/{leiamnash → src}/changeBlockedStatus.js +13 -18
- package/{leiamnash → src}/changeGroupImage.js +14 -23
- package/{leiamnash → src}/changeNickname.js +9 -14
- package/{leiamnash → src}/changeThreadColor.js +6 -10
- package/{leiamnash → src}/changeThreadEmoji.js +6 -11
- package/{leiamnash → src}/chat.js +116 -127
- package/{leiamnash → src}/createNewGroup.js +19 -27
- package/{leiamnash → src}/createPoll.js +6 -12
- package/{leiamnash → src}/deleteMessage.js +8 -13
- package/{leiamnash → src}/deleteThread.js +7 -14
- package/{leiamnash → src}/forwardAttachment.js +9 -16
- package/src/getAccessToken.js +32 -0
- package/{leiamnash → src}/getCurrentUserID.js +0 -0
- package/{leiamnash → src}/getEmojiUrl.js +1 -2
- package/{leiamnash → src}/getFriendsList.js +11 -14
- package/src/getMessage.js +84 -0
- package/{leiamnash → src}/getThreadHistory.js +27 -38
- package/{leiamnash → src}/getThreadHistoryDeprecated.js +14 -25
- package/src/getThreadInfo.js +197 -0
- package/{leiamnash → src}/getThreadInfoDeprecated.js +12 -24
- package/{leiamnash → src}/getThreadList.js +122 -88
- package/{leiamnash → src}/getThreadListDeprecated.js +9 -20
- package/{leiamnash → src}/getThreadPictures.js +9 -17
- package/{leiamnash → src}/getUserID.js +8 -11
- package/{leiamnash → src}/getUserInfo.js +12 -16
- package/src/getUserInfoV2.js +35 -0
- package/src/handleFriendRequest.js +47 -0
- package/{leiamnash → src}/handleMessageRequest.js +12 -22
- package/{leiamnash → src}/httpGet.js +15 -13
- package/{leiamnash → src}/httpPost.js +14 -13
- package/src/httpPostFormData.js +46 -0
- package/src/listenMqtt.js +1280 -0
- package/{leiamnash → src}/logout.js +7 -9
- package/{leiamnash → src}/markAsDelivered.js +14 -18
- package/{leiamnash → src}/markAsRead.js +30 -28
- package/{leiamnash → src}/markAsSeen.js +18 -19
- package/{leiamnash → src}/muteThread.js +7 -8
- package/{leiamnash/setMessageReaction.js → src/react.js} +15 -18
- package/{leiamnash → src}/removeUserFromGroup.js +13 -20
- package/{leiamnash → src}/resolvePhotoUrl.js +7 -13
- package/{leiamnash → src}/searchForThread.js +8 -13
- package/{leiamnash/markAsReadAll.js → src/seen.js} +10 -13
- package/{leiamnash → src}/sendTypingIndicator.js +23 -31
- package/src/setPostReaction.js +104 -0
- package/{leiamnash → src}/setTitle.js +15 -21
- package/src/threadColors.js +39 -0
- package/{leiamnash → src}/unfriend.js +9 -13
- package/{leiamnash/unsendMessage.js → src/unsend.js} +7 -16
- package/utils.js +1112 -1236
- package/leiamnash/addExternalModule.js +0 -19
- package/leiamnash/changeApprovalMode.js +0 -80
- package/leiamnash/getThreadInfo.js +0 -212
- package/leiamnash/handleFriendRequest.js +0 -61
- package/leiamnash/listenMqtt.js +0 -1129
- package/leiamnash/setPostReaction.js +0 -76
- package/leiamnash/threadColors.js +0 -57
@@ -1,19 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
const utils = require("../utils");
|
4
|
-
|
5
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
6
|
-
return function addExternalModule(moduleObj) {
|
7
|
-
if (utils.getType(moduleObj) == "Object") {
|
8
|
-
for (let apiName in moduleObj) {
|
9
|
-
if (utils.getType(moduleObj[apiName]) == "Function") {
|
10
|
-
api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
|
11
|
-
} else {
|
12
|
-
throw new Error(`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(moduleObj[apiName])}!`);
|
13
|
-
}
|
14
|
-
}
|
15
|
-
} else {
|
16
|
-
throw new Error(`moduleObj must be an object, not ${utils.getType(moduleObj)}!`);
|
17
|
-
}
|
18
|
-
};
|
19
|
-
};
|
@@ -1,80 +0,0 @@
|
|
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 changeApprovalMode(approval_mode, threadID, callback) {
|
8
|
-
if (utils.getType(threadID) !== "String") {
|
9
|
-
throw { error: "changeApprovalMode: threadID must be a string" };
|
10
|
-
}
|
11
|
-
|
12
|
-
var resolveFunc = function() {};
|
13
|
-
var rejectFunc = function() {};
|
14
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
15
|
-
resolveFunc = resolve;
|
16
|
-
rejectFunc = reject;
|
17
|
-
});
|
18
|
-
|
19
|
-
if (!callback) {
|
20
|
-
callback = function(err) {
|
21
|
-
if (err) {
|
22
|
-
return rejectFunc(err);
|
23
|
-
}
|
24
|
-
resolveFunc(err);
|
25
|
-
};
|
26
|
-
}
|
27
|
-
|
28
|
-
if (
|
29
|
-
utils.getType(callback) !== "Function" &&
|
30
|
-
utils.getType(callback) !== "AsyncFunction"
|
31
|
-
) {
|
32
|
-
throw { error: "changeApprovalMode: callback is not a function" };
|
33
|
-
}
|
34
|
-
|
35
|
-
approval_mode = parseInt(approval_mode);
|
36
|
-
|
37
|
-
if (approval_mode !== 0 && approval_mode !== 1) {
|
38
|
-
throw { error: "changeApprovalMode: approval_mode must be 0 or 1" };
|
39
|
-
}
|
40
|
-
|
41
|
-
var form = {
|
42
|
-
thread_fbid: threadID,
|
43
|
-
set_mode: approval_mode,
|
44
|
-
};
|
45
|
-
|
46
|
-
defaultFuncs
|
47
|
-
.post(
|
48
|
-
"https://www.facebook.com/messaging/set_approval_mode/?dpr=1",
|
49
|
-
ctx.jar,
|
50
|
-
form
|
51
|
-
)
|
52
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
53
|
-
.then(function(resData) {
|
54
|
-
if (resData.error) {
|
55
|
-
switch (resData.error) {
|
56
|
-
case 1357031:
|
57
|
-
throw {
|
58
|
-
error:
|
59
|
-
"Cannot alter approval mode: this thread is not a group chat or you are not an admin.",
|
60
|
-
rawResponse: resData,
|
61
|
-
};
|
62
|
-
default:
|
63
|
-
throw {
|
64
|
-
error:
|
65
|
-
"Cannot alter approval mode: unknown error.",
|
66
|
-
rawResponse: resData,
|
67
|
-
};
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
|
-
return callback();
|
72
|
-
})
|
73
|
-
.catch(function(err) {
|
74
|
-
log.error("changeApprovalMode", err);
|
75
|
-
return callback(err);
|
76
|
-
});
|
77
|
-
|
78
|
-
return returnPromise;
|
79
|
-
};
|
80
|
-
};
|
@@ -1,212 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var utils = require("../utils");
|
4
|
-
var log = require("npmlog");
|
5
|
-
|
6
|
-
function formatEventReminders(reminder) {
|
7
|
-
return {
|
8
|
-
reminderID: reminder.id,
|
9
|
-
eventCreatorID: reminder.lightweight_event_creator.id,
|
10
|
-
time: reminder.time,
|
11
|
-
eventType: reminder.lightweight_event_type.toLowerCase(),
|
12
|
-
locationName: reminder.location_name,
|
13
|
-
// @TODO verify this
|
14
|
-
locationCoordinates: reminder.location_coordinates,
|
15
|
-
locationPage: reminder.location_page,
|
16
|
-
eventStatus: reminder.lightweight_event_status.toLowerCase(),
|
17
|
-
note: reminder.note,
|
18
|
-
repeatMode: reminder.repeat_mode.toLowerCase(),
|
19
|
-
eventTitle: reminder.event_title,
|
20
|
-
triggerMessage: reminder.trigger_message,
|
21
|
-
secondsToNotifyBefore: reminder.seconds_to_notify_before,
|
22
|
-
allowsRsvp: reminder.allows_rsvp,
|
23
|
-
relatedEvent: reminder.related_event,
|
24
|
-
members: reminder.event_reminder_members.edges.map(function(member) {
|
25
|
-
return {
|
26
|
-
memberID: member.node.id,
|
27
|
-
state: member.guest_list_state.toLowerCase(),
|
28
|
-
};
|
29
|
-
}),
|
30
|
-
};
|
31
|
-
}
|
32
|
-
|
33
|
-
function formatThreadGraphQLResponse(data) {
|
34
|
-
var messageThread = data.o0.data.message_thread;
|
35
|
-
var threadID = messageThread.thread_key.thread_fbid
|
36
|
-
? messageThread.thread_key.thread_fbid
|
37
|
-
: messageThread.thread_key.other_user_id;
|
38
|
-
|
39
|
-
// Remove me
|
40
|
-
var lastM = messageThread.last_message;
|
41
|
-
var snippetID =
|
42
|
-
lastM &&
|
43
|
-
lastM.nodes &&
|
44
|
-
lastM.nodes[0] &&
|
45
|
-
lastM.nodes[0].message_sender &&
|
46
|
-
lastM.nodes[0].message_sender.messaging_actor
|
47
|
-
? lastM.nodes[0].message_sender.messaging_actor.id
|
48
|
-
: null;
|
49
|
-
var snippetText =
|
50
|
-
lastM && lastM.nodes && lastM.nodes[0] ? lastM.nodes[0].snippet : null;
|
51
|
-
var lastR = messageThread.last_read_receipt;
|
52
|
-
var lastReadTimestamp =
|
53
|
-
lastR &&
|
54
|
-
lastR.nodes &&
|
55
|
-
lastR.nodes[0] &&
|
56
|
-
lastR.nodes[0].timestamp_precise
|
57
|
-
? lastR.nodes[0].timestamp_precise
|
58
|
-
: null;
|
59
|
-
|
60
|
-
return {
|
61
|
-
threadID: threadID,
|
62
|
-
threadName: messageThread.name,
|
63
|
-
participantIDs: messageThread.all_participants.edges.map(
|
64
|
-
(d) => d.node.messaging_actor.id
|
65
|
-
),
|
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.url,
|
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
|
-
})),
|
78
|
-
unreadCount: messageThread.unread_count,
|
79
|
-
messageCount: messageThread.messages_count,
|
80
|
-
timestamp: messageThread.updated_time_precise,
|
81
|
-
muteUntil: messageThread.mute_until,
|
82
|
-
isGroup: messageThread.thread_type == "GROUP",
|
83
|
-
isSubscribed: messageThread.is_viewer_subscribed,
|
84
|
-
isArchived: messageThread.has_viewer_archived,
|
85
|
-
folder: messageThread.folder,
|
86
|
-
cannotReplyReason: messageThread.cannot_reply_reason,
|
87
|
-
eventReminders: messageThread.event_reminders
|
88
|
-
? messageThread.event_reminders.nodes.map(formatEventReminders)
|
89
|
-
: null,
|
90
|
-
emoji: messageThread.customization_info
|
91
|
-
? messageThread.customization_info.emoji
|
92
|
-
: null,
|
93
|
-
color:
|
94
|
-
messageThread.customization_info &&
|
95
|
-
messageThread.customization_info.outgoing_bubble_color
|
96
|
-
? messageThread.customization_info.outgoing_bubble_color.slice(
|
97
|
-
2
|
98
|
-
)
|
99
|
-
: null,
|
100
|
-
nicknames:
|
101
|
-
messageThread.customization_info &&
|
102
|
-
messageThread.customization_info.participant_customizations
|
103
|
-
? messageThread.customization_info.participant_customizations.reduce(
|
104
|
-
function(res, val) {
|
105
|
-
if (val.nickname)
|
106
|
-
res[val.participant_id] = val.nickname;
|
107
|
-
return res;
|
108
|
-
},
|
109
|
-
{}
|
110
|
-
)
|
111
|
-
: {},
|
112
|
-
adminIDs: messageThread.thread_admins.map((el) => el.id),
|
113
|
-
approvalMode: Boolean(messageThread.approval_mode),
|
114
|
-
approvalQueue: messageThread.group_approval_queue.nodes.map((a) => ({
|
115
|
-
inviterID: a.inviter.id,
|
116
|
-
requesterID: a.requester.id,
|
117
|
-
timestamp: a.request_timestamp,
|
118
|
-
request_source: a.request_source, // @Undocumented
|
119
|
-
})),
|
120
|
-
|
121
|
-
// @Undocumented
|
122
|
-
reactionsMuteMode: messageThread.reactions_mute_mode.toLowerCase(),
|
123
|
-
mentionsMuteMode: messageThread.mentions_mute_mode.toLowerCase(),
|
124
|
-
isPinProtected: messageThread.is_pin_protected,
|
125
|
-
relatedPageThread: messageThread.related_page_thread,
|
126
|
-
|
127
|
-
// @Legacy
|
128
|
-
name: messageThread.name,
|
129
|
-
snippet: snippetText,
|
130
|
-
snippetSender: snippetID,
|
131
|
-
snippetAttachments: [],
|
132
|
-
serverTimestamp: messageThread.updated_time_precise,
|
133
|
-
imageSrc: messageThread.image ? messageThread.image.uri : null,
|
134
|
-
isCanonicalUser: messageThread.is_canonical_neo_user,
|
135
|
-
isCanonical: messageThread.thread_type != "GROUP",
|
136
|
-
recipientsLoadable: true,
|
137
|
-
hasEmailParticipant: false,
|
138
|
-
readOnly: false,
|
139
|
-
canReply: messageThread.cannot_reply_reason == null,
|
140
|
-
lastMessageTimestamp: messageThread.last_message
|
141
|
-
? messageThread.last_message.timestamp_precise
|
142
|
-
: null,
|
143
|
-
lastMessageType: "message",
|
144
|
-
lastReadTimestamp: lastReadTimestamp,
|
145
|
-
threadType: messageThread.thread_type == "GROUP" ? 2 : 1,
|
146
|
-
};
|
147
|
-
}
|
148
|
-
|
149
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
150
|
-
return function getThreadInfoGraphQL(threadID, callback) {
|
151
|
-
var resolveFunc = function() {};
|
152
|
-
var rejectFunc = function() {};
|
153
|
-
var returnPromise = new Promise(function(resolve, reject) {
|
154
|
-
resolveFunc = resolve;
|
155
|
-
rejectFunc = reject;
|
156
|
-
});
|
157
|
-
|
158
|
-
if (
|
159
|
-
utils.getType(callback) != "Function" &&
|
160
|
-
utils.getType(callback) != "AsyncFunction"
|
161
|
-
) {
|
162
|
-
callback = function(err, data) {
|
163
|
-
if (err) {
|
164
|
-
return rejectFunc(err);
|
165
|
-
}
|
166
|
-
resolveFunc(data);
|
167
|
-
};
|
168
|
-
}
|
169
|
-
|
170
|
-
// `queries` has to be a string. I couldn't tell from the dev console. This
|
171
|
-
// took me a really long time to figure out. I deserve a cookie for this.
|
172
|
-
var form = {
|
173
|
-
queries: JSON.stringify({
|
174
|
-
o0: {
|
175
|
-
// This doc_id is valid as of July 20th, 2020
|
176
|
-
doc_id: "3449967031715030",
|
177
|
-
query_params: {
|
178
|
-
id: threadID,
|
179
|
-
message_limit: 0,
|
180
|
-
load_messages: false,
|
181
|
-
load_read_receipts: false,
|
182
|
-
before: null,
|
183
|
-
},
|
184
|
-
},
|
185
|
-
}),
|
186
|
-
batch_name: "MessengerGraphQLThreadFetcher",
|
187
|
-
};
|
188
|
-
|
189
|
-
defaultFuncs
|
190
|
-
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
191
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
192
|
-
.then(function(resData) {
|
193
|
-
if (resData.error) {
|
194
|
-
throw resData;
|
195
|
-
}
|
196
|
-
// This returns us an array of things. The last one is the success /
|
197
|
-
// failure one.
|
198
|
-
// @TODO What do we do in this case?
|
199
|
-
if (resData[resData.length - 1].error_results !== 0) {
|
200
|
-
throw new Error("well darn there was an error_result");
|
201
|
-
}
|
202
|
-
|
203
|
-
callback(null, formatThreadGraphQLResponse(resData[0]));
|
204
|
-
})
|
205
|
-
.catch(function(err) {
|
206
|
-
log.error("getThreadInfoGraphQL", err);
|
207
|
-
return callback(err);
|
208
|
-
});
|
209
|
-
|
210
|
-
return returnPromise;
|
211
|
-
};
|
212
|
-
};
|
@@ -1,61 +0,0 @@
|
|
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
|
-
};
|