61 lines
2.0 KiB
JavaScript
61 lines
2.0 KiB
JavaScript
// Teste específico para debug do comando "ver sinal"
|
|
const BotHandler = require('./src/bot/handler');
|
|
|
|
// Mock do bot do Telegram
|
|
const mockBot = {
|
|
sendMessage: async (chatId, message, options) => {
|
|
console.log(`📤 MENSAGEM ENVIADA para chat ${chatId}:`);
|
|
console.log(` Texto: ${message}`);
|
|
if (options) {
|
|
console.log(` Opções: ${JSON.stringify(options, null, 2)}`);
|
|
}
|
|
console.log('');
|
|
return { message_id: Date.now() };
|
|
}
|
|
};
|
|
|
|
async function testVerSinal() {
|
|
console.log('🧪 Testando comando "ver sinal" diretamente...\n');
|
|
|
|
// Criar handler
|
|
const handler = new BotHandler(mockBot);
|
|
|
|
// Testar método handleVerSinal diretamente
|
|
console.log('🎯 Teste 1: Chamando handleVerSinal diretamente');
|
|
console.log(' Serial: DACM91569513');
|
|
console.log(' ChatId: 123456789\n');
|
|
|
|
try {
|
|
await handler.handleVerSinal(123456789, 'DACM91569513');
|
|
console.log('✅ Método handleVerSinal executado sem erros');
|
|
} catch (error) {
|
|
console.error('❌ Erro no handleVerSinal:', error);
|
|
}
|
|
|
|
console.log('\n🧠 Teste 2: Testando processamento NLP');
|
|
const intent = handler.nlp.processMessage('ver sinal DACM91569513');
|
|
console.log(' Intent detectado:', intent);
|
|
|
|
console.log('\n⚙️ Teste 3: Testando executeAction');
|
|
const mockUser = { first_name: 'Teste', id: 123456789 };
|
|
|
|
try {
|
|
await handler.executeAction(123456789, intent, mockUser);
|
|
console.log('✅ executeAction executado sem erros');
|
|
} catch (error) {
|
|
console.error('❌ Erro no executeAction:', error);
|
|
}
|
|
|
|
console.log('\n📋 Teste 4: Verificando OLTs disponíveis');
|
|
const olts = handler.ssh.listOLTs();
|
|
console.log(` OLTs encontradas: ${olts.length}`);
|
|
olts.forEach(olt => {
|
|
console.log(` - ${olt.id}: ${olt.name} (${olt.host})`);
|
|
});
|
|
|
|
console.log('\n✅ Teste de debug concluído!');
|
|
}
|
|
|
|
// Executar teste
|
|
testVerSinal().catch(console.error);
|