fca-shankar-bot 20.2.0 → 20.3.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 (53) hide show
  1. package/.replit +14 -1
  2. package/Extra/Balancer.js +49 -0
  3. package/Extra/ExtraAddons.js +4 -4
  4. package/Extra/ExtraGetThread.js +27 -27
  5. package/Extra/ExtraScreenShot.js +3 -3
  6. package/Extra/ExtraUptimeRobot.js +4 -4
  7. package/Extra/Src/Change_Environment.js +2 -2
  8. package/Extra/Src/Check_Update.js +3 -3
  9. package/Extra/Src/Instant_Update.js +2 -2
  10. package/Extra/Src/Premium.js +7 -7
  11. package/Extra/Src/Release_Memory.js +7 -7
  12. package/Extra/Src/Websocket.js +12 -12
  13. package/Func/ClearCache.js +2 -2
  14. package/LICENSE +21 -0
  15. package/Language/index.json +22 -16
  16. package/Main.js +515 -349
  17. package/README.md +198 -0
  18. package/SECURITY.md +17 -0
  19. package/broadcast.js +44 -0
  20. package/index.js +215 -31
  21. package/logger.js +51 -122
  22. package/package.json +17 -15
  23. package/src/Dev_Horizon_Data.js +2 -2
  24. package/src/editMessage.js +45 -38
  25. package/src/listenMqtt.js +395 -373
  26. package/src/listenMqttV1.js +11 -11
  27. package/src/sendMessage.js +2 -2
  28. package/src/sendMqttMessage.js +51 -251
  29. package/src/setMessageReaction.js +64 -66
  30. package/src/shareContact.js +50 -75
  31. package/src/unsendMessage.js +32 -126
  32. package/src/unsendMqttMessage.js +66 -0
  33. package/test/data/shareAttach.js +146 -0
  34. package/test/data/something.mov +0 -0
  35. package/test/data/test.png +0 -0
  36. package/test/data/test.txt +7 -0
  37. package/test/example-config.json +18 -0
  38. package/test/test-page.js +140 -0
  39. package/test/test.js +385 -0
  40. package/test/testv2.js +3 -0
  41. package/utils.js +50 -11
  42. package/.cache/replit/env/latest +0 -49
  43. package/.cache/replit/env/latest.json +0 -1
  44. package/.cache/replit/modules/nodejs-20.res +0 -1
  45. package/.cache/replit/modules/replit.res +0 -1
  46. package/.cache/replit/modules.stamp +0 -0
  47. package/.cache/replit/toolchain.json +0 -1
  48. package/CountTime.json +0 -1
  49. package/src/followUser.js +0 -171
  50. package/src/getFacebookInfo.js +0 -69
  51. package/src/listenMqtt.jk +0 -732
  52. package/src/postStory.js +0 -122
  53. package/src/refreshFb_dtsg.js +0 -81
@@ -3,78 +3,53 @@
3
3
 
4
4
  var utils = require("../utils");
5
5
 
