fca-priyansh 19.0.1 → 20.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.
Files changed (135) hide show
  1. package/.gitlab-ci.yml +22 -0
  2. package/CountTime.json +1 -0
  3. package/Extra/Balancer.js +49 -49
  4. package/Extra/BroadcastSystem.js +1 -0
  5. package/Extra/Bypass/956/index.js +233 -233
  6. package/Extra/Bypass/test/aaaa.json +169 -169
  7. package/Extra/Bypass/test/index.js +187 -187
  8. package/Extra/Database/index.js +468 -468
  9. package/Extra/ExtraAddons.js +82 -82
  10. package/Extra/ExtraFindUID.js +61 -61
  11. package/Extra/ExtraGetThread.js +365 -365
  12. package/Extra/ExtraScreenShot.js +430 -430
  13. package/Extra/ExtraUptimeRobot.js +142 -38
  14. package/Extra/Html/Classic/script.js +118 -118
  15. package/Extra/Html/Classic/style.css +7 -7
  16. package/Extra/Security/Base/Step_1.js +5 -5
  17. package/Extra/Security/Base/Step_2.js +22 -22
  18. package/Extra/Security/Base/Step_3.js +22 -22
  19. package/Extra/Security/Base/index.js +190 -190
  20. package/Extra/Security/Index.js +4 -4
  21. package/Extra/Security/Step_1.js +5 -5
  22. package/Extra/Security/Step_2.js +22 -22
  23. package/Extra/Security/Step_3.js +22 -22
  24. package/Extra/Src/Change_Environment.js +24 -24
  25. package/Extra/Src/Check_Update.js +66 -66
  26. package/Extra/Src/History.js +114 -114
  27. package/Extra/Src/Instant_Update.js +64 -64
  28. package/Extra/Src/Last-Run.js +64 -64
  29. package/Extra/Src/Premium.js +81 -81
  30. package/Extra/Src/Websocket.js +212 -212
  31. package/Extra/Src/uuid.js +137 -137
  32. package/Func/AcceptAgreement.js +31 -31
  33. package/Func/ClearCache.js +64 -64
  34. package/Func/ReportV1.js +54 -54
  35. package/LICENSE +21 -21
  36. package/Language/index.json +228 -228
  37. package/Main.js +1 -1290
  38. package/README.md +198 -198
  39. package/broadcast.js +1 -44
  40. package/errorHandler.js +151 -0
  41. package/index.js +1 -448
  42. package/logger.js +69 -66
  43. package/package.json +99 -98
  44. package/src/Dev_Horizon_Data.js +124 -124
  45. package/src/Dev_getThreadInfoOLD.js +421 -421
  46. package/src/Dev_shareTest2.js +68 -68
  47. package/src/Dev_shareTest3.js +71 -71
  48. package/src/Premium.js +24 -24
  49. package/src/Screenshot.js +82 -82
  50. package/src/addExternalModule.js +16 -16
  51. package/src/addUserToGroup.js +79 -79
  52. package/src/changeAdminStatus.js +79 -79
  53. package/src/changeArchivedStatus.js +41 -41
  54. package/src/changeAvt.js +84 -84
  55. package/src/changeBio.js +65 -65
  56. package/src/changeBlockedStatus.js +36 -36
  57. package/src/changeGroupImage.js +106 -106
  58. package/src/changeNickname.js +45 -45
  59. package/src/changeThreadColor.js +62 -62
  60. package/src/changeThreadEmoji.js +42 -42
  61. package/src/changeThreadTheme.js +263 -0
  62. package/src/comment.js +244 -0
  63. package/src/createNewGroup.js +70 -70
  64. package/src/createPoll.js +60 -60
  65. package/src/deleteMessage.js +45 -45
  66. package/src/deleteThread.js +43 -43
  67. package/src/editMessage.js +71 -71
  68. package/src/follow.js +119 -0
  69. package/src/forwardAttachment.js +48 -48
  70. package/src/friend.js +383 -0
  71. package/src/getAccessToken.js +27 -27
  72. package/src/getCurrentUserID.js +7 -7
  73. package/src/getEmojiUrl.js +27 -27
  74. package/src/getFriendsList.js +73 -73
  75. package/src/getMessage.js +102 -102
  76. package/src/getPendingFriendRequests.js +45 -0
  77. package/src/getThreadHistory.js +537 -537
  78. package/src/getThreadInfo.js +424 -423
  79. package/src/getThreadInfoOLD.js +421 -421
  80. package/src/getThreadList.js +213 -213
  81. package/src/getThreadMain.js +219 -219
  82. package/src/getThreadPictures.js +59 -59
  83. package/src/getUID.js +58 -58
  84. package/src/getUserID.js +62 -62
  85. package/src/getUserInfo.js +112 -112
  86. package/src/getUserInfoMain.js +64 -64
  87. package/src/getUserInfoV2.js +31 -31
  88. package/src/getUserInfoV3.js +62 -62
  89. package/src/getUserInfoV4.js +54 -54
  90. package/src/getUserInfoV5.js +60 -60
  91. package/src/handleFriendRequest.js +46 -46
  92. package/src/handleMessageRequest.js +49 -49
  93. package/src/httpGet.js +49 -49
  94. package/src/httpPost.js +48 -48
  95. package/src/httpPostFormData.js +40 -40
  96. package/src/listenMqtt.js +1 -956
  97. package/src/listenMqttV1.js +832 -846
  98. package/src/logout.js +68 -68
  99. package/src/markAsDelivered.js +48 -48
  100. package/src/markAsRead.js +70 -70
  101. package/src/markAsReadAll.js +42 -42
  102. package/src/markAsSeen.js +51 -51
  103. package/src/muteThread.js +47 -47
  104. package/src/notes.js +279 -0
  105. package/src/removeUserFromGroup.js +49 -49
  106. package/src/resolvePhotoUrl.js +37 -37
  107. package/src/searchForThread.js +43 -43
  108. package/src/sendMention.js +325 -0
  109. package/src/sendMessage.js +1 -386
  110. package/src/sendMqttMessage.js +70 -70
  111. package/src/sendTypingIndicator.js +79 -80
  112. package/src/setMessageReaction.js +109 -109
  113. package/src/setPostReaction.js +101 -101
  114. package/src/setTitle.js +74 -74
  115. package/src/share.js +98 -0
  116. package/src/shareContact.js +55 -55
  117. package/src/shareLink.js +58 -58
  118. package/src/stickers.js +525 -0
  119. package/src/story.js +267 -0
  120. package/src/threadColors.js +38 -38
  121. package/src/unfriend.js +43 -43
  122. package/src/unsendMessage.js +47 -47
  123. package/src/unsendMqttMessage.js +65 -65
  124. package/test/data/shareAttach.js +146 -146
  125. package/test/data/test.txt +7 -7
  126. package/test/example-config.json +18 -18
  127. package/test/test-page.js +140 -140
  128. package/test/test.js +385 -385
  129. package/test/testv2.js +2 -2
  130. package/userAgentManager.js +129 -0
  131. package/utils.js +1 -3077
  132. package/.github/workflows/publish.yml +0 -20
  133. package/Extra/Src/Release_Memory.js +0 -160
  134. package/Extra/Src/test.js +0 -28
  135. package/SECURITY.md +0 -17
