stfca 1.0.23 → 1.0.24
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/package.json +1 -1
- package/src/OldMessage.js +2 -2
- package/src/sendMessage.js +2 -2
- package/src/sendTypingIndicator.js +45 -101
- package/src/sendTypingIndicatorV2.js +0 -45
package/package.json
CHANGED
package/src/OldMessage.js
CHANGED
|
@@ -316,10 +316,10 @@ module.exports = function (defaultFuncs, api, ctx) {
|
|
|
316
316
|
const typingDuration = Number(configSource.typingDuration || ctx.config?.typingDuration || 4000);
|
|
317
317
|
|
|
318
318
|
if (enableTypingIndicator) {
|
|
319
|
-
api.
|
|
319
|
+
api.sendTypingIndicator(true, threadID, () => {});
|
|
320
320
|
const originalCallback = callback;
|
|
321
321
|
callback = (err, data) => {
|
|
322
|
-
api.
|
|
322
|
+
api.sendTypingIndicator(false, threadID, () => {});
|
|
323
323
|
originalCallback(err, data);
|
|
324
324
|
};
|
|
325
325
|
setTimeout(() => {
|
package/src/sendMessage.js
CHANGED
|
@@ -239,10 +239,10 @@ module.exports = (defaultFuncs, api, ctx) => {
|
|
|
239
239
|
const typingDuration = Number(configSource.typingDuration || ctx.config?.typingDuration || 4000);
|
|
240
240
|
|
|
241
241
|
if (enableTypingIndicator) {
|
|
242
|
-
await api.
|
|
242
|
+
await api.sendTypingIndicator(true, threadID, () => {});
|
|
243
243
|
await utils.delay(typingDuration);
|
|
244
244
|
const result = await sendContent(form, threadID, isSingleUser, messageAndOTID);
|
|
245
|
-
await api.
|
|
245
|
+
await api.sendTypingIndicator(false, threadID, () => {});
|
|
246
246
|
if (callback && typeof callback === "function") {
|
|
247
247
|
callback(null, result);
|
|
248
248
|
}
|
|
@@ -1,101 +1,45 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
defaultFuncs
|
|
47
|
-
.post(
|
|
48
|
-
"https://www.facebook.com/ajax/messaging/typ.php",
|
|
49
|
-
ctx.jar,
|
|
50
|
-
form,
|
|
51
|
-
)
|
|
52
|
-
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
|
53
|
-
.then(function (resData) {
|
|
54
|
-
if (resData.error) {
|
|
55
|
-
throw resData;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return callback();
|
|
59
|
-
})
|
|
60
|
-
.catch(function (err) {
|
|
61
|
-
console.error("sendTypingIndicator", err);
|
|
62
|
-
return callback(err);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return function sendTypingIndicator(threadID, callback, isGroup) {
|
|
69
|
-
if (
|
|
70
|
-
utils.getType(callback) !== "Function" &&
|
|
71
|
-
utils.getType(callback) !== "AsyncFunction"
|
|
72
|
-
) {
|
|
73
|
-
if (callback) {
|
|
74
|
-
console.warn(
|
|
75
|
-
"sendTypingIndicator",
|
|
76
|
-
"callback is not a function - ignoring.",
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
callback = () => {};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
makeTypingIndicator(true, threadID, callback, isGroup);
|
|
83
|
-
|
|
84
|
-
return function end(cb) {
|
|
85
|
-
if (
|
|
86
|
-
utils.getType(cb) !== "Function" &&
|
|
87
|
-
utils.getType(cb) !== "AsyncFunction"
|
|
88
|
-
) {
|
|
89
|
-
if (cb) {
|
|
90
|
-
console.warn(
|
|
91
|
-
"sendTypingIndicator",
|
|
92
|
-
"callback is not a function - ignoring.",
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
cb = () => {};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
makeTypingIndicator(false, threadID, cb, isGroup);
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var utils = require("../utils");
|
|
6
|
+
// @NethWs3Dev
|
|
7
|
+
|
|
8
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
|
9
|
+
return async function sendTypingIndicatorV2(sendTyping, threadID, callback) {
|
|
10
|
+
const mqttClient = ctx.mqttClient || global.mqttClient;
|
|
11
|
+
if (!mqttClient) {
|
|
12
|
+
if (typeof callback === 'function') callback(new Error('No MQTT client available for typing indicator'));
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let count_req = 0;
|
|
17
|
+
var wsContent = {
|
|
18
|
+
app_id: 2220391788200892,
|
|
19
|
+
payload: JSON.stringify({
|
|
20
|
+
label: 3,
|
|
21
|
+
payload: JSON.stringify({
|
|
22
|
+
thread_key: threadID.toString(),
|
|
23
|
+
is_group_thread: +(threadID.toString().length >= 16),
|
|
24
|
+
is_typing: +sendTyping,
|
|
25
|
+
attribution: 0
|
|
26
|
+
}),
|
|
27
|
+
version: 5849951561777440
|
|
28
|
+
}),
|
|
29
|
+
request_id: ++count_req,
|
|
30
|
+
type: 4
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
mqttClient.publish('/ls_req', JSON.stringify(wsContent), {}, (err, _packet) => {
|
|
35
|
+
if (err) {
|
|
36
|
+
if (typeof callback === 'function') callback(err);
|
|
37
|
+
reject(err);
|
|
38
|
+
} else {
|
|
39
|
+
if (typeof callback === 'function') callback(null, _packet);
|
|
40
|
+
resolve(_packet);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var utils = require("../utils");
|
|
6
|
-
// @NethWs3Dev
|
|
7
|
-
|
|
8
|
-
module.exports = function (defaultFuncs, api, ctx) {
|
|
9
|
-
return async function sendTypingIndicatorV2(sendTyping, threadID, callback) {
|
|
10
|
-
const mqttClient = ctx.mqttClient || global.mqttClient;
|
|
11
|
-
if (!mqttClient) {
|
|
12
|
-
if (typeof callback === 'function') callback(new Error('No MQTT client available for typing indicator'));
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
let count_req = 0;
|
|
17
|
-
var wsContent = {
|
|
18
|
-
app_id: 2220391788200892,
|
|
19
|
-
payload: JSON.stringify({
|
|
20
|
-
label: 3,
|
|
21
|
-
payload: JSON.stringify({
|
|
22
|
-
thread_key: threadID.toString(),
|
|
23
|
-
is_group_thread: +(threadID.toString().length >= 16),
|
|
24
|
-
is_typing: +sendTyping,
|
|
25
|
-
attribution: 0
|
|
26
|
-
}),
|
|
27
|
-
version: 5849951561777440
|
|
28
|
-
}),
|
|
29
|
-
request_id: ++count_req,
|
|
30
|
-
type: 4
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
mqttClient.publish('/ls_req', JSON.stringify(wsContent), {}, (err, _packet) => {
|
|
35
|
-
if (err) {
|
|
36
|
-
if (typeof callback === 'function') callback(err);
|
|
37
|
-
reject(err);
|
|
38
|
-
} else {
|
|
39
|
-
if (typeof callback === 'function') callback(null, _packet);
|
|
40
|
-
resolve(_packet);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
};
|