6
- module.exports = function(defaultFuncs, api, ctx) {
7
- return function shareContact(text, senderID, threadID, callback) {
8
- let resolveFunc = function() {};
9
- let rejectFunc = function() {};
10
-
11
- const returnPromise = new Promise(function(resolve, reject) {
12
- resolveFunc = resolve;
13
- rejectFunc = reject;
14
- });
15
-
16
- if (!senderID || !threadID) {
17
- const error = new Error("senderID and threadID are required parameters");
18
- if (callback) callback(error);
19
- return Promise.reject(error);
20
- }
21
-
22
- const safeCallback = function(err, data) {
23
- if (callback && typeof callback === 'function') {
24
- callback(err, data);
25
- }
26
- if (err) {
27
- rejectFunc(err);
28
- } else {
29
- resolveFunc(data);
30
- }
31
- };
32
-
33
- try {
34
- if (!ctx.mqttClient) {
35
- throw new Error("MQTT client not initialized");
36
- }
37
-
38
- const reqID = ++ctx.req_ID;
39
- const messageData = {
40
- app_id: "2220391788200892",
41
- payload: JSON.stringify({
42
- tasks: [{
43
- label: 359,
44
- payload: JSON.stringify({
45
- contact_id: senderID,
46
- sync_group: 1,
47
- text: text || "",
48
- thread_id: threadID
49
- }),
50
- queue_name: 'xma_open_contact_share',
51
- task_id: Math.floor(Math.random() * 1001),
52
- failure_count: null,
53
- }],
54
- epoch_id: require('../utils').generateOfflineThreadingID(),
55
- version_id: '7214102258676893',
56
- }),
57
- request_id: reqID,
58
- type: 3
59
- };
60
-
61
- if (!ctx.callback_Task) {
62
- ctx.callback_Task = {};
63
- }
64
- ctx.callback_Task[reqID] = {
65
- callback: safeCallback,
66
- type: "shareContact"
67
- };
68
-
69
- ctx.mqttClient.publish('/ls_req', JSON.stringify(messageData), {
70
- qos: 1,
71
- retain: false
72
- });
73
-
74
- } catch (err) {
75
- safeCallback(err);
76
- }
77
-
78
- return returnPromise;
79
- };
80
- };
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function shareContact(text, senderID, threadID, callback) {
8
+ var resolveFunc = function () { };
9
+ var rejectFunc = function () { };
10
+
11
+ var returnPromise = new Promise(function (resolve, reject) {
12
+ resolveFunc = resolve;
13
+ rejectFunc = reject;
14
+ });
15
+
16
+ if (!callback || utils.getType(callback) != "Function" && utils.getType(callback) != "AsyncFunction") {
17
+ callback = function (err, data) {
18
+ if (err) return rejectFunc(err);
19
+ resolveFunc(data);
20
+ };
21
+ }
22
+ ctx.mqttClient.publish('/ls_req',
23
+ JSON.stringify({
24
+ app_id: "2220391788200892",
25
+ payload: JSON.stringify({
26
+ tasks: [{
27
+ label: 359,
28
+ payload: JSON.stringify({
29
+ "contact_id": senderID,
30
+ "sync_group": 1,
31
+ "text": text || "",
32
+ "thread_id": threadID
33
+ }),
34
+ queue_name: 'xma_open_contact_share',
35
+ task_id: Math.random() * 1001 << 0,
36
+ failure_count: null,
37
+ }],
38
+ epoch_id: utils.generateOfflineThreadingID(),
39
+ version_id: '7214102258676893',
40
+ }),
41
+ request_id: ++ctx.req_ID,
42
+ type: 3
43
+ }),
44
+ {
45
+ qos: 1,
46
+ retain: false,
47
+ }
48
+ );
49
+ ctx.callback_Task[ctx.req_ID] = new Object({
50
+ callback,
51
+ type: "shareContact"
52
+ });
53
+ return returnPromise;
54
+ };
55
+ };
@@ -1,142 +1,48 @@
1
1
  "use strict";
2
2
 
3
+ const Balancer = require('../Extra/Balancer.js');
3
4
  var utils = require("../utils");
4
5
  var log = require("npmlog");
5
6
 
