- Added hunt/feed duck mechanics (80% hunt, 20% feed) - Implemented persistent scoring system - Added channel control commands (\!stopducks/\!startducks) - Enhanced duck hunt with wrong action penalties - Organized bot structure with botmain.js as main file - Added comprehensive documentation (README.md) - Included 17 plugins with various games and utilities 🦆 Duck Hunt Features: - Hunt ducks with \!shoot/\!bang (80% of spawns) - Feed ducks with \!feed (20% of spawns) - Persistent scores saved to JSON - Channel-specific controls for #bakedbeans - Reaction time tracking and special achievements 🎮 Other Games: - Casino games (slots, coinflip, hi-lo, scratch cards) - Multiplayer games (pigs, zombie dice, quiplash) - Text generation (babble, conspiracy, drunk historian) - Interactive features (story writing, emojify, combos) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
215 lines
No EOL
8.5 KiB
JavaScript
215 lines
No EOL
8.5 KiB
JavaScript
// plugins/markov_debug.js - Debug version to diagnose SQLite issues
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
module.exports = {
|
|
init(bot) {
|
|
console.log('🔍 Markov Debug Plugin Starting...');
|
|
this.bot = bot;
|
|
|
|
// Test 1: Check if plugins directory exists and is writable
|
|
this.testPluginsDirectory();
|
|
|
|
// Test 2: Try to load SQLite3
|
|
this.testSQLite3();
|
|
|
|
// Test 3: Try to create a simple database
|
|
this.testDatabaseCreation();
|
|
},
|
|
|
|
cleanup(bot) {
|
|
console.log('🔍 Markov Debug Plugin cleaned up');
|
|
if (this.db) {
|
|
this.db.close();
|
|
}
|
|
},
|
|
|
|
testPluginsDirectory() {
|
|
const pluginsDir = __dirname;
|
|
console.log(`📁 Plugins directory: ${pluginsDir}`);
|
|
|
|
try {
|
|
// Check if directory exists
|
|
if (fs.existsSync(pluginsDir)) {
|
|
console.log('✅ Plugins directory exists');
|
|
|
|
// Test write permissions
|
|
const testFile = path.join(pluginsDir, 'test_write.tmp');
|
|
fs.writeFileSync(testFile, 'test');
|
|
fs.unlinkSync(testFile);
|
|
console.log('✅ Plugins directory is writable');
|
|
} else {
|
|
console.log('❌ Plugins directory does not exist');
|
|
}
|
|
} catch (error) {
|
|
console.log('❌ Plugins directory permission error:', error.message);
|
|
}
|
|
},
|
|
|
|
testSQLite3() {
|
|
console.log('🔍 Testing SQLite3 installation...');
|
|
|
|
try {
|
|
const sqlite3 = require('sqlite3');
|
|
console.log('✅ SQLite3 module loaded successfully');
|
|
console.log('📦 SQLite3 version:', sqlite3.VERSION);
|
|
this.sqlite3 = sqlite3.verbose();
|
|
} catch (error) {
|
|
console.log('❌ SQLite3 loading failed:', error.message);
|
|
console.log('💡 Try: npm install sqlite3 --build-from-source');
|
|
this.sqlite3 = null;
|
|
}
|
|
},
|
|
|
|
testDatabaseCreation() {
|
|
if (!this.sqlite3) {
|
|
console.log('⏭️ Skipping database test - SQLite3 not available');
|
|
return;
|
|
}
|
|
|
|
console.log('🔍 Testing database creation...');
|
|
|
|
const dbPath = path.join(__dirname, 'test_markov.db');
|
|
console.log(`🗄️ Test database path: ${dbPath}`);
|
|
|
|
try {
|
|
this.db = new this.sqlite3.Database(dbPath, (err) => {
|
|
if (err) {
|
|
console.log('❌ Database creation failed:', err.message);
|
|
} else {
|
|
console.log('✅ Test database created successfully');
|
|
|
|
// Try to create a simple table
|
|
this.db.run('CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, text TEXT)', (err) => {
|
|
if (err) {
|
|
console.log('❌ Table creation failed:', err.message);
|
|
} else {
|
|
console.log('✅ Test table created successfully');
|
|
|
|
// Try to insert data
|
|
this.db.run('INSERT INTO test (text) VALUES (?)', ['test message'], (err) => {
|
|
if (err) {
|
|
console.log('❌ Insert failed:', err.message);
|
|
} else {
|
|
console.log('✅ Test insert successful');
|
|
|
|
// Try to read data
|
|
this.db.get('SELECT * FROM test', (err, row) => {
|
|
if (err) {
|
|
console.log('❌ Select failed:', err.message);
|
|
} else {
|
|
console.log('✅ Test select successful:', row);
|
|
console.log('🎉 SQLite3 is working correctly!');
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
} catch (error) {
|
|
console.log('❌ Database constructor failed:', error.message);
|
|
}
|
|
},
|
|
|
|
commands: [
|
|
{
|
|
name: 'debugmarkov',
|
|
description: 'Run diagnostic tests for Markov plugin',
|
|
execute: function(context, bot) {
|
|
const plugin = module.exports;
|
|
const target = context.replyTo;
|
|
const from = context.nick;
|
|
|
|
bot.say(target, `${from}: Running diagnostics...`);
|
|
|
|
// Re-run all tests
|
|
plugin.testPluginsDirectory();
|
|
plugin.testSQLite3();
|
|
plugin.testDatabaseCreation();
|
|
|
|
bot.say(target, `${from}: Check console for diagnostic results`);
|
|
}
|
|
},
|
|
|
|
{
|
|
name: 'checknpm',
|
|
description: 'Check Node.js and NPM environment',
|
|
execute: function(context, bot) {
|
|
const target = context.replyTo;
|
|
const from = context.nick;
|
|
|
|
const nodeVersion = process.version;
|
|
const platform = process.platform;
|
|
const arch = process.arch;
|
|
|
|
bot.say(target, `${from}: Node.js ${nodeVersion} on ${platform}-${arch}`);
|
|
|
|
// Check if we can see package.json
|
|
try {
|
|
const packagePath = path.join(process.cwd(), 'package.json');
|
|
if (fs.existsSync(packagePath)) {
|
|
const pkg = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
|
|
const hasSQLite = pkg.dependencies && pkg.dependencies.sqlite3;
|
|
bot.say(target, `${from}: sqlite3 in package.json: ${hasSQLite ? '✅' : '❌'}`);
|
|
} else {
|
|
bot.say(target, `${from}: No package.json found`);
|
|
}
|
|
} catch (error) {
|
|
bot.say(target, `${from}: Error checking package.json: ${error.message}`);
|
|
}
|
|
}
|
|
},
|
|
|
|
{
|
|
name: 'testwrite',
|
|
description: 'Test file writing in plugins directory',
|
|
execute: function(context, bot) {
|
|
const target = context.replyTo;
|
|
const from = context.nick;
|
|
|
|
try {
|
|
const testPath = path.join(__dirname, 'write_test.txt');
|
|
const testData = `Test file created at ${new Date().toISOString()}`;
|
|
|
|
fs.writeFileSync(testPath, testData);
|
|
|
|
// Verify it was written
|
|
const readData = fs.readFileSync(testPath, 'utf8');
|
|
|
|
// Clean up
|
|
fs.unlinkSync(testPath);
|
|
|
|
bot.say(target, `${from}: ✅ File write test successful`);
|
|
} catch (error) {
|
|
bot.say(target, `${from}: ❌ File write test failed: ${error.message}`);
|
|
}
|
|
}
|
|
},
|
|
|
|
{
|
|
name: 'listsqlite',
|
|
description: 'List any existing SQLite database files',
|
|
execute: function(context, bot) {
|
|
const target = context.replyTo;
|
|
const from = context.nick;
|
|
|
|
try {
|
|
const files = fs.readdirSync(__dirname);
|
|
const dbFiles = files.filter(f => f.endsWith('.db') || f.endsWith('.sqlite') || f.endsWith('.sqlite3'));
|
|
|
|
if (dbFiles.length > 0) {
|
|
bot.say(target, `${from}: Found databases: ${dbFiles.join(', ')}`);
|
|
} else {
|
|
bot.say(target, `${from}: No database files found in plugins directory`);
|
|
}
|
|
|
|
bot.say(target, `${from}: All files: ${files.join(', ')}`);
|
|
} catch (error) {
|
|
bot.say(target, `${from}: Error listing files: ${error.message}`);
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}; |