node-ainzfb-new 1.7.7-iu0tg78 → 1.7.10-11
Sign up to get free protection for your applications and to get access to all the features.
- package/DOCS.md +56 -25
- package/index.js +83 -41
- package/package.json +2 -2
- package/src/changeAvt.js +73 -73
- package/src/editMessage.js +84 -0
- package/src/getAccessToken.js +21 -21
- package/src/getThreadInfo.js +3423 -18
- package/src/getUserInfoV2.js +19 -22
- package/src/pinMessage.js +61 -0
- package/src/shareContact.js +56 -0
- package/src/shareLink.js +57 -0
- package/utils.js +1480 -1063
package/src/getUserInfoV2.js
CHANGED
@@ -4,32 +4,29 @@
|
|
4
4
|
var utils = require("../utils");
|
5
5
|
var log = require("npmlog");
|
6
6
|
|
7
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
8
|
+
return function getUserInfoV2(id, callback) {
|
9
|
+
var resolveFunc = function() {};
|
10
|
+
var rejectFunc = function() {};
|
11
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
12
|
+
resolveFunc = resolve;
|
13
|
+
rejectFunc = reject;
|
14
|
+
});
|
7
15
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
rejectFunc = reject;
|
15
|
-
});
|
16
|
-
|
17
|
-
if (!callback) {
|
18
|
-
callback = function (err, userInfo) {
|
19
|
-
if (err) return rejectFunc(err);
|
20
|
-
resolveFunc(userInfo);
|
21
|
-
};
|
22
|
-
}
|
16
|
+
if (!callback) {
|
17
|
+
callback = function(err, userInfo) {
|
18
|
+
if (err) return rejectFunc(err);
|
19
|
+
resolveFunc(userInfo);
|
20
|
+
};
|
21
|
+
}
|
23
22
|
try {
|
24
|
-
var { getInfo } = require(
|
25
|
-
getInfo(id)
|
26
|
-
.then(data => {
|
23
|
+
var { getInfo } = require("../Extra/ExtraAddons");
|
24
|
+
getInfo(id).then(data => {
|
27
25
|
return callback(null, data);
|
28
26
|
});
|
29
|
-
}
|
30
|
-
catch (e) {
|
27
|
+
} catch (e) {
|
31
28
|
return callback(null, e);
|
32
29
|
}
|
33
30
|
return returnPromise;
|
34
|
-
|
35
|
-
|
31
|
+
};
|
32
|
+
};
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const { generateOfflineThreadingID, getCurrentTimestamp } = require("../utils");
|
4
|
+
|
5
|
+
function isCallable(func) {
|
6
|
+
try {
|
7
|
+
Reflect.apply(func, null, []);
|
8
|
+
return true;
|
9
|
+
} catch (error) {
|
10
|
+
return false;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
15
|
+
return function pinMessage(pinMode, messageID, threadID, callback) {
|
16
|
+
if (!ctx.mqttClient) {
|
17
|
+
throw new Error("Not connected to MQTT");
|
18
|
+
}
|
19
|
+
|
20
|
+
ctx.wsReqNumber += 1;
|
21
|
+
ctx.wsTaskNumber += 1;
|
22
|
+
|
23
|
+
const taskLabel = pinMode ? "430" : "431";
|
24
|
+
const queueNamePrefix = pinMode ? "pin_msg_v2_" : "unpin_msg_v2_";
|
25
|
+
|
26
|
+
const taskPayload = {
|
27
|
+
thread_key: threadID,
|
28
|
+
message_id: messageID,
|
29
|
+
timestamp_ms: getCurrentTimestamp()
|
30
|
+
};
|
31
|
+
|
32
|
+
const task = {
|
33
|
+
failure_count: null,
|
34
|
+
label: taskLabel,
|
35
|
+
payload: JSON.stringify(taskPayload),
|
36
|
+
queue_name: `${queueNamePrefix}${threadID}`,
|
37
|
+
task_id: ctx.wsTaskNumber
|
38
|
+
};
|
39
|
+
|
40
|
+
const content = {
|
41
|
+
app_id: "2220391788200892",
|
42
|
+
payload: JSON.stringify({
|
43
|
+
data_trace_id: null,
|
44
|
+
epoch_id: parseInt(generateOfflineThreadingID()),
|
45
|
+
tasks: [task],
|
46
|
+
version_id: "25095469420099952"
|
47
|
+
}),
|
48
|
+
request_id: ctx.wsReqNumber,
|
49
|
+
type: 3
|
50
|
+
};
|
51
|
+
|
52
|
+
if (isCallable(callback)) {
|
53
|
+
// to be implemented
|
54
|
+
}
|
55
|
+
|
56
|
+
ctx.mqttClient.publish("/ls_req", JSON.stringify(content), {
|
57
|
+
qos: 1,
|
58
|
+
retain: false
|
59
|
+
});
|
60
|
+
};
|
61
|
+
};
|
@@ -0,0 +1,56 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
+
return async function shareContact(
|
8
|
+
text,
|
9
|
+
senderID,
|
10
|
+
threadID,
|
11
|
+
mentionID,
|
12
|
+
userID,
|
13
|
+
leaverID,
|
14
|
+
callback
|
15
|
+
) {
|
16
|
+
var resolveFunc = function() {};
|
17
|
+
var rejectFunc = function() {};
|
18
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
19
|
+
resolveFunc = resolve;
|
20
|
+
rejectFunc = reject;
|
21
|
+
});
|
22
|
+
if (!callback) {
|
23
|
+
callback = function(err, data) {
|
24
|
+
if (err) return rejectFunc(err);
|
25
|
+
resolveFunc(data);
|
26
|
+
};
|
27
|
+
}
|
28
|
+
let count_req = 0;
|
29
|
+
var form = JSON.stringify({
|
30
|
+
app_id: "2220391788200892",
|
31
|
+
payload: JSON.stringify({
|
32
|
+
tasks: [
|
33
|
+
{
|
34
|
+
label: "359",
|
35
|
+
payload: JSON.stringify({
|
36
|
+
contact_id: senderID,
|
37
|
+
sync_group: 1,
|
38
|
+
text: text || "",
|
39
|
+
thread_id: threadID
|
40
|
+
}),
|
41
|
+
queue_name: "messenger_contact_sharing",
|
42
|
+
task_id: (Math.random() * 1001) << 0,
|
43
|
+
failure_count: null
|
44
|
+
}
|
45
|
+
],
|
46
|
+
epoch_id: utils.generateOfflineThreadingID(),
|
47
|
+
version_id: "7214102258676893"
|
48
|
+
}),
|
49
|
+
request_id: ++count_req,
|
50
|
+
type: 3
|
51
|
+
});
|
52
|
+
ctx.mqttClient.publish("/ls_req", form);
|
53
|
+
|
54
|
+
return returnPromise;
|
55
|
+
};
|
56
|
+
};
|
package/src/shareLink.js
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
+
return async function shareLink(text, url, threadID, callback) {
|
8
|
+
var resolveFunc = function() {};
|
9
|
+
var rejectFunc = function() {};
|
10
|
+
var returnPromise = new Promise(function(resolve, reject) {
|
11
|
+
resolveFunc = resolve;
|
12
|
+
rejectFunc = reject;
|
13
|
+
});
|
14
|
+
if (!callback) {
|
15
|
+
callback = function(err, data) {
|
16
|
+
if (err) return rejectFunc(err);
|
17
|
+
resolveFunc(data);
|
18
|
+
};
|
19
|
+
}
|
20
|
+
ctx.mqttClient.publish(
|
21
|
+
"/ls_req",
|
22
|
+
JSON.stringify({
|
23
|
+
app_id: "2220391788200892",
|
24
|
+
payload: JSON.stringify({
|
25
|
+
tasks: [
|
26
|
+
{
|
27
|
+
label: 46,
|
28
|
+
payload: JSON.stringify({
|
29
|
+
otid: utils.generateOfflineThreadingID(),
|
30
|
+
source: 524289,
|
31
|
+
sync_group: 1,
|
32
|
+
send_type: 6,
|
33
|
+
mark_thread_read: 0,
|
34
|
+
url: url || "",
|
35
|
+
text: text || "",
|
36
|
+
thread_id: threadID,
|
37
|
+
initiating_source: 0
|
38
|
+
}),
|
39
|
+
queue_name: threadID,
|
40
|
+
task_id: (Math.random() * 1001) << 0,
|
41
|
+
failure_count: null
|
42
|
+
}
|
43
|
+
],
|
44
|
+
epoch_id: utils.generateOfflineThreadingID(),
|
45
|
+
version_id: "7191105584331330"
|
46
|
+
}),
|
47
|
+
request_id: ++ctx.req_ID,
|
48
|
+
type: 3
|
49
|
+
}),
|
50
|
+
{
|
51
|
+
qos: 1,
|
52
|
+
retain: false
|
53
|
+
}
|
54
|
+
);
|
55
|
+
return returnPromise;
|
56
|
+
};
|
57
|
+
};
|