6
- module.exports = function(defaultFuncs, api, ctx) {
7
- /**
8
- * Unsends (deletes) a message by message ID.
9
- * @param {string} messageID Message ID to unsend.
10
- * @param {Function} callback Called when the message is unsent.
11
- */
12
- return async function unsendMessage(messageID, callback) {
13
- var resolveFunc = function(){};
14
- var rejectFunc = function(){};
15
- var returnPromise = new Promise(function(resolve, reject) {
7
+ module.exports = function (defaultFuncs, api, ctx) {
8
+ //const BalancerInstance = new Balancer(api.unsendMessage, unsendMessage, 0.85);
9
+
10
+ function unsendMessage(messageID, threadID, callback) {
11
+ var resolveFunc = function () { };
12
+ var rejectFunc = function () { };
13
+ var returnPromise = new Promise(function (resolve, reject) {
16
14
  resolveFunc = resolve;
17
15
  rejectFunc = reject;
18
16
  });
19
-
17
+
20
18
  if (!callback) {
21
- callback = function(err) {
19
+ callback = function (err, friendList) {
22
20
  if (err) return rejectFunc(err);
23
- resolveFunc();
21
+ resolveFunc(friendList);
24
22
  };
25
23
  }
26
24
 
27
- // Các phương thức unsend khác nhau
28
- const unsendMethods = {
29
- // Phương thức 1: GraphQL API (phương thức chính)
30
- async graphql() {
31
- try {
32
- const form = {
33
- message_id: messageID,
34
- client_mutation_id: messageID
35
- };
36
-
37
- const res = await defaultFuncs
38
- .post("https://www.facebook.com/messaging/unsend_message/", ctx.jar, form)
39
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs));
40
-
41
- if (res.error) throw res;
42
- return true;
43
- } catch (error) {
44
- log.error("Failed to unsend using GraphQL:", error);
45
- return false;
46
- }
47
- },
48
-
49
- // Phương thức 2: Messenger API
50
- async messenger() {
51
- try {
52
- const form = {
53
- message_id: messageID,
54
- source: "source:messenger:web"
55
- };
56
-
57
- const res = await defaultFuncs
58
- .post("https://www.messenger.com/messaging/unsend_message/", ctx.jar, form)
59
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs));
60
-
61
- if (res.error) throw res;
62
- return true;
63
- } catch (error) {
64
- log.error("Failed to unsend using Messenger:", error);
65
- return false;
66
- }
67
- },
68
-
69
- // Phương thức 3: Legacy API
70
- async legacy() {
71
- try {
72
- const form = {
73
- message_id: messageID,
74
- action_type: "unsend_message",
75
- is_async: true
76
- };
77
-
78
- const res = await defaultFuncs
79
- .post("https://www.facebook.com/ajax/mercury/delete_messages.php", ctx.jar, form)
80
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs));
81
-
82
- if (res.error) throw res;
83
- return true;
84
- } catch (error) {
85
- log.error("Failed to unsend using Legacy:", error);
86
- return false;
87
- }
88
- },
89
-
90
- // Phương thức 4: Mobile API
91
- async mobile() {
92
- try {
93
- const form = {
94
- message_id: messageID
95
- };
96
-
97
- const res = await defaultFuncs
98
- .post("https://m.facebook.com/messages/unsend_message/", ctx.jar, form)
99
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs));
100
-
101
- if (res.error) throw res;
102
- return true;
103
- } catch (error) {
104
- log.error("Failed to unsend using Mobile:", error);
105
- return false;
106
- }
107
- }
108
- };
109
-
110
- // Thử từng phương thức theo thứ tự cho đến khi thành công
111
- try {
112
- // Thử phương thức chính (GraphQL) trước
113
- if (await unsendMethods.graphql()) {
114
- return callback();
115
- }
116
-
117
- // Nếu thất bại, thử Messenger API
118
- if (await unsendMethods.messenger()) {
119
- return callback();
120
- }
121
-
122
- // Nếu thất bại, thử Legacy API
123
- if (await unsendMethods.legacy()) {
124
- return callback();
125
- }
126
-
127
- // Cuối cùng thử Mobile API
128
- if (await unsendMethods.mobile()) {
129
- return callback();
130
- }
131
-
132
- // Nếu tất cả đều thất bại
133
- throw {error: "Không thể gỡ tin nhắn bằng bất kỳ phương thức nào"};
134
-
135
- } catch (err) {
136
- log.error("unsendMessage", err);
137
- return callback(err);
25
+ if (threadID) return api.unsendMqttMessage(threadID, messageID, callback);
26
+ else {
27
+ var form = {
28
+ message_id: messageID
29
+ };
30
+
31
+ defaultFuncs
32
+ .post("https://www.facebook.com/messaging/unsend_message/", ctx.jar, form)
33
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
34
+ .then(function (resData) {
35
+ if (resData.error) throw resData;
36
+ return callback();
37
+ })
38
+ .catch(function (err) {
39
+ log.error("unsendMessage", err);
40
+ return callback(err);
41
+ });
42
+
43
+ return returnPromise;
138
44
  }
45
+ }
139
46
 
