zai-fca 1.0.7-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of zai-fca might be problematic. Click here for more details.
- package/.cache/replit/env/latest +56 -0
- package/.cache/replit/env/latest.json +1 -0
- package/.cache/replit/modules/nodejs-20.res +1 -0
- package/.cache/replit/modules/replit.res +1 -0
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/typescript/5.6/node_modules/.package-lock.json +178 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/index.d.ts +1365 -0
- package/.cache/typescript/5.6/node_modules/@types/bluebird/package.json +25 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/README.md +48 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/index.d.ts +29 -0
- package/.cache/typescript/5.6/node_modules/@types/caseless/package.json +35 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/index.d.ts +2929 -0
- package/.cache/typescript/5.6/node_modules/@types/mocha/package.json +56 -0
- package/.cache/typescript/5.6/node_modules/@types/node/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/.cache/typescript/5.6/node_modules/@types/node/assert.d.ts +1040 -0
- package/.cache/typescript/5.6/node_modules/@types/node/async_hooks.d.ts +541 -0
- package/.cache/typescript/5.6/node_modules/@types/node/buffer.buffer.d.ts +385 -0
- package/.cache/typescript/5.6/node_modules/@types/node/buffer.d.ts +1933 -0
- package/.cache/typescript/5.6/node_modules/@types/node/child_process.d.ts +1549 -0
- package/.cache/typescript/5.6/node_modules/@types/node/cluster.d.ts +579 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/indexable.d.ts +23 -0
- package/.cache/typescript/5.6/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node/console.d.ts +452 -0
- package/.cache/typescript/5.6/node_modules/@types/node/constants.d.ts +19 -0
- package/.cache/typescript/5.6/node_modules/@types/node/crypto.d.ts +4475 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dgram.d.ts +596 -0
- package/.cache/typescript/5.6/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dns/promises.d.ts +476 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dns.d.ts +865 -0
- package/.cache/typescript/5.6/node_modules/@types/node/dom-events.d.ts +124 -0
- package/.cache/typescript/5.6/node_modules/@types/node/domain.d.ts +170 -0
- package/.cache/typescript/5.6/node_modules/@types/node/events.d.ts +931 -0
- package/.cache/typescript/5.6/node_modules/@types/node/fs/promises.d.ts +1275 -0
- package/.cache/typescript/5.6/node_modules/@types/node/fs.d.ts +4396 -0
- package/.cache/typescript/5.6/node_modules/@types/node/globals.d.ts +566 -0
- package/.cache/typescript/5.6/node_modules/@types/node/globals.typedarray.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node/http.d.ts +1958 -0
- package/.cache/typescript/5.6/node_modules/@types/node/http2.d.ts +2558 -0
- package/.cache/typescript/5.6/node_modules/@types/node/https.d.ts +543 -0
- package/.cache/typescript/5.6/node_modules/@types/node/index.d.ts +92 -0
- package/.cache/typescript/5.6/node_modules/@types/node/inspector.d.ts +3966 -0
- package/.cache/typescript/5.6/node_modules/@types/node/module.d.ts +402 -0
- package/.cache/typescript/5.6/node_modules/@types/node/net.d.ts +1001 -0
- package/.cache/typescript/5.6/node_modules/@types/node/os.d.ts +495 -0
- package/.cache/typescript/5.6/node_modules/@types/node/package.json +220 -0
- package/.cache/typescript/5.6/node_modules/@types/node/path.d.ts +200 -0
- package/.cache/typescript/5.6/node_modules/@types/node/perf_hooks.d.ts +965 -0
- package/.cache/typescript/5.6/node_modules/@types/node/process.d.ts +1963 -0
- package/.cache/typescript/5.6/node_modules/@types/node/punycode.d.ts +117 -0
- package/.cache/typescript/5.6/node_modules/@types/node/querystring.d.ts +153 -0
- package/.cache/typescript/5.6/node_modules/@types/node/readline/promises.d.ts +162 -0
- package/.cache/typescript/5.6/node_modules/@types/node/readline.d.ts +589 -0
- package/.cache/typescript/5.6/node_modules/@types/node/repl.d.ts +430 -0
- package/.cache/typescript/5.6/node_modules/@types/node/sea.d.ts +153 -0
- package/.cache/typescript/5.6/node_modules/@types/node/sqlite.d.ts +213 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream/web.d.ts +609 -0
- package/.cache/typescript/5.6/node_modules/@types/node/stream.d.ts +1726 -0
- package/.cache/typescript/5.6/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/.cache/typescript/5.6/node_modules/@types/node/test.d.ts +2248 -0
- package/.cache/typescript/5.6/node_modules/@types/node/timers/promises.d.ts +97 -0
- package/.cache/typescript/5.6/node_modules/@types/node/timers.d.ts +240 -0
- package/.cache/typescript/5.6/node_modules/@types/node/tls.d.ts +1226 -0
- package/.cache/typescript/5.6/node_modules/@types/node/trace_events.d.ts +197 -0
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +385 -0
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +19 -0
- package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/index.d.ts +92 -0
- package/.cache/typescript/5.6/node_modules/@types/node/tty.d.ts +208 -0
- package/.cache/typescript/5.6/node_modules/@types/node/url.d.ts +972 -0
- package/.cache/typescript/5.6/node_modules/@types/node/util.d.ts +2371 -0
- package/.cache/typescript/5.6/node_modules/@types/node/v8.d.ts +808 -0
- package/.cache/typescript/5.6/node_modules/@types/node/vm.d.ts +976 -0
- package/.cache/typescript/5.6/node_modules/@types/node/wasi.d.ts +181 -0
- package/.cache/typescript/5.6/node_modules/@types/node/worker_threads.d.ts +745 -0
- package/.cache/typescript/5.6/node_modules/@types/node/zlib.d.ts +539 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/README.md +76 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/index.d.ts +57 -0
- package/.cache/typescript/5.6/node_modules/@types/node-cron/package.json +50 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/index.d.ts +84 -0
- package/.cache/typescript/5.6/node_modules/@types/npmlog/package.json +32 -0
- package/.cache/typescript/5.6/node_modules/@types/request/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/request/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/request/index.d.ts +395 -0
- package/.cache/typescript/5.6/node_modules/@types/request/package.json +70 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/index.d.ts +321 -0
- package/.cache/typescript/5.6/node_modules/@types/tough-cookie/package.json +35 -0
- package/.cache/typescript/5.6/node_modules/asynckit/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/asynckit/README.md +233 -0
- package/.cache/typescript/5.6/node_modules/asynckit/bench.js +76 -0
- package/.cache/typescript/5.6/node_modules/asynckit/index.js +6 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/abort.js +29 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/async.js +34 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/defer.js +26 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/iterate.js +75 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/state.js +37 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/streamify.js +141 -0
- package/.cache/typescript/5.6/node_modules/asynckit/lib/terminator.js +29 -0
- package/.cache/typescript/5.6/node_modules/asynckit/package.json +63 -0
- package/.cache/typescript/5.6/node_modules/asynckit/parallel.js +43 -0
- package/.cache/typescript/5.6/node_modules/asynckit/serial.js +17 -0
- package/.cache/typescript/5.6/node_modules/asynckit/serialOrdered.js +75 -0
- package/.cache/typescript/5.6/node_modules/asynckit/stream.js +21 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/License +19 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/Readme.md +138 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/package.json +25 -0
- package/.cache/typescript/5.6/node_modules/combined-stream/yarn.lock +17 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/License +19 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/Makefile +7 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/Readme.md +141 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/.cache/typescript/5.6/node_modules/delayed-stream/package.json +27 -0
- package/.cache/typescript/5.6/node_modules/form-data/License +19 -0
- package/.cache/typescript/5.6/node_modules/form-data/Readme.md +350 -0
- package/.cache/typescript/5.6/node_modules/form-data/index.d.ts +51 -0
- package/.cache/typescript/5.6/node_modules/form-data/lib/browser.js +2 -0
- package/.cache/typescript/5.6/node_modules/form-data/lib/form_data.js +484 -0
- package/.cache/typescript/5.6/node_modules/form-data/lib/populate.js +10 -0
- package/.cache/typescript/5.6/node_modules/form-data/package.json +72 -0
- package/.cache/typescript/5.6/node_modules/mime-db/HISTORY.md +507 -0
- package/.cache/typescript/5.6/node_modules/mime-db/LICENSE +23 -0
- package/.cache/typescript/5.6/node_modules/mime-db/README.md +100 -0
- package/.cache/typescript/5.6/node_modules/mime-db/db.json +8519 -0
- package/.cache/typescript/5.6/node_modules/mime-db/index.js +12 -0
- package/.cache/typescript/5.6/node_modules/mime-db/package.json +60 -0
- package/.cache/typescript/5.6/node_modules/mime-types/HISTORY.md +397 -0
- package/.cache/typescript/5.6/node_modules/mime-types/LICENSE +23 -0
- package/.cache/typescript/5.6/node_modules/mime-types/README.md +113 -0
- package/.cache/typescript/5.6/node_modules/mime-types/index.js +188 -0
- package/.cache/typescript/5.6/node_modules/mime-types/package.json +44 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/README.md +584 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/index.d.ts +187 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/index.js +65 -0
- package/.cache/typescript/5.6/node_modules/safe-buffer/package.json +51 -0
- package/.cache/typescript/5.6/node_modules/types-registry/README.md +2 -0
- package/.cache/typescript/5.6/node_modules/types-registry/index.json +1 -0
- package/.cache/typescript/5.6/node_modules/types-registry/package.json +20 -0
- package/.cache/typescript/5.6/node_modules/undici-types/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/undici-types/README.md +6 -0
- package/.cache/typescript/5.6/node_modules/undici-types/agent.d.ts +31 -0
- package/.cache/typescript/5.6/node_modules/undici-types/api.d.ts +43 -0
- package/.cache/typescript/5.6/node_modules/undici-types/balanced-pool.d.ts +29 -0
- package/.cache/typescript/5.6/node_modules/undici-types/cache.d.ts +36 -0
- package/.cache/typescript/5.6/node_modules/undici-types/client.d.ts +108 -0
- package/.cache/typescript/5.6/node_modules/undici-types/connector.d.ts +34 -0
- package/.cache/typescript/5.6/node_modules/undici-types/content-type.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/undici-types/cookies.d.ts +28 -0
- package/.cache/typescript/5.6/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
- package/.cache/typescript/5.6/node_modules/undici-types/dispatcher.d.ts +255 -0
- package/.cache/typescript/5.6/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
- package/.cache/typescript/5.6/node_modules/undici-types/errors.d.ts +149 -0
- package/.cache/typescript/5.6/node_modules/undici-types/eventsource.d.ts +61 -0
- package/.cache/typescript/5.6/node_modules/undici-types/fetch.d.ts +209 -0
- package/.cache/typescript/5.6/node_modules/undici-types/file.d.ts +39 -0
- package/.cache/typescript/5.6/node_modules/undici-types/filereader.d.ts +54 -0
- package/.cache/typescript/5.6/node_modules/undici-types/formdata.d.ts +108 -0
- package/.cache/typescript/5.6/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/.cache/typescript/5.6/node_modules/undici-types/global-origin.d.ts +7 -0
- package/.cache/typescript/5.6/node_modules/undici-types/handlers.d.ts +15 -0
- package/.cache/typescript/5.6/node_modules/undici-types/header.d.ts +4 -0
- package/.cache/typescript/5.6/node_modules/undici-types/index.d.ts +71 -0
- package/.cache/typescript/5.6/node_modules/undici-types/interceptors.d.ts +17 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-client.d.ts +25 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/.cache/typescript/5.6/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/.cache/typescript/5.6/node_modules/undici-types/package.json +55 -0
- package/.cache/typescript/5.6/node_modules/undici-types/patch.d.ts +33 -0
- package/.cache/typescript/5.6/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/.cache/typescript/5.6/node_modules/undici-types/pool.d.ts +39 -0
- package/.cache/typescript/5.6/node_modules/undici-types/proxy-agent.d.ts +28 -0
- package/.cache/typescript/5.6/node_modules/undici-types/readable.d.ts +60 -0
- package/.cache/typescript/5.6/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/.cache/typescript/5.6/node_modules/undici-types/retry-handler.d.ts +116 -0
- package/.cache/typescript/5.6/node_modules/undici-types/util.d.ts +18 -0
- package/.cache/typescript/5.6/node_modules/undici-types/webidl.d.ts +222 -0
- package/.cache/typescript/5.6/node_modules/undici-types/websocket.d.ts +150 -0
- package/.cache/typescript/5.6/package-lock.json +190 -0
- package/.cache/typescript/5.6/package.json +1 -0
- package/.replit +4 -0
- package/.upm/store.json +1 -0
- package/LICENSE +21 -0
- package/README.md +289 -0
- package/index.js +460 -0
- package/package.json +45 -0
- package/src/Screenshot.js +83 -0
- package/src/addExternalModule.js +15 -0
- package/src/addUserToGroup.js +77 -0
- package/src/changeAdminStatus.js +47 -0
- package/src/changeArchivedStatus.js +41 -0
- package/src/changeAvt.js +85 -0
- package/src/changeBio.js +65 -0
- package/src/changeBlockedStatus.js +36 -0
- package/src/changeGroupImage.js +106 -0
- package/src/changeNickname.js +45 -0
- package/src/changeThreadColor.js +61 -0
- package/src/changeThreadEmoji.js +41 -0
- package/src/createNewGroup.js +70 -0
- package/src/createPoll.js +59 -0
- package/src/createPost.js +277 -0
- package/src/deleteMessage.js +44 -0
- package/src/deleteThread.js +42 -0
- package/src/forwardAttachment.js +47 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +27 -0
- package/src/getFriendsList.js +73 -0
- package/src/getThreadHistory.js +537 -0
- package/src/getThreadHistoryDeprecated.js +71 -0
- package/src/getThreadInfo.js +232 -0
- package/src/getThreadInfoDeprecated.js +56 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadListDeprecated.js +46 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getUID.js +119 -0
- package/src/getUserID.js +61 -0
- package/src/getUserInfo.js +66 -0
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +47 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/listenMqtt.js +827 -0
- package/src/listenMqtt.txt +827 -0
- package/src/logout.js +68 -0
- package/src/markAsDelivered.js +47 -0
- package/src/markAsRead.js +70 -0
- package/src/markAsReadAll.js +40 -0
- package/src/markAsSeen.js +48 -0
- package/src/muteThread.js +45 -0
- package/src/postFormData.txt +46 -0
- package/src/removeUserFromGroup.js +45 -0
- package/src/resolvePhotoUrl.js +36 -0
- package/src/searchForThread.js +42 -0
- package/src/sendMessage.js +329 -0
- package/src/sendTypingIndicator.js +70 -0
- package/src/setMessageReaction.js +109 -0
- package/src/setPostReaction.js +102 -0
- package/src/setTitle.js +70 -0
- package/src/shareContact.js +46 -0
- package/src/shareLink.js +62 -0
- package/src/threadColors.js +41 -0
- package/src/unfriend.js +42 -0
- package/src/unsendMessage.js +39 -0
- package/test/example-config.json +18 -0
- package/test/test-page.js +140 -0
- package/test/test.js +385 -0
- package/utils.js +2876 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const utils = require("../utils");
|
|
4
|
+
|
|
5
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
6
|
+
return function changeAdminStatus(threadID, adminID, adminStatus) {
|
|
7
|
+
if (utils.getType(threadID) !== "String") throw { error: "changeAdminStatus: threadID must be a string" };
|
|
8
|
+
if (utils.getType(adminID) !== "String" && utils.getType(adminID) !== "Array") throw { error: "changeAdminStatus: adminID must be a string or an array" };
|
|
9
|
+
if (utils.getType(adminStatus) !== "Boolean") throw { error: "changeAdminStatus: adminStatus must be true or false" };
|
|
10
|
+
|
|
11
|
+
let wsContent = {
|
|
12
|
+
request_id: 1,
|
|
13
|
+
type: 3,
|
|
14
|
+
payload: {
|
|
15
|
+
version_id: '3816854585040595',
|
|
16
|
+
tasks: [],
|
|
17
|
+
epoch_id: 6763184801413415579,
|
|
18
|
+
data_trace_id: null
|
|
19
|
+
},
|
|
20
|
+
app_id: '772021112871879'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (utils.getType(adminID) === "Array") {
|
|
24
|
+
for (let i = 0; i < adminID.length; i++) {
|
|
25
|
+
wsContent.payload.tasks.push({
|
|
26
|
+
label: '25',
|
|
27
|
+
payload: JSON.stringify({ thread_key: threadID, contact_id: adminID[i], is_admin: adminStatus }),
|
|
28
|
+
queue_name: 'admin_status',
|
|
29
|
+
task_id: i + 1,
|
|
30
|
+
failure_count: null
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
wsContent.payload.tasks.push({
|
|
36
|
+
label: '25',
|
|
37
|
+
payload: JSON.stringify({ thread_key: threadID, contact_id: adminID, is_admin: adminStatus }),
|
|
38
|
+
queue_name: 'admin_status',
|
|
39
|
+
task_id: 1,
|
|
40
|
+
failure_count: null
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
wsContent.payload = JSON.stringify(wsContent.payload);
|
|
45
|
+
return new Promise((resolve, reject) => ctx.mqttClient && ctx.mqttClient.publish('/ls_req', JSON.stringify(wsContent), {}, (err, _packet) => err ? reject(err) : resolve()));
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
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 changeArchivedStatus(threadOrThreads, archive, 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) {
|
|
17
|
+
if (err) return rejectFunc(err);
|
|
18
|
+
resolveFunc();
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var form = {};
|
|
23
|
+
|
|
24
|
+
if (utils.getType(threadOrThreads) === "Array") for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + threadOrThreads[i] + "]"] = archive;
|
|
25
|
+
else form["ids[" + threadOrThreads + "]"] = archive;
|
|
26
|
+
|
|
27
|
+
defaultFuncs
|
|
28
|
+
.post("https://www.facebook.com/ajax/mercury/change_archived_status.php", ctx.jar, form)
|
|
29
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
30
|
+
.then(function (resData) {
|
|
31
|
+
if (resData.error) throw resData;
|
|
32
|
+
return callback();
|
|
33
|
+
})
|
|
34
|
+
.catch(function (err) {
|
|
35
|
+
log.error("changeArchivedStatus", err);
|
|
36
|
+
return callback(err);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return returnPromise;
|
|
40
|
+
};
|
|
41
|
+
};
|
package/src/changeAvt.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var utils = require("../utils");
|
|
4
|
+
var log = require("npmlog");
|
|
5
|
+
/**
|
|
6
|
+
* It posts an image to a Facebook profile
|
|
7
|
+
* @param Api - The API object
|
|
8
|
+
* @param BotID - The ID of the bot you want to post the image to.
|
|
9
|
+
* @param form - The form data that you want to send.
|
|
10
|
+
* @returns The JSON.parse(Data.split("for (;;);")[1]); is returning the following:
|
|
11
|
+
* {"__ar":1,"payload":null,"jsmods":{"require":[["ImageUploader","uploadPhoto",[{"__m":"__elem_0"},{"__m":"__elem_1"},{"__m":"__elem_2"},{"__m":"__
|
|
12
|
+
*/
|
|
13
|
+
async function postImage(Api,BotID,form) {
|
|
14
|
+
var Data = await Api.httpPostFormData(`https://www.facebook.com/profile/picture/upload/?profile_id=${BotID}&photo_source=57&av=${BotID}`, form);
|
|
15
|
+
return JSON.parse(Data.split("for (;;);")[1]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
|
19
|
+
/* Changing the profile picture of the bot. */
|
|
20
|
+
return function changeAvt(link, caption, callback) {
|
|
21
|
+
var resolveFunc = function() {};
|
|
22
|
+
var rejectFunc = function() {};
|
|
23
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
|
24
|
+
resolveFunc = resolve;
|
|
25
|
+
rejectFunc = reject;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (!callback) {
|
|
29
|
+
callback = function(err, data) {
|
|
30
|
+
if (err) return rejectFunc(err);
|
|
31
|
+
resolveFunc(data);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
var Fetch = require('axios')
|
|
36
|
+
Fetch.get(link, { responseType: "stream" }).then(data => {
|
|
37
|
+
postImage(api, ctx.userID, { file: data.data }).then(data => {
|
|
38
|
+
if (data.error) throw new Error({ error: data.error, des: data.error.errorDescription });
|
|
39
|
+
var form = {
|
|
40
|
+
av: ctx.userID,
|
|
41
|
+
fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
|
|
42
|
+
fb_api_caller_class: "RelayModern",
|
|
43
|
+
doc_id: "5066134240065849",
|
|
44
|
+
variables: JSON.stringify({
|
|
45
|
+
input: {
|
|
46
|
+
caption: (caption || ""),
|
|
47
|
+
existing_photo_id: data.payload.fbid,
|
|
48
|
+
expiration_time: null,
|
|
49
|
+
profile_id: ctx.userID,
|
|
50
|
+
profile_pic_method: "EXISTING",
|
|
51
|
+
profile_pic_source: "TIMELINE",
|
|
52
|
+
scaled_crop_rect: {
|
|
53
|
+
height: 1,
|
|
54
|
+
width: 1,
|
|
55
|
+
x: 0,
|
|
56
|
+
y: 0
|
|
57
|
+
},
|
|
58
|
+
skip_cropping: true,
|
|
59
|
+
actor_id: ctx.userID,
|
|
60
|
+
client_mutation_id: Math.round(Math.random() * 19).toString()
|
|
61
|
+
},
|
|
62
|
+
isPage: false,
|
|
63
|
+
isProfile: true,
|
|
64
|
+
scale: 3,
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
defaultFuncs
|
|
68
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
69
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
70
|
+
.then(function(resData) {
|
|
71
|
+
if (resData.error) throw resData;
|
|
72
|
+
else return callback(null,true)
|
|
73
|
+
})
|
|
74
|
+
.catch(function(err) {
|
|
75
|
+
return callback(err);
|
|
76
|
+
});
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
throw e;
|
|
82
|
+
}
|
|
83
|
+
return returnPromise;
|
|
84
|
+
};
|
|
85
|
+
};
|
package/src/changeBio.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
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 changeBio(bio, publish, 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
|
+
if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") callback = publish;
|
|
17
|
+
else {
|
|
18
|
+
callback = function (err) {
|
|
19
|
+
if (err) return rejectFunc(err);
|
|
20
|
+
resolveFunc();
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (utils.getType(publish) != "Boolean") publish = false;
|
|
26
|
+
if (utils.getType(bio) != "String") {
|
|
27
|
+
bio = "";
|
|
28
|
+
publish = false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var form = {
|
|
32
|
+
fb_api_caller_class: "RelayModern",
|
|
33
|
+
fb_api_req_friendly_name: "ProfileCometSetBioMutation",
|
|
34
|
+
// This doc_is is valid as of May 23, 2020
|
|
35
|
+
doc_id: "2725043627607610",
|
|
36
|
+
variables: JSON.stringify({
|
|
37
|
+
input: {
|
|
38
|
+
bio: bio,
|
|
39
|
+
publish_bio_feed_story: publish,
|
|
40
|
+
actor_id: ctx.userID,
|
|
41
|
+
client_mutation_id: Math.round(Math.random() * 1024).toString()
|
|
42
|
+
},
|
|
43
|
+
hasProfileTileViewID: false,
|
|
44
|
+
profileTileViewID: null,
|
|
45
|
+
scale: 1
|
|
46
|
+
}),
|
|
47
|
+
av: ctx.userID
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
defaultFuncs
|
|
51
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
52
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
53
|
+
.then(function (resData) {
|
|
54
|
+
if (resData.errors) throw resData;
|
|
55
|
+
|
|
56
|
+
return callback();
|
|
57
|
+
})
|
|
58
|
+
.catch(function (err) {
|
|
59
|
+
log.error("changeBio", err);
|
|
60
|
+
return callback(err);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return returnPromise;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
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 changeBlockedStatus(userID, block, 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) {
|
|
17
|
+
if (err) return rejectFunc(err);
|
|
18
|
+
resolveFunc();
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
defaultFuncs
|
|
23
|
+
.post(`https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`, ctx.jar, { fbid: userID })
|
|
24
|
+
.then(utils.saveCookies(ctx.jar))
|
|
25
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
26
|
+
.then(function (resData) {
|
|
27
|
+
if (resData.error) throw resData;
|
|
28
|
+
return callback();
|
|
29
|
+
})
|
|
30
|
+
.catch(function (err) {
|
|
31
|
+
log.error("changeBlockedStatus", err);
|
|
32
|
+
return callback(err);
|
|
33
|
+
});
|
|
34
|
+
return returnPromise;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var utils = require("../utils");
|
|
4
|
+
var log = require("npmlog");
|
|
5
|
+
var bluebird = require("bluebird");
|
|
6
|
+
|
|
7
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
8
|
+
function handleUpload(image, callback) {
|
|
9
|
+
var uploads = [];
|
|
10
|
+
|
|
11
|
+
var form = {
|
|
12
|
+
images_only: "true",
|
|
13
|
+
"attachment[]": image
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
uploads.push(
|
|
17
|
+
defaultFuncs
|
|
18
|
+
.postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
|
|
19
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
20
|
+
.then(function (resData) {
|
|
21
|
+
if (resData.error) throw resData;
|
|
22
|
+
|
|
23
|
+
return resData.payload.metadata[0];
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// resolve all promises
|
|
28
|
+
bluebird
|
|
29
|
+
.all(uploads)
|
|
30
|
+
.then(resData => callback(null, resData))
|
|
31
|
+
.catch(function (err) {
|
|
32
|
+
log.error("handleUpload", err);
|
|
33
|
+
return callback(err);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return function changeGroupImage(image, threadID, callback) {
|
|
38
|
+
if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
|
|
39
|
+
|
|
40
|
+
var resolveFunc = function () { };
|
|
41
|
+
var rejectFunc = function () { };
|
|
42
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
|
43
|
+
resolveFunc = resolve;
|
|
44
|
+
rejectFunc = reject;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (!callback) {
|
|
48
|
+
callback = function (err) {
|
|
49
|
+
if (err) return rejectFunc(err);
|
|
50
|
+
resolveFunc();
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var messageAndOTID = utils.generateOfflineThreadingID();
|
|
55
|
+
var form = {
|
|
56
|
+
client: "mercury",
|
|
57
|
+
action_type: "ma-type:log-message",
|
|
58
|
+
author: "fbid:" + ctx.userID,
|
|
59
|
+
author_email: "",
|
|
60
|
+
ephemeral_ttl_mode: "0",
|
|
61
|
+
is_filtered_content: false,
|
|
62
|
+
is_filtered_content_account: false,
|
|
63
|
+
is_filtered_content_bh: false,
|
|
64
|
+
is_filtered_content_invalid_app: false,
|
|
65
|
+
is_filtered_content_quasar: false,
|
|
66
|
+
is_forward: false,
|
|
67
|
+
is_spoof_warning: false,
|
|
68
|
+
is_unread: false,
|
|
69
|
+
log_message_type: "log:thread-image",
|
|
70
|
+
manual_retry_cnt: "0",
|
|
71
|
+
message_id: messageAndOTID,
|
|
72
|
+
offline_threading_id: messageAndOTID,
|
|
73
|
+
source: "source:chat:web",
|
|
74
|
+
"source_tags[0]": "source:chat",
|
|
75
|
+
status: "0",
|
|
76
|
+
thread_fbid: threadID,
|
|
77
|
+
thread_id: "",
|
|
78
|
+
timestamp: Date.now(),
|
|
79
|
+
timestamp_absolute: "Today",
|
|
80
|
+
timestamp_relative: utils.generateTimestampRelative(),
|
|
81
|
+
timestamp_time_passed: "0"
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
handleUpload(image, function (err, payload) {
|
|
85
|
+
if (err) return callback(err);
|
|
86
|
+
|
|
87
|
+
form["thread_image_id"] = payload[0]["image_id"];
|
|
88
|
+
form["thread_id"] = threadID;
|
|
89
|
+
|
|
90
|
+
defaultFuncs
|
|
91
|
+
.post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
|
|
92
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
93
|
+
.then(function (resData) {
|
|
94
|
+
// check for errors here
|
|
95
|
+
if (resData.error) throw resData;
|
|
96
|
+
return callback();
|
|
97
|
+
})
|
|
98
|
+
.catch(function (err) {
|
|
99
|
+
log.error("changeGroupImage", err);
|
|
100
|
+
return callback(err);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return returnPromise;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
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 changeNickname(nickname, threadID, participantID, 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
|
+
if (!callback) {
|
|
15
|
+
callback = function (err) {
|
|
16
|
+
if (err) return rejectFunc(err);
|
|
17
|
+
resolveFunc();
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var form = {
|
|
22
|
+
nickname: nickname,
|
|
23
|
+
participant_id: participantID,
|
|
24
|
+
thread_or_other_fbid: threadID
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
defaultFuncs
|
|
28
|
+
.post("https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1", ctx.jar, form)
|
|
29
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
30
|
+
.then(function (resData) {
|
|
31
|
+
if (resData.error === 1545014) throw { error: "Trying to change nickname of user isn't in thread" };
|
|
32
|
+
if (resData.error === 1357031) 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." };
|
|
33
|
+
|
|
34
|
+
if (resData.error) throw resData;
|
|
35
|
+
|
|
36
|
+
return callback();
|
|
37
|
+
})
|
|
38
|
+
.catch(function (err) {
|
|
39
|
+
log.error("changeNickname", err);
|
|
40
|
+
return callback(err);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return returnPromise;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -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 changeThreadColor(color, threadID, 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) {
|
|
17
|
+
if (err) return rejectFunc(err);
|
|
18
|
+
resolveFunc(err);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var validatedColor = color !== null ? color.toLowerCase() : color; // API only accepts lowercase letters in hex string
|
|
23
|
+
var colorList = Object.keys(api.threadColors).map(function (name) {
|
|
24
|
+
return api.threadColors[name];
|
|
25
|
+
});
|
|
26
|
+
if (!colorList.includes(validatedColor)) throw { error: "The color you are trying to use is not a valid thread color. Use api.threadColors to find acceptable values." };
|
|
27
|
+
|
|
28
|
+
var form = {
|
|
29
|
+
dpr: 1,
|
|
30
|
+
queries: JSON.stringify({
|
|
31
|
+
o0: {
|
|
32
|
+
//This doc_id is valid as of January 31, 2020
|
|
33
|
+
doc_id: "1727493033983591",
|
|
34
|
+
query_params: {
|
|
35
|
+
data: {
|
|
36
|
+
actor_id: ctx.userID,
|
|
37
|
+
client_mutation_id: "0",
|
|
38
|
+
source: "SETTINGS",
|
|
39
|
+
theme_id: validatedColor,
|
|
40
|
+
thread_id: threadID
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
defaultFuncs
|
|
48
|
+
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
|
49
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
50
|
+
.then(function (resData) {
|
|
51
|
+
if (resData[resData.length - 1].error_results > 0) throw resData[0].o0.errors;
|
|
52
|
+
return callback();
|
|
53
|
+
})
|
|
54
|
+
.catch(function (err) {
|
|
55
|
+
log.error("changeThreadColor", err);
|
|
56
|
+
return callback(err);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return returnPromise;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
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 changeThreadEmoji(emoji, threadID, 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) {
|
|
17
|
+
if (err) return rejectFunc(err);
|
|
18
|
+
resolveFunc();
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
var form = {
|
|
22
|
+
emoji_choice: emoji,
|
|
23
|
+
thread_or_other_fbid: threadID
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
defaultFuncs
|
|
27
|
+
.post("https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg", ctx.jar, form)
|
|
28
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
29
|
+
.then(function (resData) {
|
|
30
|
+
if (resData.error === 1357031) 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." };
|
|
31
|
+
if (resData.error) throw resData;
|
|
32
|
+
return callback();
|
|
33
|
+
})
|
|
34
|
+
.catch(function (err) {
|
|
35
|
+
log.error("changeThreadEmoji", err);
|
|
36
|
+
return callback(err);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return returnPromise;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
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 createNewGroup(participantIDs, groupTitle, callback) {
|
|
8
|
+
if (utils.getType(groupTitle) == "Function") {
|
|
9
|
+
callback = groupTitle;
|
|
10
|
+
groupTitle = null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (utils.getType(participantIDs) !== "Array") throw { error: "createNewGroup: participantIDs should be an array." };
|
|
14
|
+
|
|
15
|
+
if (participantIDs.length < 2) throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
|
|
16
|
+
|
|
17
|
+
var resolveFunc = function () { };
|
|
18
|
+
var rejectFunc = function () { };
|
|
19
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
|
20
|
+
resolveFunc = resolve;
|
|
21
|
+
rejectFunc = reject;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (!callback) {
|
|
25
|
+
callback = function (err, threadID) {
|
|
26
|
+
if (err) return rejectFunc(err);
|
|
27
|
+
resolveFunc(threadID);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var pids = [];
|
|
32
|
+
for (var n in participantIDs) pids.push({ fbid: participantIDs[n] });
|
|
33
|
+
pids.push({ fbid: ctx.userID });
|
|
34
|
+
|
|
35
|
+
var form = {
|
|
36
|
+
fb_api_caller_class: "RelayModern",
|
|
37
|
+
fb_api_req_friendly_name: "MessengerGroupCreateMutation",
|
|
38
|
+
av: ctx.userID,
|
|
39
|
+
//This doc_id is valid as of January 11th, 2020
|
|
40
|
+
doc_id: "577041672419534",
|
|
41
|
+
variables: JSON.stringify({
|
|
42
|
+
input: {
|
|
43
|
+
entry_point: "jewel_new_group",
|
|
44
|
+
actor_id: ctx.userID,
|
|
45
|
+
participants: pids,
|
|
46
|
+
client_mutation_id: Math.round(Math.random() * 1024).toString(),
|
|
47
|
+
thread_settings: {
|
|
48
|
+
name: groupTitle,
|
|
49
|
+
joinable_mode: "PRIVATE",
|
|
50
|
+
thread_image_fbid: null
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
defaultFuncs
|
|
57
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
|
58
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
59
|
+
.then(function (resData) {
|
|
60
|
+
if (resData.errors) throw resData;
|
|
61
|
+
return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
|
|
62
|
+
})
|
|
63
|
+
.catch(function (err) {
|
|
64
|
+
log.error("createNewGroup", err);
|
|
65
|
+
return callback(err);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return returnPromise;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
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 createPoll(title, threadID, options, 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
|
+
if (utils.getType(options) == "Function") {
|
|
17
|
+
callback = options;
|
|
18
|
+
options = null;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
callback = function (err) {
|
|
22
|
+
if (err) return rejectFunc(err);
|
|
23
|
+
resolveFunc();
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!options) options = {}; // Initial poll options are optional
|
|
28
|
+
|
|
29
|
+
var form = {
|
|
30
|
+
target_id: threadID,
|
|
31
|
+
question_text: title
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Set fields for options (and whether they are selected initially by the posting user)
|
|
35
|
+
var ind = 0;
|
|
36
|
+
for (var opt in options) {
|
|
37
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
38
|
+
if (options.hasOwnProperty(opt)) {
|
|
39
|
+
form["option_text_array[" + ind + "]"] = opt;
|
|
40
|
+
form["option_is_selected_array[" + ind + "]"] = options[opt] ? "1" : "0";
|
|
41
|
+
ind++;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
defaultFuncs
|
|
46
|
+
.post("https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1", ctx.jar, form)
|
|
47
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
48
|
+
.then(function (resData) {
|
|
49
|
+
if (resData.payload.status != "success") throw resData;
|
|
50
|
+
return callback();
|
|
51
|
+
})
|
|
52
|
+
.catch(function (err) {
|
|
53
|
+
log.error("createPoll", err);
|
|
54
|
+
return callback(err);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return returnPromise;
|
|
58
|
+
};
|
|
59
|
+
};
|