@@ -0,0 +1,325 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ /**
8
+ * Send a message with mentions using MQTT API
9
+ * This function is specifically designed for text-only messages with mentions
10
+ * For messages with attachments, use sendMessage instead
11
+ *
12
+ * @param {string|Object} msg - The message to send. Can be:
13
+ * - String: Plain text message
14
+ * - Object: { body: string, mentions: Array<{tag: string, id: string}> }
15
+ * @param {string} threadID - The ID of the thread to send the message to
16
+ * @param {function} callback - Optional callback function
17
+ * @param {string} replyToMessage - Optional message ID to reply to
18
+ * @returns {Promise} Promise that resolves when message is sent
19
+ */
20
+ return function sendMention(msg, threadID, callback, replyToMessage) {
21
+ if (!ctx.mqttClient || !ctx.mqttClient.connected) {
22
+ const err = { error: "MQTT client not connected. sendMention requires MQTT connection." };
23
+ if (callback) callback(err);
24
+ throw err;
25
+ }
26
+
27
+ if (typeof threadID === "function") {
28
+ return threadID({ error: "Pass a threadID as a second argument." });
29
+ }
30
+
31
+ if (typeof callback === "string" && !replyToMessage) {
32
+ replyToMessage = callback;
33
+ callback = undefined;
34
+ }
35
+
36
+ var resolveFunc = function () { };
37
+ var rejectFunc = function () { };
38
+ var returnPromise = new Promise(function (resolve, reject) {
39
+ resolveFunc = resolve;
40
+ rejectFunc = reject;
41
+ });
42
+
43
+ if (!callback) {
44
+ callback = function (err, data) {
45
+ if (err) return rejectFunc(err);
46
+ resolveFunc(data);
47
+ };
48
+ }
49
+
50
+ // Coerce message to object format
51
+ var msgType = utils.getType(msg);
52
+ if (msgType !== "String" && msgType !== "Object") {
53
+ return callback({
54
+ error: "Message should be of type string or object and not " + msgType + "."
55
+ });
56
+ }
57
+
58
+ const m = msgType === "String" ? { body: msg } : msg;
59
+ const baseBody = m.body != null ? String(m.body) : "";
60
+
61
+ // Check if attachment is present
62
+ const hasAttachment = m.attachment != null;
63
+
64
+ // If attachment is present, skip mentions and just send attachment
65
+ if (hasAttachment) {
66
+ log.info("sendMention", "Attachment detected - skipping mentions, sending attachment only");
67
+ // Use sendMessage for attachments (it will handle it properly)
68
+ // Import sendMessage function or use api.sendMessage
69
+ // Since we're in the same module system, we can use api.sendMessage
70
+ const attachmentMsg = { ...m };
71
+ delete attachmentMsg.mentions; // Remove mentions when attachment is present
72
+
73
+ // Use the standard sendMessage API for attachments
74
+ if (api.sendMessage) {
75
+ return api.sendMessage(attachmentMsg, threadID, callback, replyToMessage);
76
+ } else {
77
+ return callback({
78
+ error: "sendMessage API not available. Cannot send attachment."
79
+ });
80
+ }
81
+ }
82
+
83
+ // Validate mentions (only if no attachment)
84
+ if (!m.mentions || !Array.isArray(m.mentions) || m.mentions.length === 0) {
85
+ return callback({
86
+ error: "sendMention requires mentions array. Use sendMessage for messages without mentions."
87
+ });
88
+ }
89
+
90
+ // Build mention data
91
+ const mentionData = buildMentionData(m, baseBody);
92
+ if (!mentionData) {
93
+ return callback({
94
+ error: "Failed to build mention data. Check mentions format."
95
+ });
96
+ }
97
+
98
+ const reqID = Math.floor(100 + Math.random() * 900);
99
+ const epoch = (BigInt(Date.now()) << 22n).toString();
100
+
101
+ const payload0 = {
102
+ thread_id: String(threadID),
103
+ otid: utils.generateOfflineThreadingID(),
104
+ source: 2097153,
105
+ send_type: 1, // Text message with mentions
106
+ sync_group: 1,
107
+ mark_thread_read: 1,
108
+ text: baseBody === "" ? null : baseBody,
109
+ initiating_source: 0,
110
+ skip_url_preview_gen: 0,
111
+ text_has_links: hasLinks(baseBody) ? 1 : 0,
112
+ multitab_env: 0,
113
+ metadata_dataclass: JSON.stringify({ media_accessibility_metadata: { alt_text: null } }),
114
+ mention_data: mentionData // Add mention data
115
+ };
116
+
117
+ if (replyToMessage) {
118
+ payload0.reply_metadata = {
119
+ reply_source_id: replyToMessage,
120
+ reply_source_type: 1,
121
+ reply_type: 0
122
+ };
123
+ }
124
+
125
+ const content = {
126
+ app_id: "2220391788200892",
127
+ payload: {
128
+ tasks: [
129
+ {
130
+ label: "46",
131
+ payload: payload0,
132
+ queue_name: String(threadID),
133
+ task_id: 400,
134
+ failure_count: null
135
+ },
136
+ {
137
+ label: "21",
138
+ payload: {
139
+ thread_id: String(threadID),
140
+ last_read_watermark_ts: Date.now(),
141
+ sync_group: 1
142
+ },
143
+ queue_name: String(threadID),
144
+ task_id: 401,
145
+ failure_count: null
146
+ }
147
+ ],
148
+ epoch_id: epoch,
149
+ version_id: "24804310205905615",
150
+ data_trace_id: "#" + Buffer.from(String(Math.random())).toString("base64").replace(/=+$/g, "")
151
+ },
152
+ request_id: reqID,
153
+ type: 3
154
+ };
155
+
156
+ content.payload.tasks.forEach(t => (t.payload = JSON.stringify(t.payload)));
157
+ content.payload = JSON.stringify(content.payload);
158
+
159
+ // Publish to MQTT and wait for response
160
+ return publishWithAck(content, baseBody, reqID, callback);
161
+ };
162
+
163
+ // Helper function to check for links
164
+ function hasLinks(s) {
165
+ return typeof s === "string" && /(https?:\/\/|www\.|t\.me\/|fb\.me\/|youtu\.be\/|facebook\.com\/|youtube\.com\/)/i.test(s);
166
+ }
167
+
168
+ // Build mention data from mentions array
169
+ function buildMentionData(msg, baseBody) {
170
+ if (!msg.mentions || !Array.isArray(msg.mentions) || !msg.mentions.length) return null;
171
+
172
+ const base = typeof baseBody === "string" ? baseBody : "";
173
+ const ids = [];
174
+ const offsets = [];
175
+ const lengths = [];
176
+ const types = [];
177
+ let cursor = 0;
178
+
179
+ for (const m of msg.mentions) {
180
+ const raw = String(m.tag || "").trim();
181
+ const name = raw.replace(/^@+/, "").trim();
182
+
183
+ if (!name || name.length === 0) {
184
+ log.warn("sendMention", "Skipping empty mention tag");
185
+ continue;
186
+ }
187
+
188
+ const start = Number.isInteger(m.fromIndex) ? m.fromIndex : cursor;
189
+
190
+ // Try multiple search strategies to find the name in the body
191
+ let idx = -1;
192
+ let adj = 0;
193
+
194
+ // Strategy 1: Exact match with @ symbol
195
+ if (raw.startsWith("@")) {
196
+ idx = base.indexOf(raw, start);
197
+ if (idx !== -1) {
198
+ adj = raw.length - name.length;
199
+ }
200
+ }
201
+
202
+ // Strategy 2: Exact match of name only (without @)
203
+ if (idx === -1) {
204
+ idx = base.indexOf(name, start);
205
+ adj = 0;
206
+ }
207
+
208
+ // Strategy 3: Case-insensitive search
209
+ if (idx === -1) {
210
+ const lowerBase = base.toLowerCase();
211
+ const lowerName = name.toLowerCase();
212
+ idx = lowerBase.indexOf(lowerName, start);
213
+ adj = 0;
214
+ }
215
+
216
+ // Strategy 4: Find name that's surrounded by spaces or special chars
217
+ if (idx === -1) {
218
+ const regex = new RegExp(`\\b${name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`, 'i');
219
+ const match = base.substring(start).match(regex);
220
+ if (match) {
221
+ idx = start + match.index;
222
+ adj = 0;
223
+ }
224
+ }
225
+
226
+ // If still not found, try to find any occurrence
227
+ if (idx < 0) {
228
+ idx = base.lastIndexOf(name);
229
+ if (idx === -1) {
230
+ // Last resort: use cursor position
231
+ idx = Math.max(cursor, base.length);
232
+ }
233
+ adj = 0;
234
+ }
235
+
236
+ const off = Math.max(0, idx + adj);
237
+ const nameLen = name.length;
238
+
239
+ ids.push(String(m.id || 0));
240
+ offsets.push(off);
241
+ lengths.push(nameLen);
242
+ types.push("p");
243
+ cursor = off + nameLen;
244
+ }
245
+
246
+ if (ids.length === 0) return null;
247
+
248
+ return {
249
+ mention_ids: ids.join(","),
250
+ mention_offsets: offsets.join(","),
251
+ mention_lengths: lengths.join(","),
252
+ mention_types: types.join(",")
253
+ };
254
+ }
255
+
256
+ // Publish to MQTT and wait for acknowledgment
257
+ function publishWithAck(content, text, reqID, callback) {
258
+ const mqttClient = ctx.mqttClient;
259
+ return new Promise((resolve, reject) => {
260
+ let done = false;
261
+ const cleanup = () => {
262
+ if (done) return;
263
+ done = true;
264
+ mqttClient.removeListener("message", handleRes);
265
+ };
266
+
267
+ const handleRes = (topic, message) => {
268
+ if (topic !== "/ls_resp") return;
269
+ let jsonMsg;
270
+ try {
271
+ jsonMsg = JSON.parse(message.toString());
272
+ jsonMsg.payload = JSON.parse(jsonMsg.payload);
273
+ } catch {
274
+ return;
275
+ }
276
+ if (jsonMsg.request_id !== reqID) return;
277
+
278
+ const { threadID, messageID } = extractIdsFromPayload(jsonMsg.payload);
279
+ const bodies = { body: text || null, messageID, threadID };
280
+ cleanup();
281
+ callback && callback(undefined, bodies);
282
+ resolve(bodies);
283
+ };
284
+
285
+ mqttClient.on("message", handleRes);
286
+ mqttClient.publish("/ls_req", JSON.stringify(content), { qos: 1, retain: false }, err => {
287
+ if (err) {
288
+ cleanup();
289
+ callback && callback(err);
290
+ reject(err);
291
+ }
292
+ });
293
+
294
+ setTimeout(() => {
295
+ if (done) return;
296
+ cleanup();
297
+ const err = { error: "Timeout waiting for ACK" };
298
+ callback && callback(err);
299
+ reject(err);
300
+ }, 15000);
301
+ });
302
+ }
303
+
304
+ // Extract message ID and thread ID from MQTT response payload
305
+ function extractIdsFromPayload(payload) {
306
+ let messageID = null;
307
+ let threadID = null;
308
+
309
+ function walk(n) {
310
+ if (Array.isArray(n)) {
311
+ if (n[0] === 5 && (n[1] === "replaceOptimsiticMessage" || n[1] === "replaceOptimisticMessage")) {
312
+ messageID = String(n[3]);
313
+ }
314
+ if (n[0] === 5 && n[1] === "writeCTAIdToThreadsTable") {
315
+ const a = n[2];
316
+ if (Array.isArray(a) && a[0] === 19) threadID = String(a[1]);
317
+ }
318
+ for (const x of n) walk(x);
319
+ }
320
+ }
321
+ walk(payload?.step);
322
+ return { threadID, messageID };
323
+ }
324
+ };
325
+