fca-smart-shankar 1.5.6 → 12.0.0
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.
- package/.cache/nix/binary-cache-v6.sqlite +0 -0
- package/.cache/replit/env/latest +116 -47
- package/.cache/replit/env/latest.json +1 -1
- package/.cache/replit/modules/nix.res +1 -0
- package/.cache/replit/modules/nodejs-20.res +1 -0
- package/.cache/replit/nix/env.json +1 -0
- package/.cache/typescript/5.6/node_modules/.package-lock.json +171 -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/cheerio/LICENSE +21 -0
- package/.cache/typescript/5.6/node_modules/@types/cheerio/README.md +15 -0
- package/.cache/typescript/5.6/node_modules/@types/cheerio/index.d.ts +318 -0
- package/.cache/typescript/5.6/node_modules/@types/cheerio/package.json +71 -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/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/{LICENSE → .cache/typescript/5.6/node_modules/undici-types/LICENSE} +1 -1
- 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 +183 -0
- package/.cache/typescript/5.6/package.json +1 -0
- package/.replit +3 -3
- package/LICENSE-MIT +21 -0
- package/README.md +199 -1
- package/index.js +452 -425
- package/package.json +40 -87
- package/replit.nix +3 -0
- package/src/addExternalModule.js +14 -5
- package/src/addUserToGroup.js +57 -21
- package/src/changeAdminStatus.js +46 -22
- package/src/changeArchivedStatus.js +26 -12
- package/src/changeAvatar.js +136 -0
- package/src/{changeAvt.js → changeAvatarV2.js} +4 -3
- package/src/changeBio.js +26 -15
- package/src/changeBlockedStatus.js +22 -9
- package/src/changeBlockedStatusMqtt.js +80 -0
- package/src/changeCover.js +73 -0
- package/src/changeGroupImage.js +55 -26
- package/src/changeName.js +79 -0
- package/src/changeNickname.js +28 -14
- package/src/changeThreadColor.js +22 -19
- package/src/changeThreadEmoji.js +25 -12
- package/src/changeUsername.js +59 -0
- package/src/createCommentPost.js +230 -0
- package/src/createNewGroup.js +36 -18
- package/src/createPoll.js +28 -17
- package/src/createPost.js +276 -0
- package/src/data/getThreadInfo.json +1 -0
- package/src/deleteMessage.js +25 -14
- package/src/deleteThread.js +26 -13
- package/src/editMessage.js +56 -50
- package/src/editMessageOld.js +67 -0
- package/src/follow.js +74 -0
- package/src/forwardAttachment.js +28 -16
- package/src/getAccess.js +112 -0
- package/src/getAvatarUser.js +78 -0
- package/src/getCurrentUserID.js +3 -3
- package/src/getEmojiUrl.js +10 -8
- package/src/getFriendsList.js +25 -15
- package/src/getMessage.js +813 -81
- package/src/getRegion.js +7 -0
- package/src/getThreadHistory.js +241 -98
- package/src/getThreadHistoryDeprecated.js +93 -0
- package/src/getThreadInfo.js +90 -287
- package/src/getThreadInfoDeprecated.js +80 -0
- package/src/getThreadList.js +215 -158
- package/src/getThreadListDeprecated.js +75 -0
- package/src/getThreadPictures.js +40 -20
- package/src/getUID.js +113 -50
- package/src/getUserID.js +18 -14
- package/src/getUserInfo.js +35 -75
- package/src/handleFriendRequest.js +25 -14
- package/src/handleMessageRequest.js +37 -21
- package/src/httpGet.js +36 -20
- package/src/httpPost.js +37 -20
- package/src/httpPostFormData.js +53 -24
- package/src/listenMqtt.js +421 -654
- package/src/listenNotification.js +85 -0
- package/src/logout.js +24 -17
- package/src/markAsDelivered.js +23 -16
- package/src/markAsRead.js +43 -28
- package/src/markAsReadAll.js +22 -15
- package/src/markAsSeen.js +29 -19
- package/src/muteThread.js +18 -13
- package/src/pinMessage.js +59 -0
- package/src/refreshFb_dtsg.js +89 -0
- package/src/removeUserFromGroup.js +48 -18
- package/src/resolvePhotoUrl.js +22 -14
- package/src/searchForThread.js +23 -13
- package/src/searchStickers.js +53 -0
- package/src/sendMessage.js +180 -122
- package/src/sendMessageMqtt.js +322 -0
- package/src/sendTypingIndicator.js +42 -21
- package/src/sendTypingIndicatorV2.js +28 -0
- package/src/setMessageReaction.js +33 -20
- package/src/setMessageReactionMqtt.js +62 -0
- package/src/setPostReaction.js +105 -95
- package/src/setProfileGuard.js +45 -0
- package/src/setStoryReaction.js +64 -0
- package/src/setTitle.js +35 -19
- package/src/shareContact.js +92 -37
- package/src/shareLink.js +6 -5
- package/src/stopListenMqtt.js +23 -0
- package/src/threadColors.js +110 -18
- package/src/unfriend.js +20 -11
- package/src/unsendMessage.js +15 -10
- package/src/uploadAttachment.js +94 -0
- package/test/test-page.js +1 -1
- package/test/test.js +1 -1
- package/utils.js +1237 -2896
- package/.cache/replit/modules/nodejs-14.res +0 -1
- package/.cache/replit/modules/web.res +0 -1
- package/.cache/typescript/5.5/package.json +0 -1
- package/.config/configstore/update-notifier-npm.json +0 -4
- package/.gitattributes +0 -2
- package/.upm/store.json +0 -1
- package/Extra/Bypass/956/index.js +0 -234
- package/Extra/Bypass/test/aaaa.json +0 -170
- package/Extra/Bypass/test/index.js +0 -188
- package/Extra/Database/index.js +0 -469
- package/Extra/ExtraAddons.js +0 -82
- package/Extra/ExtraFindUID.js +0 -62
- package/Extra/ExtraGetThread.js +0 -365
- package/Extra/ExtraScreenShot.js +0 -430
- package/Extra/ExtraUptimeRobot.js +0 -38
- package/Extra/Html/Classic/script.js +0 -119
- package/Extra/Html/Classic/style.css +0 -8
- package/Extra/Security/Base/Step_1.js +0 -6
- package/Extra/Security/Base/Step_2.js +0 -22
- package/Extra/Security/Base/Step_3.js +0 -22
- package/Extra/Security/Base/index.js +0 -191
- package/Extra/Security/Index.js +0 -5
- package/Extra/Security/Step_1.js +0 -6
- package/Extra/Security/Step_2.js +0 -22
- package/Extra/Security/Step_3.js +0 -22
- package/Extra/Src/Change_Environment.js +0 -24
- package/Extra/Src/Check_Update.js +0 -67
- package/Extra/Src/History.js +0 -115
- package/Extra/Src/Instant_Update.js +0 -65
- package/Extra/Src/Last-Run.js +0 -65
- package/Extra/Src/Premium.js +0 -81
- package/Extra/Src/Release_Memory.js +0 -160
- package/Extra/Src/Websocket.js +0 -213
- package/Extra/Src/image/checkmate.jpg +0 -0
- package/Extra/Src/test.js +0 -28
- package/Extra/Src/uuid.js +0 -137
- package/Func/AcceptAgreement.js +0 -31
- package/Func/ClearCache.js +0 -64
- package/Func/ReportV1.js +0 -54
- package/Language/index.json +0 -222
- package/Main.js +0 -1266
- package/SECURITY.md +0 -18
- package/broadcast.js +0 -44
- package/logger.js +0 -66
- package/src/Dev_Horizon_Data.js +0 -125
- package/src/Dev_getThreadInfoOLD.js +0 -422
- package/src/Dev_shareTest2.js +0 -68
- package/src/Dev_shareTest3.js +0 -71
- package/src/Premium.js +0 -25
- package/src/Screenshot.js +0 -83
- package/src/getAccessToken.js +0 -28
- package/src/getThreadInfoOLD.js +0 -422
- package/src/getThreadMain.js +0 -220
- package/src/getUserInfoMain.js +0 -65
- package/src/getUserInfoV2.js +0 -32
- package/src/getUserInfoV3.js +0 -63
- package/src/getUserInfoV4.js +0 -55
- package/src/getUserInfoV5.js +0 -61
- package/src/listenMqttV1.js +0 -846
- package/src/sendMqttMessage.js +0 -71
- package/test/Database_Test.js +0 -4
- package/test/Db2.js +0 -530
- package/test/Horizon_Database/A_README.md +0 -1
- package/test/Horizon_Database/Database.db +0 -0
- package/test/data/shareAttach.js +0 -146
- package/test/data/something.mov +0 -0
- package/test/data/test.png +0 -0
- package/test/data/test.txt +0 -7
- package/test/env/.env +0 -0
- package/test/example-db.db +0 -0
- package/test/memoryleak.js +0 -18
- package/test/testname.js +0 -1342
- package/test/testv2.js +0 -3
- /package/{Extra/Security/AES_256_GCM/index.js → .cache/nix/binary-cache-v6.sqlite-journal} +0 -0
package/src/listenMqtt.js
CHANGED
@@ -1,94 +1,44 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
const WebSocket = require('ws');
|
8
|
-
const HttpsProxyAgent = require('https-proxy-agent');
|
1
|
+
"use strict";
|
2
|
+
var utils = require("../utils");
|
3
|
+
// @NethWs3Dev
|
4
|
+
var mqtt = require('mqtt');
|
5
|
+
var websocket = require('websocket-stream');
|
6
|
+
var HttpsProxyAgent = require('https-proxy-agent');
|
9
7
|
const EventEmitter = require('events');
|
10
|
-
|
11
|
-
const {
|
12
|
-
Transform
|
13
|
-
} = require('stream');
|
8
|
+
|
14
9
|
var identity = function() {};
|
15
10
|
var form = {};
|
16
11
|
var getSeqID = function() {};
|
17
|
-
global.Fca.Data.MsgCount = new Map();
|
18
|
-
global.Fca.Data.event = new Map();
|
19
|
-
|
20
|
-
const topics = ['/ls_req', '/ls_resp', '/legacy_web', '/webrtc', '/rtc_multi', '/onevc', '/br_sr', '/sr_res', '/t_ms', '/thread_typing', '/orca_typing_notifications', '/notify_disconnect', '/orca_presence', '/inbox', '/mercury', '/messaging_events', '/orca_message_notifications', '/pp', '/webrtc_response'];
|
21
|
-
|
22
|
-
let WebSocket_Global;
|
23
|
-
|
24
|
-
function buildProxy() {
|
25
|
-
const Proxy = new Transform({
|
26
|
-
objectMode: false,
|
27
|
-
transform(chunk, enc, next) {
|
28
|
-
if (WebSocket_Global.readyState !== WebSocket_Global.OPEN) {
|
29
|
-
return next();
|
30
|
-
}
|
31
|
-
|
32
|
-
let data;
|
33
|
-
if (typeof chunk === 'string') {
|
34
|
-
data = Buffer.from(chunk, 'utf8');
|
35
|
-
} else {
|
36
|
-
data = chunk;
|
37
|
-
}
|
38
12
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
WebSocket.onclose = () => {
|
64
|
-
Stream.end();
|
65
|
-
Stream.destroy();
|
66
|
-
};
|
67
|
-
|
68
|
-
WebSocket.onerror = (err) => {
|
69
|
-
Stream.destroy(err);
|
70
|
-
};
|
71
|
-
|
72
|
-
WebSocket.onmessage = (event) => {
|
73
|
-
const data = event.data instanceof ArrayBuffer ? Buffer.from(event.data) : Buffer.from(event.data, 'utf8');
|
74
|
-
Stream.push(data);
|
75
|
-
};
|
76
|
-
|
77
|
-
WebSocket.onopen = () => {
|
78
|
-
Stream.setReadable(Proxy);
|
79
|
-
Stream.setWritable(Proxy);
|
80
|
-
Stream.emit('connect');
|
81
|
-
};
|
82
|
-
|
83
|
-
WebSocket_Global = WebSocket;
|
84
|
-
Proxy.on('close', () => WebSocket.close());
|
85
|
-
|
86
|
-
return Stream;
|
87
|
-
}
|
13
|
+
var topics = [
|
14
|
+
"/legacy_web",
|
15
|
+
"/webrtc",
|
16
|
+
"/rtc_multi",
|
17
|
+
"/onevc",
|
18
|
+
"/br_sr", //Notification
|
19
|
+
//Need to publish /br_sr right after this
|
20
|
+
"/sr_res",
|
21
|
+
"/t_ms",
|
22
|
+
"/thread_typing",
|
23
|
+
"/orca_typing_notifications",
|
24
|
+
"/notify_disconnect",
|
25
|
+
//Need to publish /messenger_sync_create_queue right after this
|
26
|
+
"/orca_presence",
|
27
|
+
//Will receive /sr_res right here.
|
28
|
+
|
29
|
+
"/inbox",
|
30
|
+
"/mercury",
|
31
|
+
"/messaging_events",
|
32
|
+
"/orca_message_notifications",
|
33
|
+
"/pp",
|
34
|
+
"/webrtc_response",
|
35
|
+
];
|
88
36
|
|
89
37
|
function listenMqtt(defaultFuncs, api, ctx, globalCallback) {
|
90
|
-
|
91
|
-
|
38
|
+
//Don't really know what this does but I think it's for the active state?
|
39
|
+
//TODO: Move to ctx when implemented
|
40
|
+
var chatOn = ctx.globalOptions.online;
|
41
|
+
var foreground = false;
|
92
42
|
|
93
43
|
const sessionID = Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1;
|
94
44
|
const GUID = utils.getGUID()
|
@@ -110,7 +60,9 @@ function listenMqtt(defaultFuncs, api, ctx, globalCallback) {
|
|
110
60
|
no_auto_fg: true,
|
111
61
|
gas: null,
|
112
62
|
pack: [],
|
63
|
+
a: ctx.globalOptions.userAgent,
|
113
64
|
p: null,
|
65
|
+
aids: null,
|
114
66
|
php_override: ""
|
115
67
|
};
|
116
68
|
|
@@ -118,11 +70,11 @@ function listenMqtt(defaultFuncs, api, ctx, globalCallback) {
|
|
118
70
|
|
119
71
|
let host;
|
120
72
|
if (ctx.mqttEndpoint) {
|
121
|
-
host = `${ctx.mqttEndpoint}&sid=${sessionID}
|
73
|
+
host = `${ctx.mqttEndpoint}&sid=${sessionID}`;
|
122
74
|
} else if (ctx.region) {
|
123
|
-
host = `wss://edge-chat.facebook.com/chat?region=${ctx.region.toLowerCase()}&sid=${sessionID}
|
75
|
+
host = `wss://edge-chat.facebook.com/chat?region=${ctx.region.toLowerCase()}&sid=${sessionID}`;
|
124
76
|
} else {
|
125
|
-
host = `wss://edge-chat.facebook.com/chat?sid=${sessionID}
|
77
|
+
host = `wss://edge-chat.facebook.com/chat?sid=${sessionID}`;
|
126
78
|
}
|
127
79
|
|
128
80
|
const options = {
|
@@ -148,111 +100,65 @@ function listenMqtt(defaultFuncs, api, ctx, globalCallback) {
|
|
148
100
|
reconnectPeriod: 3,
|
149
101
|
};
|
150
102
|
|
151
|
-
if (ctx.globalOptions.proxy
|
152
|
-
|
103
|
+
if (typeof ctx.globalOptions.proxy != "undefined") {
|
104
|
+
var agent = new HttpsProxyAgent(ctx.globalOptions.proxy);
|
153
105
|
options.wsOptions.agent = agent;
|
154
106
|
}
|
155
107
|
|
156
|
-
ctx.mqttClient = new mqtt.Client(
|
157
|
-
|
108
|
+
ctx.mqttClient = new mqtt.Client(_ => websocket(host, options.wsOptions), options);
|
109
|
+
|
110
|
+
var mqttClient = ctx.mqttClient;
|
158
111
|
|
159
|
-
global.mqttClient.on('error', (err) => {
|
160
|
-
log.error('listenMqtt', err);
|
161
|
-
global.mqttClient.end();
|
162
112
|
|
113
|
+
function stopListening() {
|
114
|
+
if (mqttClient) {
|
115
|
+
mqttClient.unsubscribe("/webrtc");
|
116
|
+
mqttClient.unsubscribe("/rtc_multi");
|
117
|
+
mqttClient.unsubscribe("/onevc");
|
118
|
+
mqttClient.publish("/browser_close", "{}");
|
119
|
+
mqttClient.end(false, function(...data) {
|
120
|
+
ctx.mqttClient = null; mqttClient = null;
|
121
|
+
});
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
mqttClient.on('error', function(err) {
|
126
|
+
stopListening();
|
163
127
|
if (ctx.globalOptions.autoReconnect) {
|
164
128
|
getSeqID();
|
165
129
|
} else {
|
166
|
-
globalCallback({
|
167
|
-
type: 'stop_listen',
|
168
|
-
error: 'Server Đã Sập - Auto Restart'
|
169
|
-
}, null);
|
170
|
-
return process.exit(1);
|
130
|
+
globalCallback({ type: "stop_listen", error: "Connection refused: Server unavailable" }, null);
|
171
131
|
}
|
132
|
+
console.warn("login", "Error detected. Will relogin automatically...");
|
133
|
+
api.ws3.relogin();
|
134
|
+
return;
|
172
135
|
});
|
173
136
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
ctx.mqttClient.end();
|
181
|
-
global.Fca.Require.logger.Warning('Reconnecting MQTT Client...');
|
182
|
-
global.Fca.Data.Setup = false;
|
183
|
-
getSeqID();
|
184
|
-
}, Number(global.Fca.Require.FastConfig.RestartMQTT_Minutes) * 60 * 1000);
|
185
|
-
}
|
186
|
-
}
|
187
|
-
|
188
|
-
if (process.env.OnStatus === undefined) {
|
189
|
-
global.Fca.Require.logger.Normal('Bạn Đang Sài Phiên Bản: Premium Access');
|
190
|
-
|
191
|
-
if (Number(global.Fca.Require.FastConfig.AutoRestartMinutes) === 0) {
|
192
|
-
// something
|
193
|
-
} else if (Number(global.Fca.Require.FastConfig.AutoRestartMinutes) < 10) {
|
194
|
-
log.warn('AutoRestartMinutes', 'The number of minutes to automatically restart must be more than 10 minutes');
|
195
|
-
} else if (Number(global.Fca.Require.FastConfig.AutoRestartMinutes) < 0) {
|
196
|
-
log.warn('AutoRestartMinutes', 'Invalid auto-restart minutes!');
|
197
|
-
} else {
|
198
|
-
global.Fca.Require.logger.Normal(global.Fca.getText(global.Fca.Require.Language.Src.AutoRestart, global.Fca.Require.FastConfig.AutoRestartMinutes));
|
199
|
-
global.Fca.Require.logger.Normal(`Auto Restart MQTT Client After: ${global.Fca.Require.FastConfig.RestartMQTT_Minutes} Minutes`);
|
200
|
-
setTimeout(() => {
|
201
|
-
global.Fca.Require.logger.Normal(global.Fca.Require.Language.Src.OnRestart);
|
202
|
-
process.exit(1);
|
203
|
-
}, Number(global.Fca.Require.FastConfig.AutoRestartMinutes) * 60000);
|
204
|
-
}
|
205
|
-
require('../broadcast').startBroadcasting();
|
206
|
-
const MemoryManager = require('../Extra/Src/Release_Memory');
|
207
|
-
const path = require('path');
|
208
|
-
|
209
|
-
const SettingMemoryManager = {
|
210
|
-
warningThreshold: 0.7,
|
211
|
-
releaseThreshold: 0.8,
|
212
|
-
maxThreshold: 0.9,
|
213
|
-
interval: 60 * 1000,
|
214
|
-
logLevel: 'warn',
|
215
|
-
logFile: path.join(process.cwd(), 'Horizon_Database' ,'memory.log'),
|
216
|
-
smartReleaseEnabled: true,
|
217
|
-
allowLog: (global.Fca.Require.FastConfig.AntiStuckAndMemoryLeak.LogFile.Use || false)
|
218
|
-
};
|
219
|
-
|
220
|
-
const memoryManager = new MemoryManager(SettingMemoryManager);
|
221
|
-
|
222
|
-
memoryManager.autoStart(60 * 60 * 1000);
|
223
|
-
|
224
|
-
if (global.Fca.Require.FastConfig.AntiStuckAndMemoryLeak.AutoRestart.Use) {
|
225
|
-
memoryManager.onMaxMemory(function() {
|
226
|
-
global.Fca.Require.logger.Warning('Memory Usage >= 90% - Auto Restart Avoid Crash');
|
227
|
-
process.exit(1);
|
228
|
-
});
|
229
|
-
}
|
230
|
-
process.env.OnStatus = true;
|
231
|
-
}
|
232
|
-
|
233
|
-
topics.forEach((topicsub) => global.mqttClient.subscribe(topicsub));
|
234
|
-
|
235
|
-
|
236
|
-
let topic;
|
237
|
-
const queue = {
|
238
|
-
sync_api_version: 11,
|
239
|
-
max_deltas_able_to_process: 100,
|
137
|
+
mqttClient.on('connect', function() {
|
138
|
+
topics.forEach(topicsub => mqttClient.subscribe(topicsub));
|
139
|
+
var topic;
|
140
|
+
var queue = {
|
141
|
+
sync_api_version: 10,
|
142
|
+
max_deltas_able_to_process: 1000,
|
240
143
|
delta_batch_size: 500,
|
241
|
-
encoding:
|
144
|
+
encoding: "JSON",
|
242
145
|
entity_fbid: ctx.userID,
|
243
146
|
};
|
244
147
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
148
|
+
if (ctx.syncToken) {
|
149
|
+
topic = "/messenger_sync_get_diffs";
|
150
|
+
queue.last_seq_id = ctx.lastSeqId;
|
151
|
+
queue.sync_token = ctx.syncToken;
|
152
|
+
} else {
|
153
|
+
topic = "/messenger_sync_create_queue";
|
154
|
+
queue.initial_titan_sequence_id = ctx.lastSeqId;
|
155
|
+
queue.device_params = null;
|
156
|
+
}
|
253
157
|
|
158
|
+
mqttClient.publish(topic, JSON.stringify(queue), { qos: 1, retain: false });
|
159
|
+
mqttClient.publish("/foreground_state", JSON.stringify({ "foreground": chatOn }), { qos: 1 });
|
254
160
|
var rTimeout = setTimeout(function() {
|
255
|
-
|
161
|
+
mqttClient.end();
|
256
162
|
getSeqID();
|
257
163
|
}, 3000);
|
258
164
|
|
@@ -261,13 +167,17 @@ function listenMqtt(defaultFuncs, api, ctx, globalCallback) {
|
|
261
167
|
ctx.globalOptions.emitReady ? globalCallback({
|
262
168
|
type: "ready",
|
263
169
|
error: null
|
264
|
-
}) :
|
170
|
+
}) : "";
|
265
171
|
delete ctx.tmsWait;
|
266
172
|
};
|
267
173
|
});
|
268
174
|
|
269
|
-
|
270
|
-
|
175
|
+
mqttClient.on('message', function(topic, message, _packet) {
|
176
|
+
try {
|
177
|
+
var jsonMessage = JSON.parse(message);
|
178
|
+
} catch (ex) {
|
179
|
+
return console.error("listenMqtt", ex);
|
180
|
+
}
|
271
181
|
if (topic === "/t_ms") {
|
272
182
|
if (ctx.tmsWait && typeof ctx.tmsWait == "function") ctx.tmsWait();
|
273
183
|
|
@@ -277,31 +187,11 @@ function listenMqtt(defaultFuncs, api, ctx, globalCallback) {
|
|
277
187
|
}
|
278
188
|
|
279
189
|
if (jsonMessage.lastIssuedSeqId) ctx.lastSeqId = parseInt(jsonMessage.lastIssuedSeqId);
|
190
|
+
|
280
191
|
//If it contains more than 1 delta
|
281
192
|
for (var i in jsonMessage.deltas) {
|
282
193
|
var delta = jsonMessage.deltas[i];
|
283
|
-
parseDelta(defaultFuncs, api, ctx, globalCallback, {
|
284
|
-
"delta": delta
|
285
|
-
});
|
286
|
-
}
|
287
|
-
} else if (topic === "/ls_resp") {
|
288
|
-
const payload = JSON.parse(jsonMessage.payload); //'{"name":null,"step":[1,[1,[4,0,1,[5,"taskExists",[19,"415"]]],[23,[2,0],[1,[5,"replaceOptimsiticMessage","7192532113093667880","mid.$gABfX5li9LA6VdUymnWPRAdlkiawo"]]]],[1,[4,0,1,[5,"taskExists",[19,"415"]]],[23,[2,0],[1,[5,"mailboxTaskCompletionApiOnTaskCompletion",[19,"415"],true]]]],[1,[4,0,1,[5,"taskExists",[19,"415"]]],[23,[2,0],[1,[5,"removeTask",[19,"415"],[9]]]]]]}'
|
289
|
-
const request_ID = jsonMessage.request_id;
|
290
|
-
|
291
|
-
if (ctx.callback_Task[request_ID] != undefined && ctx.callback_Task[request_ID].type != undefined) {
|
292
|
-
const {
|
293
|
-
callback,
|
294
|
-
type
|
295
|
-
} = ctx.callback_Task[request_ID];
|
296
|
-
const Data = new getRespData(type, payload);
|
297
|
-
if (!callback) {
|
298
|
-
return;
|
299
|
-
}
|
300
|
-
else if (!Data) {
|
301
|
-
callback("Something went wrong 🐳", null);
|
302
|
-
} else {
|
303
|
-
callback(null, Data);
|
304
|
-
}
|
194
|
+
parseDelta(defaultFuncs, api, ctx, globalCallback, { "delta": delta });
|
305
195
|
}
|
306
196
|
} else if (topic === "/thread_typing" || topic === "/orca_typing_notifications") {
|
307
197
|
var typ = {
|
@@ -310,9 +200,7 @@ function listenMqtt(defaultFuncs, api, ctx, globalCallback) {
|
|
310
200
|
from: jsonMessage.sender_fbid.toString(),
|
311
201
|
threadID: utils.formatID((jsonMessage.thread || jsonMessage.sender_fbid).toString())
|
312
202
|
};
|
313
|
-
(function() {
|
314
|
-
globalCallback(null, typ);
|
315
|
-
})();
|
203
|
+
(function() { globalCallback(null, typ); })();
|
316
204
|
} else if (topic === "/orca_presence") {
|
317
205
|
if (!ctx.globalOptions.updatePresence) {
|
318
206
|
for (var i in jsonMessage.list) {
|
@@ -326,512 +214,421 @@ function listenMqtt(defaultFuncs, api, ctx, globalCallback) {
|
|
326
214
|
timestamp: data["l"] * 1000,
|
327
215
|
statuses: data["p"]
|
328
216
|
};
|
329
|
-
(function() {
|
330
|
-
globalCallback(null, presence);
|
331
|
-
})();
|
217
|
+
(function() { globalCallback(null, presence); })();
|
332
218
|
}
|
333
219
|
}
|
334
220
|
}
|
335
221
|
|
336
|
-
};
|
337
|
-
|
338
|
-
global.mqttClient.on('message', HandleMessage);
|
339
|
-
|
340
|
-
process.on('SIGINT', () => {
|
341
|
-
LogUptime();
|
342
|
-
process.kill(process.pid);
|
343
222
|
});
|
344
223
|
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
}
|
349
|
-
|
350
|
-
function getRespData(Type, payload) {
|
351
|
-
try {
|
352
|
-
switch (Type) {
|
353
|
-
case "sendMqttMessage": {
|
354
|
-
return {
|
355
|
-
type: Type,
|
356
|
-
threadID: payload.step[1][2][2][1][2], //this is sick bro
|
357
|
-
messageID: payload.step[1][2][2][1][3],
|
358
|
-
payload: payload.step[1][2]
|
359
|
-
};
|
360
|
-
}
|
361
|
-
default: { //!very LAZY :> cook yourself
|
362
|
-
return {
|
363
|
-
Data: payload.step[1][2][2][1],
|
364
|
-
type: Type,
|
365
|
-
payload: payload.step[1][2]
|
366
|
-
};
|
367
|
-
}
|
368
|
-
}
|
369
|
-
} catch (e) {
|
370
|
-
return null;
|
371
|
-
}
|
372
|
-
}
|
373
|
-
|
374
|
-
function LogUptime() {
|
375
|
-
const uptime = process.uptime();
|
376
|
-
const {
|
377
|
-
join
|
378
|
-
} = require('path');
|
379
|
-
const filePath = join(__dirname, '../CountTime.json');
|
380
|
-
|
381
|
-
let time1;
|
382
|
-
if (global.Fca.Require.fs.existsSync(filePath)) {
|
383
|
-
time1 = Number(global.Fca.Require.fs.readFileSync(filePath, 'utf8')) || 0;
|
384
|
-
} else {
|
385
|
-
time1 = 0;
|
386
|
-
}
|
387
|
-
|
388
|
-
global.Fca.Require.fs.writeFileSync(filePath, String(Number(uptime) + time1), 'utf8');
|
389
|
-
}
|
390
|
-
|
391
|
-
if (global.Fca.Require.FastConfig.AntiGetInfo.AntiGetThreadInfo) {
|
392
|
-
setInterval(() => {
|
393
|
-
try {
|
394
|
-
const { updateMessageCount, getData, hasData } = require('../Extra/ExtraGetThread');
|
395
|
-
const Data = global.Fca.Data.MsgCount;
|
396
|
-
const Arr = Array.from(Data.keys());
|
397
|
-
for (let i of Arr) {
|
398
|
-
const Count = parseInt(Data.get(i));
|
399
|
-
if (hasData(i)) {
|
400
|
-
let x = getData(i);
|
401
|
-
x.messageCount += Count;
|
402
|
-
updateMessageCount(i, x);
|
403
|
-
Data.delete(i);
|
404
|
-
}
|
405
|
-
}
|
406
|
-
|
407
|
-
} catch (e) {
|
408
|
-
console.log(e);
|
409
|
-
}
|
410
|
-
}, 30 * 1000);
|
224
|
+
mqttClient.on('close', function() {
|
225
|
+
//(function () { globalCallback("Connection closed."); })();
|
226
|
+
// client.end();
|
227
|
+
});
|
411
228
|
}
|
412
229
|
|
413
|
-
function parseDelta(defaultFuncs, api, ctx, globalCallback, {
|
414
|
-
delta
|
415
|
-
|
416
|
-
|
417
|
-
if (ctx.globalOptions.pageID && ctx.globalOptions.pageID !== delta.queue) return;
|
230
|
+
function parseDelta(defaultFuncs, api, ctx, globalCallback, v) {
|
231
|
+
if (v.delta.class == "NewMessage") {
|
232
|
+
//Not tested for pages
|
233
|
+
if (ctx.globalOptions.pageID && ctx.globalOptions.pageID != v.queue) return;
|
418
234
|
|
419
|
-
|
420
|
-
if (
|
421
|
-
|
235
|
+
(function resolveAttachmentUrl(i) {
|
236
|
+
if (v.delta.attachments && (i == v.delta.attachments.length)) {
|
237
|
+
var fmtMsg;
|
422
238
|
try {
|
423
|
-
fmtMsg = utils.formatDeltaMessage(
|
239
|
+
fmtMsg = utils.formatDeltaMessage(v);
|
424
240
|
} catch (err) {
|
425
|
-
return
|
241
|
+
return globalCallback({
|
242
|
+
error: "Problem parsing message object. Please open an issue at https://github.com/Schmavery/facebook-chat-api/issues.",
|
243
|
+
detail: err,
|
244
|
+
res: v,
|
245
|
+
type: "parse_error"
|
246
|
+
});
|
426
247
|
}
|
427
|
-
|
428
|
-
|
429
|
-
const isGroup = fmtMsg.isGroup;
|
430
|
-
const threadID = fmtMsg.threadID;
|
431
|
-
const messageID = fmtMsg.messageID;
|
432
|
-
|
433
|
-
global.Fca.Data.event.set("Data", {
|
434
|
-
isGroup,
|
435
|
-
threadID,
|
436
|
-
messageID
|
437
|
-
});
|
438
|
-
|
439
|
-
if (global.Fca.Require.FastConfig.AntiGetInfo.AntiGetThreadInfo) {
|
440
|
-
global.Fca.Data.MsgCount.set(fmtMsg.threadID, ((global.Fca.Data.MsgCount.get(fmtMsg.threadID)) + 1 || 1));
|
441
|
-
}
|
442
|
-
|
443
|
-
if (ctx.globalOptions.autoMarkDelivery) {
|
444
|
-
markDelivery(ctx, api, fmtMsg.threadID, fmtMsg.messageID);
|
445
|
-
}
|
248
|
+
if (fmtMsg)
|
249
|
+
if (ctx.globalOptions.autoMarkDelivery) markDelivery(ctx, api, fmtMsg.threadID, fmtMsg.messageID);
|
446
250
|
|
447
|
-
|
448
|
-
globalCallback(null, fmtMsg);
|
449
|
-
}
|
251
|
+
return !ctx.globalOptions.selfListen && fmtMsg.senderID === ctx.userID ? undefined : (function() { globalCallback(null, fmtMsg); })();
|
450
252
|
} else {
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
resolveAttachmentUrl(i + 1);
|
253
|
+
if (v.delta.attachments && (v.delta.attachments[i].mercury.attach_type == "photo")) {
|
254
|
+
api.resolvePhotoUrl(v.delta.attachments[i].fbid, (err, url) => {
|
255
|
+
if (!err) v.delta.attachments[i].mercury.metadata.url = url;
|
256
|
+
return resolveAttachmentUrl(i + 1);
|
456
257
|
});
|
457
|
-
} else
|
458
|
-
resolveAttachmentUrl(i + 1);
|
459
|
-
}
|
258
|
+
} else return resolveAttachmentUrl(i + 1);
|
460
259
|
}
|
461
|
-
};
|
260
|
+
})(0);
|
261
|
+
}
|
462
262
|
|
463
|
-
|
464
|
-
|
465
|
-
const clientPayload = utils.decodeClientPayload(delta.payload);
|
263
|
+
if (v.delta.class == "ClientPayload") {
|
264
|
+
var clientPayload = utils.decodeClientPayload(v.delta.payload);
|
466
265
|
if (clientPayload && clientPayload.deltas) {
|
467
|
-
for (
|
266
|
+
for (var i in clientPayload.deltas) {
|
267
|
+
var delta = clientPayload.deltas[i];
|
468
268
|
if (delta.deltaMessageReaction && !!ctx.globalOptions.listenEvents) {
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
269
|
+
(function() {
|
270
|
+
globalCallback(null, {
|
271
|
+
type: "message_reaction",
|
272
|
+
threadID: (delta.deltaMessageReaction.threadKey.threadFbId ? delta.deltaMessageReaction.threadKey.threadFbId : delta.deltaMessageReaction.threadKey.otherUserFbId).toString(),
|
273
|
+
messageID: delta.deltaMessageReaction.messageId,
|
274
|
+
reaction: delta.deltaMessageReaction.reaction,
|
275
|
+
senderID: delta.deltaMessageReaction.senderId.toString(),
|
276
|
+
userID: delta.deltaMessageReaction.userId.toString()
|
277
|
+
});
|
278
|
+
})();
|
478
279
|
} else if (delta.deltaRecallMessageData && !!ctx.globalOptions.listenEvents) {
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
280
|
+
(function() {
|
281
|
+
globalCallback(null, {
|
282
|
+
type: "message_unsend",
|
283
|
+
threadID: (delta.deltaRecallMessageData.threadKey.threadFbId ? delta.deltaRecallMessageData.threadKey.threadFbId : delta.deltaRecallMessageData.threadKey.otherUserFbId).toString(),
|
284
|
+
messageID: delta.deltaRecallMessageData.messageID,
|
285
|
+
senderID: delta.deltaRecallMessageData.senderID.toString(),
|
286
|
+
deletionTimestamp: delta.deltaRecallMessageData.deletionTimestamp,
|
287
|
+
timestamp: delta.deltaRecallMessageData.timestamp
|
288
|
+
});
|
289
|
+
})();
|
488
290
|
} else if (delta.deltaMessageReply) {
|
489
|
-
|
490
|
-
|
491
|
-
[] :
|
492
|
-
delta.deltaMessageReply.message.data === undefined ?
|
493
|
-
[] :
|
494
|
-
delta.deltaMessageReply.message.data.prng === undefined ?
|
495
|
-
[] :
|
291
|
+
//Mention block - #1
|
292
|
+
var mdata =
|
293
|
+
delta.deltaMessageReply.message === undefined ? [] :
|
294
|
+
delta.deltaMessageReply.message.data === undefined ? [] :
|
295
|
+
delta.deltaMessageReply.message.data.prng === undefined ? [] :
|
496
296
|
JSON.parse(delta.deltaMessageReply.message.data.prng);
|
297
|
+
var m_id = mdata.map(u => u.i);
|
298
|
+
var m_offset = mdata.map(u => u.o);
|
299
|
+
var m_length = mdata.map(u => u.l);
|
497
300
|
|
498
|
-
|
499
|
-
const m_offset = mdata.map((u) => u.o);
|
500
|
-
const m_length = mdata.map((u) => u.l);
|
501
|
-
|
502
|
-
const mentions = {};
|
503
|
-
for (let i = 0; i < m_id.length; i++) {
|
504
|
-
mentions[m_id[i]] = (delta.deltaMessageReply.message.body || '').substring(m_offset[i], m_offset[i] + m_length[i]);
|
505
|
-
}
|
301
|
+
var mentions = {};
|
506
302
|
|
507
|
-
|
508
|
-
|
303
|
+
for (var i = 0; i < m_id.length; i++) mentions[m_id[i]] = (delta.deltaMessageReply.message.body || "").substring(m_offset[i], m_offset[i] + m_length[i]);
|
304
|
+
//Mention block - 1#
|
305
|
+
var callbackToReturn = {
|
306
|
+
type: "message_reply",
|
509
307
|
threadID: (delta.deltaMessageReply.message.messageMetadata.threadKey.threadFbId ? delta.deltaMessageReply.message.messageMetadata.threadKey.threadFbId : delta.deltaMessageReply.message.messageMetadata.threadKey.otherUserFbId).toString(),
|
510
308
|
messageID: delta.deltaMessageReply.message.messageMetadata.messageId,
|
511
309
|
senderID: delta.deltaMessageReply.message.messageMetadata.actorFbId.toString(),
|
512
|
-
attachments:
|
513
|
-
.
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
args: (delta.deltaMessageReply.message.body || '').trim().split(/\s+/),
|
530
|
-
body: delta.deltaMessageReply.message.body || '',
|
310
|
+
attachments: delta.deltaMessageReply.message.attachments.map(function(att) {
|
311
|
+
var mercury = JSON.parse(att.mercuryJSON);
|
312
|
+
Object.assign(att, mercury);
|
313
|
+
return att;
|
314
|
+
}).map(att => {
|
315
|
+
var x;
|
316
|
+
try {
|
317
|
+
x = utils._formatAttachment(att);
|
318
|
+
} catch (ex) {
|
319
|
+
x = att;
|
320
|
+
x.error = ex;
|
321
|
+
x.type = "unknown";
|
322
|
+
}
|
323
|
+
return x;
|
324
|
+
}),
|
325
|
+
args: (delta.deltaMessageReply.message.body || "").trim().split(/\s+/),
|
326
|
+
body: (delta.deltaMessageReply.message.body || ""),
|
531
327
|
isGroup: !!delta.deltaMessageReply.message.messageMetadata.threadKey.threadFbId,
|
532
|
-
mentions,
|
533
|
-
timestamp:
|
534
|
-
participantIDs: (delta.deltaMessageReply.message.participants || []).map(
|
328
|
+
mentions: mentions,
|
329
|
+
timestamp: delta.deltaMessageReply.message.messageMetadata.timestamp,
|
330
|
+
participantIDs: (delta.deltaMessageReply.message.participants || []).map(e => e.toString())
|
535
331
|
};
|
536
332
|
|
537
333
|
if (delta.deltaMessageReply.repliedToMessage) {
|
538
|
-
|
539
|
-
|
540
|
-
[] :
|
541
|
-
delta.deltaMessageReply.repliedToMessage.data === undefined ?
|
542
|
-
[] :
|
543
|
-
delta.deltaMessageReply.repliedToMessage.data.prng === undefined ?
|
544
|
-
[] :
|
334
|
+
//Mention block - #2
|
335
|
+
mdata =
|
336
|
+
delta.deltaMessageReply.repliedToMessage === undefined ? [] :
|
337
|
+
delta.deltaMessageReply.repliedToMessage.data === undefined ? [] :
|
338
|
+
delta.deltaMessageReply.repliedToMessage.data.prng === undefined ? [] :
|
545
339
|
JSON.parse(delta.deltaMessageReply.repliedToMessage.data.prng);
|
340
|
+
m_id = mdata.map(u => u.i);
|
341
|
+
m_offset = mdata.map(u => u.o);
|
342
|
+
m_length = mdata.map(u => u.l);
|
546
343
|
|
547
|
-
|
548
|
-
const m_offset = mdata.map((u) => u.o);
|
549
|
-
const m_length = mdata.map((u) => u.l);
|
550
|
-
|
551
|
-
const rmentions = {};
|
552
|
-
for (let i = 0; i < m_id.length; i++) {
|
553
|
-
rmentions[m_id[i]] = (delta.deltaMessageReply.repliedToMessage.body || '').substring(m_offset[i], m_offset[i] + m_length[i]);
|
554
|
-
}
|
344
|
+
var rmentions = {};
|
555
345
|
|
346
|
+
for (var i = 0; i < m_id.length; i++) rmentions[m_id[i]] = (delta.deltaMessageReply.repliedToMessage.body || "").substring(m_offset[i], m_offset[i] + m_length[i]);
|
347
|
+
//Mention block - 2#
|
556
348
|
callbackToReturn.messageReply = {
|
557
349
|
threadID: (delta.deltaMessageReply.repliedToMessage.messageMetadata.threadKey.threadFbId ? delta.deltaMessageReply.repliedToMessage.messageMetadata.threadKey.threadFbId : delta.deltaMessageReply.repliedToMessage.messageMetadata.threadKey.otherUserFbId).toString(),
|
558
350
|
messageID: delta.deltaMessageReply.repliedToMessage.messageMetadata.messageId,
|
559
351
|
senderID: delta.deltaMessageReply.repliedToMessage.messageMetadata.actorFbId.toString(),
|
560
|
-
attachments: delta.deltaMessageReply.repliedToMessage.attachments
|
561
|
-
.
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
args: (delta.deltaMessageReply.repliedToMessage.body || '').trim().split(/\s+/),
|
578
|
-
body: delta.deltaMessageReply.repliedToMessage.body || '',
|
352
|
+
attachments: delta.deltaMessageReply.repliedToMessage.attachments.map(function(att) {
|
353
|
+
var mercury = JSON.parse(att.mercuryJSON);
|
354
|
+
Object.assign(att, mercury);
|
355
|
+
return att;
|
356
|
+
}).map(att => {
|
357
|
+
var x;
|
358
|
+
try {
|
359
|
+
x = utils._formatAttachment(att);
|
360
|
+
} catch (ex) {
|
361
|
+
x = att;
|
362
|
+
x.error = ex;
|
363
|
+
x.type = "unknown";
|
364
|
+
}
|
365
|
+
return x;
|
366
|
+
}),
|
367
|
+
args: (delta.deltaMessageReply.repliedToMessage.body || "").trim().split(/\s+/),
|
368
|
+
body: delta.deltaMessageReply.repliedToMessage.body || "",
|
579
369
|
isGroup: !!delta.deltaMessageReply.repliedToMessage.messageMetadata.threadKey.threadFbId,
|
580
370
|
mentions: rmentions,
|
581
|
-
timestamp:
|
582
|
-
participantIDs: (delta.deltaMessageReply.repliedToMessage.participants || []).map(
|
371
|
+
timestamp: delta.deltaMessageReply.repliedToMessage.messageMetadata.timestamp,
|
372
|
+
participantIDs: (delta.deltaMessageReply.repliedToMessage.participants || []).map(e => e.toString())
|
583
373
|
};
|
584
374
|
} else if (delta.deltaMessageReply.replyToMessageId) {
|
585
375
|
return defaultFuncs
|
586
|
-
.post(
|
587
|
-
av: ctx.globalOptions.pageID,
|
588
|
-
queries: JSON.stringify({
|
589
|
-
o0: {
|
590
|
-
doc_id
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
376
|
+
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, {
|
377
|
+
"av": ctx.globalOptions.pageID,
|
378
|
+
"queries": JSON.stringify({
|
379
|
+
"o0": {
|
380
|
+
//Using the same doc_id as forcedFetch
|
381
|
+
"doc_id": "2848441488556444",
|
382
|
+
"query_params": {
|
383
|
+
"thread_and_message_id": {
|
384
|
+
"thread_id": callbackToReturn.threadID,
|
385
|
+
"message_id": delta.deltaMessageReply.replyToMessageId.id,
|
386
|
+
}
|
387
|
+
}
|
388
|
+
}
|
389
|
+
})
|
599
390
|
})
|
600
391
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
601
392
|
.then((resData) => {
|
602
|
-
if (resData[resData.length - 1].error_results > 0)
|
603
|
-
|
604
|
-
|
605
|
-
res: resData
|
606
|
-
};
|
607
|
-
const fetchData = resData[0].o0.data.message;
|
608
|
-
const mobj = {};
|
609
|
-
|
610
|
-
for (const n in fetchData.message.ranges) {
|
611
|
-
mobj[fetchData.message.ranges[n].entity.id] = (fetchData.message.text || '').substr(fetchData.message.ranges[n].offset, fetchData.message.ranges[n].length);
|
393
|
+
if (resData[resData.length - 1].error_results > 0) {
|
394
|
+
const errorL = resData[0].o0.errors;
|
395
|
+
throw errorL;
|
612
396
|
}
|
397
|
+
if (resData[resData.length - 1].successful_results === 0) throw { error: "forcedFetch: there was no successful_results", res: resData };
|
398
|
+
var fetchData = resData[0].o0.data.message;
|
399
|
+
var mobj = {};
|
400
|
+
for (var n in fetchData.message.ranges) mobj[fetchData.message.ranges[n].entity.id] = (fetchData.message.text || "").substr(fetchData.message.ranges[n].offset, fetchData.message.ranges[n].length);
|
401
|
+
|
613
402
|
callbackToReturn.messageReply = {
|
614
|
-
type: 'Message',
|
615
403
|
threadID: callbackToReturn.threadID,
|
616
404
|
messageID: fetchData.message_id,
|
617
405
|
senderID: fetchData.message_sender.id.toString(),
|
618
|
-
attachments: fetchData.message.blob_attachment.map(
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
406
|
+
attachments: fetchData.message.blob_attachment.map(att => {
|
407
|
+
var x;
|
408
|
+
try {
|
409
|
+
x = utils._formatAttachment({ blob_attachment: att });
|
410
|
+
} catch (ex) {
|
411
|
+
x = att;
|
412
|
+
x.error = ex;
|
413
|
+
x.type = "unknown";
|
414
|
+
}
|
415
|
+
return x;
|
416
|
+
}),
|
417
|
+
args: (fetchData.message.text || "").trim().split(/\s+/) || [],
|
418
|
+
body: fetchData.message.text || "",
|
623
419
|
isGroup: callbackToReturn.isGroup,
|
624
420
|
mentions: mobj,
|
625
|
-
timestamp: parseInt(fetchData.timestamp_precise)
|
421
|
+
timestamp: parseInt(fetchData.timestamp_precise)
|
626
422
|
};
|
627
423
|
})
|
628
|
-
|
629
|
-
.
|
630
|
-
|
631
|
-
|
632
|
-
markDelivery(ctx, api, callbackToReturn.threadID, callbackToReturn.messageID);
|
633
|
-
}
|
634
|
-
|
635
|
-
if (!ctx.globalOptions.selfListen && callbackToReturn.senderID === ctx.userID) return;
|
636
|
-
globalCallback(null, callbackToReturn);
|
424
|
+
.catch(err => console.error("forcedFetch", err))
|
425
|
+
.finally(function() {
|
426
|
+
if (ctx.globalOptions.autoMarkDelivery) markDelivery(ctx, api, callbackToReturn.threadID, callbackToReturn.messageID);
|
427
|
+
!ctx.globalOptions.selfListen && callbackToReturn.senderID === ctx.userID ? undefined : (function() { globalCallback(null, callbackToReturn); })();
|
637
428
|
});
|
638
|
-
} else
|
639
|
-
|
640
|
-
|
641
|
-
if (ctx.globalOptions.autoMarkDelivery) {
|
642
|
-
markDelivery(ctx, api, callbackToReturn.threadID, callbackToReturn.messageID);
|
643
|
-
}
|
429
|
+
} else callbackToReturn.delta = delta;
|
430
|
+
|
431
|
+
if (ctx.globalOptions.autoMarkDelivery) markDelivery(ctx, api, callbackToReturn.threadID, callbackToReturn.messageID);
|
644
432
|
|
645
|
-
|
646
|
-
globalCallback(null, callbackToReturn);
|
433
|
+
return !ctx.globalOptions.selfListen && callbackToReturn.senderID === ctx.userID ? undefined : (function() { globalCallback(null, callbackToReturn); })();
|
647
434
|
}
|
648
435
|
}
|
649
|
-
|
650
436
|
return;
|
651
437
|
}
|
652
438
|
}
|
653
|
-
|
654
|
-
|
655
|
-
|
439
|
+
|
440
|
+
if (v.delta.class !== "NewMessage" && !ctx.globalOptions.listenEvents) return;
|
441
|
+
switch (v.delta.class) {
|
442
|
+
case "ReadReceipt":
|
443
|
+
var fmtMsg;
|
656
444
|
try {
|
657
|
-
fmtMsg = utils.formatDeltaReadReceipt(delta);
|
445
|
+
fmtMsg = utils.formatDeltaReadReceipt(v.delta);
|
658
446
|
} catch (err) {
|
659
|
-
return
|
447
|
+
return globalCallback({
|
448
|
+
error: "Problem parsing message object. Please open an issue at https://github.com/Schmavery/facebook-chat-api/issues.",
|
449
|
+
detail: err,
|
450
|
+
res: v.delta,
|
451
|
+
type: "parse_error"
|
452
|
+
});
|
660
453
|
}
|
661
|
-
globalCallback(null, fmtMsg);
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
case
|
667
|
-
case
|
668
|
-
case
|
669
|
-
case
|
670
|
-
case
|
671
|
-
case
|
672
|
-
case
|
673
|
-
case
|
674
|
-
case
|
675
|
-
|
676
|
-
case 'participant_joined_group_call': {
|
677
|
-
let fmtMsg;
|
454
|
+
return (function() { globalCallback(null, fmtMsg); })();
|
455
|
+
case "AdminTextMessage":
|
456
|
+
switch (v.delta.type) {
|
457
|
+
case "change_thread_theme":
|
458
|
+
case "change_thread_nickname":
|
459
|
+
case "change_thread_admins":
|
460
|
+
case "change_thread_approval_mode":
|
461
|
+
case "joinable_group_link_mode_change":
|
462
|
+
case "rtc_call_log":
|
463
|
+
case "group_poll":
|
464
|
+
case "update_vote":
|
465
|
+
case "magic_words":
|
466
|
+
case "messenger_call_log":
|
467
|
+
case "participant_joined_group_call":
|
468
|
+
var fmtMsg;
|
678
469
|
try {
|
679
|
-
fmtMsg = utils.formatDeltaEvent(delta);
|
470
|
+
fmtMsg = utils.formatDeltaEvent(v.delta);
|
680
471
|
} catch (err) {
|
681
|
-
|
682
|
-
|
472
|
+
return globalCallback({
|
473
|
+
error: "Problem parsing message object. Please open an issue at https://github.com/Schmavery/facebook-chat-api/issues.",
|
474
|
+
detail: err,
|
475
|
+
res: v.delta,
|
476
|
+
type: "parse_error"
|
477
|
+
});
|
683
478
|
}
|
684
|
-
globalCallback(null, fmtMsg);
|
685
|
-
|
686
|
-
|
479
|
+
return (function() { globalCallback(null, fmtMsg); })();
|
480
|
+
default:
|
481
|
+
return;
|
687
482
|
}
|
688
483
|
break;
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
const mid = delta.messageId;
|
695
|
-
const tid = delta.threadKey.threadFbId;
|
696
|
-
|
484
|
+
//For group images
|
485
|
+
case "ForcedFetch":
|
486
|
+
if (!v.delta.threadKey) return;
|
487
|
+
var mid = v.delta.messageId;
|
488
|
+
var tid = v.delta.threadKey.threadFbId;
|
697
489
|
if (mid && tid) {
|
698
490
|
const form = {
|
699
|
-
av: ctx.globalOptions.pageID,
|
700
|
-
queries: JSON.stringify({
|
701
|
-
o0: {
|
702
|
-
doc_id
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
491
|
+
"av": ctx.globalOptions.pageID,
|
492
|
+
"queries": JSON.stringify({
|
493
|
+
"o0": {
|
494
|
+
//This doc_id is valid as of March 25, 2020
|
495
|
+
"doc_id": "2848441488556444",
|
496
|
+
"query_params": {
|
497
|
+
"thread_and_message_id": {
|
498
|
+
"thread_id": tid.toString(),
|
499
|
+
"message_id": mid,
|
500
|
+
}
|
501
|
+
}
|
502
|
+
}
|
503
|
+
})
|
711
504
|
};
|
505
|
+
|
712
506
|
defaultFuncs
|
713
|
-
.post(
|
507
|
+
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
714
508
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
715
509
|
.then((resData) => {
|
716
|
-
if (resData[resData.length - 1].error_results > 0)
|
510
|
+
if (resData[resData.length - 1].error_results > 0) {
|
511
|
+
const errorL = resData[0].o0.errors;
|
512
|
+
throw errorL;
|
513
|
+
}
|
717
514
|
|
718
|
-
if (resData[resData.length - 1].successful_results === 0) throw {
|
719
|
-
error: 'forcedFetch: there was no successful_results',
|
720
|
-
res: resData
|
721
|
-
};
|
515
|
+
if (resData[resData.length - 1].successful_results === 0) throw { error: "forcedFetch: there was no successful_results", res: resData };
|
722
516
|
|
723
|
-
|
517
|
+
var fetchData = resData[0].o0.data.message;
|
724
518
|
|
725
|
-
if (utils.getType(fetchData)
|
726
|
-
log
|
519
|
+
if (utils.getType(fetchData) == "Object") {
|
520
|
+
console.log("forcedFetch", fetchData);
|
727
521
|
switch (fetchData.__typename) {
|
728
|
-
case
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
522
|
+
case "ThreadImageMessage":
|
523
|
+
(!ctx.globalOptions.selfListen &&
|
524
|
+
fetchData.message_sender.id.toString() === ctx.userID) ||
|
525
|
+
!ctx.loggedIn ?
|
526
|
+
undefined :
|
527
|
+
(function() {
|
528
|
+
globalCallback(null, {
|
529
|
+
type: "change_thread_image",
|
530
|
+
threadID: utils.formatID(tid.toString()),
|
531
|
+
snippet: fetchData.snippet,
|
532
|
+
timestamp: fetchData.timestamp_precise,
|
533
|
+
author: fetchData.message_sender.id,
|
534
|
+
image: {
|
535
|
+
attachmentID: fetchData.image_with_metadata && fetchData.image_with_metadata.legacy_attachment_id,
|
536
|
+
width: fetchData.image_with_metadata && fetchData.image_with_metadata.original_dimensions.x,
|
537
|
+
height: fetchData.image_with_metadata && fetchData.image_with_metadata.original_dimensions.y,
|
538
|
+
url: fetchData.image_with_metadata && fetchData.image_with_metadata.preview.uri
|
539
|
+
}
|
540
|
+
});
|
541
|
+
})();
|
745
542
|
break;
|
746
|
-
case
|
747
|
-
|
748
|
-
type:
|
543
|
+
case "UserMessage":
|
544
|
+
console.log("ff-Return", {
|
545
|
+
type: "message",
|
749
546
|
senderID: utils.formatID(fetchData.message_sender.id),
|
750
|
-
body: fetchData.message.text ||
|
547
|
+
body: fetchData.message.text || "",
|
751
548
|
threadID: utils.formatID(tid.toString()),
|
752
549
|
messageID: fetchData.message_id,
|
753
550
|
attachments: [{
|
754
|
-
type:
|
551
|
+
type: "share",
|
755
552
|
ID: fetchData.extensible_attachment.legacy_attachment_id,
|
756
553
|
url: fetchData.extensible_attachment.story_attachment.url,
|
554
|
+
|
757
555
|
title: fetchData.extensible_attachment.story_attachment.title_with_entities.text,
|
758
556
|
description: fetchData.extensible_attachment.story_attachment.description.text,
|
759
557
|
source: fetchData.extensible_attachment.story_attachment.source,
|
558
|
+
|
760
559
|
image: ((fetchData.extensible_attachment.story_attachment.media || {}).image || {}).uri,
|
761
560
|
width: ((fetchData.extensible_attachment.story_attachment.media || {}).image || {}).width,
|
762
561
|
height: ((fetchData.extensible_attachment.story_attachment.media || {}).image || {}).height,
|
763
562
|
playable: (fetchData.extensible_attachment.story_attachment.media || {}).is_playable || false,
|
764
563
|
duration: (fetchData.extensible_attachment.story_attachment.media || {}).playable_duration_in_ms || 0,
|
564
|
+
|
765
565
|
subattachments: fetchData.extensible_attachment.subattachments,
|
766
566
|
properties: fetchData.extensible_attachment.story_attachment.properties,
|
767
|
-
|
567
|
+
}],
|
768
568
|
mentions: {},
|
769
569
|
timestamp: parseInt(fetchData.timestamp_precise),
|
770
|
-
isGroup: (fetchData.message_sender.id
|
771
|
-
};
|
570
|
+
isGroup: (fetchData.message_sender.id != tid.toString())
|
571
|
+
});
|
572
|
+
globalCallback(null, {
|
573
|
+
type: "message",
|
574
|
+
senderID: utils.formatID(fetchData.message_sender.id),
|
575
|
+
body: fetchData.message.text || "",
|
576
|
+
threadID: utils.formatID(tid.toString()),
|
577
|
+
messageID: fetchData.message_id,
|
578
|
+
attachments: [{
|
579
|
+
type: "share",
|
580
|
+
ID: fetchData.extensible_attachment.legacy_attachment_id,
|
581
|
+
url: fetchData.extensible_attachment.story_attachment.url,
|
772
582
|
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
583
|
+
title: fetchData.extensible_attachment.story_attachment.title_with_entities.text,
|
584
|
+
description: fetchData.extensible_attachment.story_attachment.description.text,
|
585
|
+
source: fetchData.extensible_attachment.story_attachment.source,
|
586
|
+
|
587
|
+
image: ((fetchData.extensible_attachment.story_attachment.media || {}).image || {}).uri,
|
588
|
+
width: ((fetchData.extensible_attachment.story_attachment.media || {}).image || {}).width,
|
589
|
+
height: ((fetchData.extensible_attachment.story_attachment.media || {}).image || {}).height,
|
590
|
+
playable: (fetchData.extensible_attachment.story_attachment.media || {}).is_playable || false,
|
591
|
+
duration: (fetchData.extensible_attachment.story_attachment.media || {}).playable_duration_in_ms || 0,
|
592
|
+
|
593
|
+
subattachments: fetchData.extensible_attachment.subattachments,
|
594
|
+
properties: fetchData.extensible_attachment.story_attachment.properties,
|
595
|
+
}],
|
596
|
+
mentions: {},
|
597
|
+
timestamp: parseInt(fetchData.timestamp_precise),
|
598
|
+
isGroup: (fetchData.message_sender.id != tid.toString())
|
599
|
+
});
|
779
600
|
}
|
780
|
-
} else
|
781
|
-
log.error('forcedFetch', fetchData);
|
782
|
-
}
|
601
|
+
} else console.error("forcedFetch", fetchData);
|
783
602
|
})
|
784
|
-
.catch((err) =>
|
603
|
+
.catch((err) => console.error("forcedFetch", err));
|
785
604
|
}
|
786
605
|
break;
|
787
|
-
|
788
|
-
case
|
789
|
-
case
|
790
|
-
|
791
|
-
let formattedEvent;
|
606
|
+
case "ThreadName":
|
607
|
+
case "ParticipantsAddedToGroupThread":
|
608
|
+
case "ParticipantLeftGroupThread":
|
609
|
+
var formattedEvent;
|
792
610
|
try {
|
793
|
-
formattedEvent = utils.formatDeltaEvent(delta);
|
611
|
+
formattedEvent = utils.formatDeltaEvent(v.delta);
|
794
612
|
} catch (err) {
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
globalCallback(null, formattedEvent);
|
802
|
-
break;
|
803
|
-
}
|
804
|
-
case 'NewMessage': {
|
805
|
-
const hasLiveLocation = delta => {
|
806
|
-
const attachment = delta.attachments?.[0]?.mercury?.extensible_attachment;
|
807
|
-
const storyAttachment = attachment?.story_attachment;
|
808
|
-
return storyAttachment?.style_list?.includes('message_live_location');
|
809
|
-
};
|
810
|
-
|
811
|
-
if (delta.attachments?.length === 1 && hasLiveLocation(delta)) {
|
812
|
-
delta.class = 'UserLocation';
|
813
|
-
|
814
|
-
try {
|
815
|
-
const fmtMsg = utils.formatDeltaEvent(delta);
|
816
|
-
globalCallback(null, fmtMsg);
|
817
|
-
} catch (err) {
|
818
|
-
console.log(delta);
|
819
|
-
log.error('Lỗi Nhẹ', err);
|
820
|
-
}
|
613
|
+
return globalCallback({
|
614
|
+
error: "Problem parsing message object. Please open an issue at https://github.com/Schmavery/facebook-chat-api/issues.",
|
615
|
+
detail: err,
|
616
|
+
res: v.delta,
|
617
|
+
type: "parse_error"
|
618
|
+
});
|
821
619
|
}
|
822
|
-
|
823
|
-
}
|
620
|
+
return (!ctx.globalOptions.selfListen && formattedEvent.author.toString() === ctx.userID) || !ctx.loggedIn ? undefined : (function() { globalCallback(null, formattedEvent); })();
|
824
621
|
}
|
825
622
|
}
|
826
623
|
|
827
624
|
function markDelivery(ctx, api, threadID, messageID) {
|
828
625
|
if (threadID && messageID) {
|
829
626
|
api.markAsDelivered(threadID, messageID, (err) => {
|
830
|
-
if (err)
|
627
|
+
if (err) console.error("markAsDelivered", err);
|
831
628
|
else {
|
832
629
|
if (ctx.globalOptions.autoMarkRead) {
|
833
630
|
api.markAsRead(threadID, (err) => {
|
834
|
-
if (err)
|
631
|
+
if (err) console.error("markAsDelivered", err);
|
835
632
|
});
|
836
633
|
}
|
837
634
|
}
|
@@ -839,8 +636,6 @@ function markDelivery(ctx, api, threadID, messageID) {
|
|
839
636
|
}
|
840
637
|
}
|
841
638
|
|
842
|
-
|
843
|
-
|
844
639
|
module.exports = function(defaultFuncs, api, ctx) {
|
845
640
|
var globalCallback = identity;
|
846
641
|
getSeqID = function getSeqID() {
|
@@ -849,56 +644,29 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
849
644
|
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
850
645
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
851
646
|
.then((resData) => {
|
852
|
-
if (utils.getType(resData) != "Array")
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
} else if (!global.Fca.Require.FastConfig.AutoLogin) {
|
858
|
-
return global.Fca.Require.logger.Error(global.Fca.Require.Language.Index.ErrAppState);
|
859
|
-
}
|
860
|
-
return;
|
861
|
-
} else {
|
862
|
-
if (resData && resData[resData.length - 1].error_results > 0) throw resData[0].o0.errors;
|
863
|
-
if (resData[resData.length - 1].successful_results === 0) throw {
|
864
|
-
error: "getSeqId: there was no successful_results",
|
865
|
-
res: resData
|
866
|
-
};
|
867
|
-
if (resData[0].o0.data.viewer.message_threads.sync_sequence_id) {
|
868
|
-
ctx.lastSeqId = resData[0].o0.data.viewer.message_threads.sync_sequence_id;
|
869
|
-
listenMqtt(defaultFuncs, api, ctx, globalCallback);
|
870
|
-
} else throw {
|
871
|
-
error: "getSeqId: no sync_sequence_id found.",
|
872
|
-
res: resData
|
873
|
-
};
|
647
|
+
if (utils.getType(resData) != "Array")
|
648
|
+
throw { error: "Not logged in", res: resData };
|
649
|
+
if (resData[resData.length - 1].error_results > 0) {
|
650
|
+
const errorL = resData[0].o0.errors;
|
651
|
+
throw errorL;
|
874
652
|
}
|
653
|
+
if (resData[resData.length - 1].successful_results === 0) throw { error: "getSeqId: there was no successful_results", res: resData };
|
654
|
+
if (resData[0].o0.data.viewer.message_threads.sync_sequence_id) {
|
655
|
+
ctx.lastSeqId = resData[0].o0.data.viewer.message_threads.sync_sequence_id;
|
656
|
+
listenMqtt(defaultFuncs, api, ctx, globalCallback);
|
657
|
+
} else throw { error: "getSeqId: no sync_sequence_id found.", res: resData };
|
875
658
|
})
|
876
659
|
.catch((err) => {
|
877
|
-
|
878
|
-
|
660
|
+
if (utils.getType(err) == "Object" && err.error === "Not logged in") {
|
661
|
+
ctx.loggedIn = false;
|
662
|
+
}
|
879
663
|
return globalCallback(err);
|
880
664
|
});
|
881
665
|
};
|
882
666
|
|
883
|
-
return function(callback) {
|
884
|
-
class MessageEmitter extends EventEmitter {
|
885
|
-
stopListening(callback) {
|
886
|
-
callback = callback || (() => {});
|
887
|
-
globalCallback = identity;
|
888
|
-
if (ctx.mqttClient) {
|
889
|
-
ctx.mqttClient.unsubscribe("/webrtc");
|
890
|
-
ctx.mqttClient.unsubscribe("/rtc_multi");
|
891
|
-
ctx.mqttClient.unsubscribe("/onevc");
|
892
|
-
ctx.mqttClient.publish("/browser_close", "{}");
|
893
|
-
ctx.mqttClient.end(false, function(...data) {
|
894
|
-
ctx.mqttClient = undefined;
|
895
|
-
});
|
896
|
-
}
|
897
|
-
global.Fca.Data.StopListening = true;
|
898
|
-
}
|
899
|
-
}
|
667
|
+
return async function(callback) {
|
900
668
|
|
901
|
-
var msgEmitter = new
|
669
|
+
var msgEmitter = new EventEmitter();
|
902
670
|
globalCallback = (callback || function(error, message) {
|
903
671
|
if (error) return msgEmitter.emit("error", error);
|
904
672
|
msgEmitter.emit("message", message);
|
@@ -908,29 +676,28 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
908
676
|
if (!ctx.firstListen) ctx.lastSeqId = null;
|
909
677
|
ctx.syncToken = undefined;
|
910
678
|
ctx.t_mqttCalled = false;
|
911
|
-
|
912
679
|
//Same request as getThreadList
|
913
680
|
form = {
|
914
|
-
av: ctx.globalOptions.pageID,
|
915
|
-
queries: JSON.stringify({
|
916
|
-
o0: {
|
917
|
-
doc_id:
|
918
|
-
query_params: {
|
919
|
-
limit: 1,
|
920
|
-
before: null,
|
921
|
-
tags: [
|
922
|
-
includeDeliveryReceipts: false,
|
923
|
-
includeSeqID: true
|
924
|
-
}
|
925
|
-
}
|
926
|
-
})
|
681
|
+
"av": ctx.globalOptions.pageID,
|
682
|
+
"queries": JSON.stringify({
|
683
|
+
"o0": {
|
684
|
+
"doc_id": "3336396659757871",
|
685
|
+
"query_params": {
|
686
|
+
"limit": 1,
|
687
|
+
"before": null,
|
688
|
+
"tags": ["INBOX"],
|
689
|
+
"includeDeliveryReceipts": false,
|
690
|
+
"includeSeqID": true
|
691
|
+
}
|
692
|
+
}
|
693
|
+
})
|
927
694
|
};
|
928
695
|
|
929
|
-
|
930
696
|
if (!ctx.firstListen || !ctx.lastSeqId) getSeqID();
|
931
|
-
else
|
697
|
+
else {
|
698
|
+
listenMqtt(defaultFuncs, api, ctx, globalCallback);
|
699
|
+
}
|
932
700
|
ctx.firstListen = false;
|
933
|
-
|
934
701
|
return msgEmitter;
|
935
702
|
};
|
936
703
|
};
|