teto_ai/check_ready.js

195 lines
5 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { testVP8Implementation } from "./test_vp8.js";
import fs from "fs";
import path from "path";
async function checkBotReadiness() {
console.log("🤖 Discord Teto Bot - Readiness Check\n");
const checks = [];
// 1. Check VP8 Implementation
console.log("1⃣ Checking VP8 Implementation...");
try {
const vp8Ready = await testVP8Implementation();
checks.push({
name: "VP8 Implementation",
status: vp8Ready ? "✅ READY" : "❌ FAILED",
passed: vp8Ready
});
} catch (error) {
checks.push({
name: "VP8 Implementation",
status: "❌ ERROR",
passed: false,
error: error.message
});
}
// 2. Check Required Files
console.log("\n2⃣ Checking Required Files...");
const requiredFiles = [
"bot.js",
"src/services/webcamRecording.js",
"src/services/commandHandler.js",
"src/config/videoConfig.js",
"discord.js-selfbot-v13/src/util/Util.js",
"discord.js-selfbot-v13/src/client/voice/receiver/Recorder.js",
"discord.js-selfbot-v13/src/client/voice/receiver/PacketHandler.js"
];
let filesOk = true;
for (const file of requiredFiles) {
if (fs.existsSync(file)) {
console.log(`${file}`);
} else {
console.log(`${file} - MISSING`);
filesOk = false;
}
}
checks.push({
name: "Required Files",
status: filesOk ? "✅ READY" : "❌ MISSING FILES",
passed: filesOk
});
// 3. Check Output Directory
console.log("\n3⃣ Checking Output Directory...");
const outputDir = "/tmp/output";
try {
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true });
}
// Test write permissions
const testFile = path.join(outputDir, "test_write.tmp");
fs.writeFileSync(testFile, "test");
fs.unlinkSync(testFile);
console.log(`${outputDir} - writable`);
checks.push({
name: "Output Directory",
status: "✅ READY",
passed: true
});
} catch (error) {
console.log(`${outputDir} - ${error.message}`);
checks.push({
name: "Output Directory",
status: "❌ NOT WRITABLE",
passed: false,
error: error.message
});
}
// 4. Check Environment Variables
console.log("\n4⃣ Checking Environment Variables...");
const requiredEnvVars = ["USER_TOKEN"];
let envOk = true;
for (const envVar of requiredEnvVars) {
if (process.env[envVar]) {
console.log(`${envVar} - set`);
} else {
console.log(`${envVar} - missing`);
envOk = false;
}
}
checks.push({
name: "Environment Variables",
status: envOk ? "✅ READY" : "❌ MISSING VARS",
passed: envOk
});
// 5. Check FFmpeg Availability
console.log("\n5⃣ Checking FFmpeg...");
try {
const { spawn } = await import("child_process");
const ffmpeg = spawn("ffmpeg", ["-version"]);
await new Promise((resolve, reject) => {
ffmpeg.on("close", (code) => {
if (code === 0) {
console.log(" ✅ FFmpeg - available");
checks.push({
name: "FFmpeg",
status: "✅ READY",
passed: true
});
resolve();
} else {
console.log(" ❌ FFmpeg - not working");
checks.push({
name: "FFmpeg",
status: "❌ NOT WORKING",
passed: false
});
resolve();
}
});
ffmpeg.on("error", (error) => {
console.log(" ❌ FFmpeg - not found");
checks.push({
name: "FFmpeg",
status: "❌ NOT FOUND",
passed: false,
error: error.message
});
resolve();
});
});
} catch (error) {
checks.push({
name: "FFmpeg",
status: "❌ ERROR",
passed: false,
error: error.message
});
}
// Summary
console.log("\n" + "=".repeat(50));
console.log("📊 READINESS SUMMARY");
console.log("=".repeat(50));
let allPassed = true;
for (const check of checks) {
console.log(`${check.status.padEnd(20)} ${check.name}`);
if (check.error) {
console.log(` Error: ${check.error}`);
}
if (!check.passed) allPassed = false;
}
console.log("\n" + "=".repeat(50));
if (allPassed) {
console.log("🎉 BOT IS READY FOR WEBCAM RECORDING!");
console.log("\nNext steps:");
console.log("1. Start the bot: npm start");
console.log("2. Test VP8: 'test vp8' in Discord");
console.log("3. Record webcam: 'record webcam' in Discord");
} else {
console.log("⚠️ BOT NOT READY - Fix issues above first");
console.log("\nCommon fixes:");
console.log("- Set USER_TOKEN environment variable");
console.log("- Install FFmpeg in container");
console.log("- Fix file permissions");
}
return allPassed;
}
// Run check if called directly
if (import.meta.url === `file://${process.argv[1]}`) {
checkBotReadiness()
.then(ready => process.exit(ready ? 0 : 1))
.catch(error => {
console.error("❌ Readiness check failed:", error);
process.exit(1);
});
}
export { checkBotReadiness };