140
- return returnPromise;
141
- };
47
+ return unsendMessage;
142
48
  };
@@ -0,0 +1,66 @@
1
+ /* eslint-disable linebreak-style */
2
+ "use strict";
3
+
4
+ var utils = require("../utils");
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function(threadID, messageID ,callback) {
8
+ var resolveFunc = function () { };
9
+ var rejectFunc = function () { };
10
+
11
+ var returnPromise = new Promise(function (resolve, reject) {
12
+ resolveFunc = resolve;
13
+ rejectFunc = reject;
14
+ });
15
+
16
+ if (!callback && utils.getType(messageID) === "AsyncFunction" || !callback && utils.getType(messageID) === "Function") messageID = callback;
17
+
18
+ if (!callback) {
19
+ callback = function (err, data) {
20
+ if (err) return rejectFunc(err);
21
+ resolveFunc(data);
22
+ };
23
+ }
24
+
25
+ const Payload = {
26
+ message_id:messageID,
27
+ thread_key:threadID,
28
+ sync_group: 1
29
+ };
30
+
31
+ if (messageID != undefined || messageID != null) Payload.reply_metadata = {
32
+ reply_source_id: messageID,
33
+ reply_source_type: 1,
34
+ reply_type: 0
35
+ };
36
+
37
+ const Form = JSON.stringify({
38
+ app_id: "2220391788200892",
39
+ payload: JSON.stringify({
40
+ tasks: [{
41
+ label: 33,
42
+ payload: JSON.stringify(Payload),
43
+ queue_name: "unsend_message",
44
+ task_id: Math.random() * 1001 << 0,
45
+ failure_count: null,
46
+ }],
47
+ epoch_id: utils.generateOfflineThreadingID(),
48
+ version_id: '9094446350588544',
49
+
50
+ }),
51
+ request_id: ++ctx.req_ID,
52
+ type: 3
53
+ });
54
+
55
+ ctx.mqttClient.publish('/ls_req', Form,{
56
+ qos: 1,
57
+ retain: false,
58
+ });
59
+ ctx.callback_Task[ctx.req_ID] = new Object({
60
+ callback,
61
+ type: "unsendMqttMessage",
62
+ });
63
+
64
+ return returnPromise;
65
+ };
66
+ };
@@ -0,0 +1,146 @@
1
+ module.exports = {
2
+ "delta": {
3
+ "attachments": [
4
+ {
5
+ "fbid": "1522004821162174",
6
+ "id": "1522004821162174",
7
+ "mercury": {
8
+ "app_attribution": null,
9
+ "attach_type": "share",
10
+ "name": null,
11
+ "url": null,
12
+ "rel": null,
13
+ "preview_url": null,
14
+ "preview_width": null,
15
+ "preview_height": null,
16
+ "large_preview_url": null,
17
+ "large_preview_width": null,
18
+ "large_preview_height": null,
19
+ "icon_type": null,
20
+ "metadata": null,
21
+ "thumbnail_url": null,
22
+ "share": {
23
+ "description": null,
24
+ "media": {
25
+ "animated_image": null,
26
+ "animated_image_size": {
27
+ "height": null,
28
+ "width": null
29
+ },
30
+ "image": null,
31
+ "image_size": {
32
+ "height": null,
33
+ "width": null
34
+ },
35
+ "duration": null,
36
+ "playable": null,
37
+ "source": null
38
+ },
39
+ "source": "Dimon - testing",
40
+ "style_list": [
41
+ "business_message_items", "fallback"
42
+ ],
43
+ "title": "search engines",
44
+ "properties": null,
45
+ "uri": null,
46
+ "subattachments": [],
47
+ "deduplication_key": "abcde",
48
+ "action_links": [],
49
+ "share_id": "1522004821162174",
50
+ "target": {
51
+ "call_to_actions": [],
52
+ "items": [
53
+ {
54
+ "id": "629934437209008",
55
+ "name": "search engines",
56
+ "desc": "",
57
+ "thumb_url": null,
58
+ "item_url": null,
59
+ "title": "search engines",
60
+ "text": "",
61
+ "source": null,
62
+ "metalines": {
63
+ "metaline_1": "click to get redirected",
64
+ "metaline_2": null,
65
+ "metaline_3": null
66
+ },
67
+ "location": 12314,
68
+ "category": 69,
69
+ "call_to_actions": [
70
+ {
71
+ "action_link": "http://l.facebook.com/l.php?u=http%3A%2F%2Fgoogle.com%2F&h=ATNziCq_-6I3ZPYwwLluFdCrWMEwLLKvokFlXdEdS4LD2Lzsv2cR2SJYffJcDYBfB092Xeq8oRdftJk4husEYVduH24RnlP3HvVQOkOrciXDs2M7TkWYyNLBelvJ2Fc-mw8pbGy5NslGf_fkZ_A",
72
+ "action_type": 2,
73
+ "id": "FFD=",
74
+ "title": "Google",
75
+ "link_target_ids": [629934437209008],
76
+ "is_mutable_by_server": false,
77
+ "should_show_user_confirmation": false,
78
+ "confirmation_title": null,
79
+ "confirmation_message": null,
80
+ "confirmation_continue_label": null,
81
+ "confirmation_cancel_label": null,
82
+ "payment_metadata": {
83
+ "total_price": null,
84
+ "payment_module_config": null
85
+ },
86
+ "is_disabled": false
87
+ }, {
88
+ "action_link": "http://l.facebook.com/l.php?u=http%3A%2F%2Fyahoo.com%2F&h=ATNIuTf7iDGP5xXTWOAdhaGhRFfDf4eS09t_G9CrR0MDiBKpqtCDzPf_9y5Bq7TXMgmo6RttztsgeO0ReSc0PDvJDTa1fLMMK2CjrpkqC91_m-yaMXfeQ4aI6MbhZrOPnK3YFnQP4XvRx3N1udE",
89
+ "action_type": 2,
90
+ "id": "CDE=",
91
+ "title": "Yahoo",
92
+ "link_target_ids": [629934437209008],
93
+ "is_mutable_by_server": false,
94
+ "should_show_user_confirmation": false,
95
+ "confirmation_title": null,
96
+ "confirmation_message": null,
97
+ "confirmation_continue_label": null,
98
+ "confirmation_cancel_label": null,
99
+ "payment_metadata": {
100
+ "total_price": null,
101
+ "payment_module_config": null
102
+ },
103
+ "is_disabled": false
104
+ }, {
105
+ "action_link": "http://l.facebook.com/l.php?u=http%3A%2F%2Fbing.com%2F&h=ATMoMijAt6Da6WWIQ679DhZyZizWdxAViWwyl-RjKobFUG_x8GmB8LD6pPa3KP5K1-QTL9vuaFwjqB0itaMFWk4VwQ9uh56JgnbFnAo4qM_CrQufgLeHwwCnWSCnZt8IzYT4y6YULLLFA5bL1H4",
106
+ "action_type": 2,
107
+ "id": "ABC=",
108
+ "title": "Bing",
109
+ "link_target_ids": [629934437209008],
110
+ "is_mutable_by_server": false,
111
+ "should_show_user_confirmation": false,
112
+ "confirmation_title": null,
113
+ "confirmation_message": null,
114
+ "confirmation_continue_label": null,
115
+ "confirmation_cancel_label": null,
116
+ "payment_metadata": {
117
+ "total_price": null,
118
+ "payment_module_config": null
119
+ },
120
+ "is_disabled": false
121
+ }
122
+ ]
123
+ }
124
+ ],
125
+ "location": 132145,
126
+ "category": 69,
127
+ "message": "Aaa: search engines"
128
+ }
129
+ }
130
+ },
131
+ "otherUserFbIds": ["1521994257829897"],
132
+ "titanType": 1
133
+ }
134
+ ],
135
+ "messageMetadata": {
136
+ "actorFbId": "1345",
137
+ "messageId": "mid.12345:asdv",
138
+ "offlineThreadingId": "1345v1345",
139
+ "tags": ["source:messenger:commerce"],
140
+ "threadKey": {
141
+ "otherUserFbId": "13451345"
142
+ },
143
+ "timestamp": "1487078180265"
144
+ }
145
+ }
146
+ }
Binary file
Binary file
@@ -0,0 +1,7 @@
1
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut placerat risus massa, eu rutrum massa tempus id. Aenean aliquet turpis at risus gravida, id scelerisque sem vestibulum. Aliquam erat volutpat. Pellentesque ut justo a sapien fringilla tincidunt ornare ac arcu. Nam non finibus turpis, eget tincidunt turpis. Morbi sed tempus leo. Aliquam ut nunc sed ante efficitur tristique et sed eros.
2
+
3
+ In eu tincidunt libero, eget tincidunt mauris. Donec ultrices placerat tincidunt. Sed ultrices neque dui, id viverra ante porta sed. Suspendisse tincidunt malesuada finibus. Ut cursus dolor sem, eu mattis lectus euismod a. In porttitor maximus lacus, eget volutpat mauris pretium at. Nulla consequat ipsum id enim fermentum feugiat. Fusce convallis bibendum massa ac viverra.
4
+
5
+ Sed a vehicula diam, et sollicitudin nunc. Quisque nec libero sit amet nibh fringilla pretium at vel massa. In enim dolor, euismod sed sapien id, accumsan tempus lacus. Aenean dapibus nulla at libero ultricies, id sagittis erat pretium. Nam iaculis tellus est, lobortis lacinia dui egestas vitae. Phasellus elementum quis lectus nec tincidunt. Ut gravida vestibulum ipsum ut cursus.
6
+
7
+ Mauris quam est, dignissim sed quam at, vulputate scelerisque purus. Maecenas tortor turpis, venenatis non purus et, finibus venenatis augue. Etiam et fringilla enim. Suspendisse a leo sed ex aliquet feugiat vitae nec magna. Vestibulum id massa in orci dictum ultricies. Vestibulum vitae leo sed lacus tempor dapibus. Cras viverra lorem sit amet magna imperdiet sodales. In sollicitudin ex sed feugiat commodo. Maecenas ac arcu tristique quam euismod ultrices quis et mi. Nulla lacinia sit amet lacus nec ultrices. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In hac habitasse platea dictumst. Curabitur vehicula, enim at vulputate bibendum, lorem tortor pellentesque massa, nec aliquam lacus mi ac libero. In vel nibh in ante facilisis tristique. Aliquam sapien purus, lobortis quis ultricies nec, dictum a turpis. Aenean pharetra congue lacus, id cursus erat fringilla congue.
@@ -0,0 +1,18 @@
1
+ // Instructions: Copy this file to test-config.json, fill in your test data
2
+ // and remove all comments (JSON doesn't support comments).
3
+ // Run the test with `npm test` after installing the devDependencies (mocha).
4
+ {
5
+ // Test user login information
6
+ "user" : {
7
+ "id" : "00000000000000",
8
+ "email" : "example@test.com",
9
+ "password" : "qwerty"
10
+ },
11
+ // Array of at least 2 other user IDs (not the same as the test user)
12
+ "userIDs" : [
13
+ "11111111111111",
14
+ "22222222222222"
15
+ ],
16
+ // Id of page to which test user is an admin
17
+ "pageID": "3333333333333"
18
+ }