innovators-bot2 1.2.7 → 1.2.9

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/example.js CHANGED
@@ -91,6 +91,7 @@ async function start() {
91
91
  console.log('Is Removed:', reaction.isRemoved)
92
92
  console.log('Message ID:', reaction.messageKey.id)
93
93
  })
94
+
94
95
  client.on('call', (call) => {
95
96
  const callData = call[0]; // Get the first call object from the array
96
97
  if (callData.status !== 'offer') return;
@@ -110,6 +111,10 @@ async function start() {
110
111
  console.log('āŒ Client disconnected')
111
112
  })
112
113
 
114
+ client.on('group-left', (info) => {
115
+ console.log(`Left group ${info.id}: ${info.reason}`);
116
+ });
117
+
113
118
  // Connect to WhatsApp
114
119
  client.connect()
115
120
 
package/index.js CHANGED
@@ -491,7 +491,21 @@ class WhatsAppClient extends EventEmitter {
491
491
  const metadata = await this.sock.groupMetadata(update.id);
492
492
  this.updateGroupMetadataCache(update.id, metadata);
493
493
  } catch (error) {
494
- console.error(`Error refreshing metadata for group ${update.id}:`, error);
494
+ // Check if group no longer exists or bot was removed (404 item-not-found)
495
+ const isNotFound = error.data === 404 ||
496
+ error.message?.includes('item-not-found') ||
497
+ error.output?.statusCode === 404;
498
+
499
+ if (isNotFound) {
500
+ // Group no longer exists or bot was removed - clean up cache
501
+ this.clearGroupMetadataCache(update.id);
502
+ this.emit('group-left', {
503
+ id: update.id,
504
+ reason: 'Group not found or bot was removed'
505
+ });
506
+ } else {
507
+ console.error(`Error refreshing metadata for group ${update.id}:`, error);
508
+ }
495
509
  }
496
510
  });
497
511
 
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "innovators-bot2",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "start": "node example.js"
7
+ "start": "node example.js",
8
+ "publish": "node publish.js"
8
9
  },
9
10
  "keywords": [
10
11
  "whatsapp",
@@ -28,9 +29,8 @@
28
29
  },
29
30
  "homepage": "https://github.com/innovatorssoft/WhatsAppAPI?tab=readme-ov-file#whatsapp-api",
30
31
  "dependencies": {
31
- "@innovatorssoft/baileys": "^7.3.5",
32
+ "@innovatorssoft/baileys": "^7.4.0",
32
33
  "figlet": "^1.8.0",
33
- "link-preview-js": "^3.0.13",
34
34
  "mime": "^3.0.0",
35
35
  "mime-types": "^2.1.35",
36
36
  "node-cache": "^5.1.2",
package/publish.js ADDED
@@ -0,0 +1,40 @@
1
+ const { execSync } = require('child_process');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ const packagePath = path.join(__dirname, 'package.json');
6
+
7
+ // Read the original package.json
8
+ const originalPackage = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
9
+ const originalName = originalPackage.name;
10
+
11
+ console.log('šŸš€ Starting dual npm publish...\n');
12
+
13
+ try {
14
+ // Step 1: Publish as unscoped package (innovators-bot2)
15
+ console.log(`šŸ“¦ Publishing as "${originalName}"...`);
16
+ execSync('npm publish', { stdio: 'inherit', cwd: __dirname });
17
+ console.log(`āœ… Successfully published "${originalName}"\n`);
18
+
19
+ // Step 2: Change name to scoped package
20
+ const scopedName = '@innovatorssoft/innovators-bot2';
21
+ console.log(`šŸ“¦ Publishing as "${scopedName}"...`);
22
+
23
+ originalPackage.name = scopedName;
24
+ fs.writeFileSync(packagePath, JSON.stringify(originalPackage, null, 2) + '\n');
25
+
26
+ // Step 3: Publish as scoped package with public access
27
+ execSync('npm publish --access public', { stdio: 'inherit', cwd: __dirname });
28
+ console.log(`āœ… Successfully published "${scopedName}"\n`);
29
+
30
+ } catch (error) {
31
+ console.error('āŒ Error during publish:', error.message);
32
+ process.exitCode = 1;
33
+ } finally {
34
+ // Step 4: Always restore original package.json
35
+ console.log('šŸ”„ Restoring original package.json...');
36
+ originalPackage.name = originalName;
37
+ fs.writeFileSync(packagePath, JSON.stringify(originalPackage, null, 2) + '\n');
38
+ console.log('āœ… Original package.json restored');
39
+ console.log('\nšŸŽ‰ Dual publish complete!');
40
+ }