@eryxenx/fca 1.1.2 → 1.1.3
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eryxenx/fca",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Facebook Chat API by EryXenX | Stable • Auto Re-login • Full E2EE Support — send messages, media, reactions & more in encrypted chats, hassle-free",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -59,7 +59,7 @@ module.exports = function (defaultFuncs, api, ctx, opts) {
|
|
|
59
59
|
(ctx.globalOptions.humanize && ctx.globalOptions.humanize.enabled !== false);
|
|
60
60
|
if (humanizeEnabled) {
|
|
61
61
|
try {
|
|
62
|
-
middleware.use("humanizer", createHumanizerMiddleware(ctx._humanizer, logger));
|
|
62
|
+
middleware.use("humanizer", createHumanizerMiddleware(ctx._humanizer, logger, api));
|
|
63
63
|
ctx._humanizerMiddlewareInstalled = true;
|
|
64
64
|
logger("Humanizer middleware installed (command anti-spam active)", "info");
|
|
65
65
|
} catch (e) {
|
package/src/utils/humanizer.js
CHANGED
|
@@ -166,11 +166,21 @@ function createCommandHumanizer(options) {
|
|
|
166
166
|
return new CommandHumanizer(options);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
function createHumanizerMiddleware(humanizer, logger) {
|
|
169
|
+
function createHumanizerMiddleware(humanizer, logger, api) {
|
|
170
170
|
const log = typeof logger === "function"
|
|
171
171
|
? (msg, level) => logger(msg, level || "info")
|
|
172
172
|
: () => {};
|
|
173
173
|
|
|
174
|
+
function typingWanted() {
|
|
175
|
+
try {
|
|
176
|
+
const GoatBot = typeof global !== "undefined" ? global.GoatBot : undefined;
|
|
177
|
+
if (GoatBot && GoatBot.config) return GoatBot.config.enableTypingIndicator === true;
|
|
178
|
+
return true;
|
|
179
|
+
} catch {
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
174
184
|
return function commandHumanizerMiddleware(event, next) {
|
|
175
185
|
if (!humanizer.isCommand(event)) { next(); return; }
|
|
176
186
|
|
|
@@ -186,7 +196,17 @@ function createHumanizerMiddleware(humanizer, logger) {
|
|
|
186
196
|
const delay = Math.max(0, decision.delayMs || 0);
|
|
187
197
|
if (delay <= 0) { next(); return; }
|
|
188
198
|
|
|
189
|
-
|
|
199
|
+
const canType = api && typeof api.sendTypingIndicator === "function" && event.threadID && typingWanted();
|
|
200
|
+
if (!canType) {
|
|
201
|
+
setTimeout(() => next(), delay);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
Promise.resolve(api.sendTypingIndicator(event.threadID, true)).catch(() => {});
|
|
206
|
+
setTimeout(() => {
|
|
207
|
+
Promise.resolve(api.sendTypingIndicator(event.threadID, false)).catch(() => {});
|
|
208
|
+
next();
|
|
209
|
+
}, delay);
|
|
190
210
|
};
|
|
191
211
|
}
|
|
192
212
|
|