xmd-baileys 1.0.12 → 1.0.13

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 (2) hide show
  1. package/lib/index.js +17 -2
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -2,11 +2,26 @@
2
2
 
3
3
  const chalk = require("chalk");
4
4
 
5
- const _ol = console.log, _ow = console.warn, _oi = console.info;
6
- const _sf = (m) => typeof m === 'string' && (m.includes('Closing') || m.includes('Session') || m.includes('Bad MAC') || m.includes('decrypt')) || (typeof m === 'object' && m?._chains);
5
+ const _ol = console.log, _ow = console.warn, _oi = console.info, _oe = console.error;
6
+ let _rc = 0, _lt = 0;
7
+ const _sf = (m) => {
8
+ if (typeof m === 'object' && m?._chains) return true;
9
+ if (typeof m !== 'string') return false;
10
+ if (m.includes('Bad MAC') || m.includes('SESSION_CIPHER_FAIL') || m.includes('No valid sessions')) {
11
+ _rc++;
12
+ const now = Date.now();
13
+ if (now - _lt > 30000 && _rc > 0) {
14
+ _ol.call(console, chalk.yellow(`[XMD] `) + chalk.gray(`Session auto-repair: ${_rc} key(s) refreshed`));
15
+ _rc = 0; _lt = now;
16
+ }
17
+ return true;
18
+ }
19
+ return m.includes('Closing') || m.includes('SessionEntry') || m.includes('decrypt') && m.includes('fail');
20
+ };
7
21
  console.log = (...a) => { if (!_sf(a[0])) _ol.apply(console, a); };
8
22
  console.warn = (...a) => { if (!_sf(a[0])) _ow.apply(console, a); };
9
23
  console.info = (...a) => { if (!_sf(a[0])) _oi.apply(console, a); };
24
+ console.error = (...a) => { if (!_sf(a[0])) _oe.apply(console, a); };
10
25
 
11
26
  console.log(chalk.whiteBright("\n• WELCOME TO BWM XMD WORLD"));
12
27
  console.log(chalk.cyan("• Creator : ") + chalk.greenBright(" Mr Ibrahim Adams"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmd-baileys",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "A lightweight, full-featured WhatsApp Web API library for Node.js",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",