@lazyneoaz/metachat 1.1.0 → 1.1.1

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": "@lazyneoaz/metachat",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "type": "commonjs",
5
5
  "types": "src/types/index.d.ts",
6
6
  "description": "Advanced Facebook Chat API client for building Messenger bots — real-time messaging, thread management, MQTT, and session stability.",
@@ -289,27 +289,6 @@ module.exports = (defaultFuncs, api, ctx) => {
289
289
  }
290
290
 
291
291
  try {
292
- await globalAntiSuspension.prepareBeforeMessage(String(Array.isArray(threadID) ? threadID[0] : threadID), msg.body || '');
293
-
294
- let typingStarted = false;
295
- let typingTimeout;
296
- const shouldSimulateTyping = ctx.globalOptions && ctx.globalOptions.simulateTyping && api.sendTypingIndicator && ctx.mqttClient && ctx.mqttClient.connected;
297
- if (shouldSimulateTyping) {
298
- try {
299
- await api.sendTypingIndicator(true, threadID);
300
- typingStarted = true;
301
- const msgLen = (msg.body || '').length;
302
- const typingMs = await globalAntiSuspension.simulateTyping(threadID, msgLen);
303
- await new Promise(resolve => setTimeout(resolve, typingMs));
304
- typingTimeout = setTimeout(() => {
305
- if (typingStarted) {
306
- try { api.sendTypingIndicator(false, threadID); } catch (_) {}
307
- typingStarted = false;
308
- }
309
- }, 10000);
310
- } catch (_) {}
311
- }
312
-
313
292
  try {
314
293
  const mqttReady = ctx.mqttClient && ctx.mqttClient.connected;
315
294
  const isMultiRecipient = Array.isArray(threadID);
@@ -87,8 +87,8 @@ class AntiSuspension {
87
87
  this.lastActivity = new Map();
88
88
  this.typing = new Map();
89
89
 
90
- this.messageDelayMs = 50;
91
- this.threadDelayMs = 50;
90
+ this.messageDelayMs = 0;
91
+ this.threadDelayMs = 0;
92
92
  this.loginAttempts = 0;
93
93
  this.maxLoginAttempts = 3;
94
94
  this.loginCooldown = 300000;
@@ -329,14 +329,14 @@ class AntiSuspension {
329
329
 
330
330
  async enforceThreadThrottling(threadID) {
331
331
  const lastTime = this.lastActivity.get(String(threadID)) || 0;
332
- const timeSinceLastMsg = Date.now() - lastTime;
333
- const minInterval = this.threadDelayMs + Math.random() * 10;
334
-
335
- if (timeSinceLastMsg < minInterval) {
336
- const waitTime = minInterval - timeSinceLastMsg;
337
- await new Promise(resolve => setTimeout(resolve, waitTime));
332
+ if (this.threadDelayMs > 0) {
333
+ const timeSinceLastMsg = Date.now() - lastTime;
334
+ const minInterval = this.threadDelayMs + Math.random() * 10;
335
+ if (timeSinceLastMsg < minInterval) {
336
+ const waitTime = minInterval - timeSinceLastMsg;
337
+ await new Promise(resolve => setTimeout(resolve, waitTime));
338
+ }
338
339
  }
339
-
340
340
  this.lastActivity.set(String(threadID), Date.now());
341
341
  return Date.now() - lastTime;
342
342
  }
@@ -482,8 +482,6 @@ class AntiSuspension {
482
482
  if (volumeWarning) {
483
483
  const { utils } = this._getUtils();
484
484
  utils && utils.warn && utils.warn("AntiSuspension", volumeWarning);
485
- // Add a safety pause instead of hard-blocking so callers can decide
486
- await new Promise(resolve => setTimeout(resolve, 5000 + Math.random() * 3000));
487
485
  }
488
486
 
489
487
  await this.enforceThreadThrottling(threadID);