logs
This commit is contained in:
34
.serena/memories/song_selection_issue_analysis.md
Normal file
34
.serena/memories/song_selection_issue_analysis.md
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Song Selection Issue Analysis
|
||||||
|
|
||||||
|
## Problem
|
||||||
|
- Production: Song selection says it will send to chat but doesn't actually send
|
||||||
|
- /start command works fine
|
||||||
|
- No errors in logs
|
||||||
|
|
||||||
|
## Code Flow Analysis
|
||||||
|
|
||||||
|
### Working /start Command (src/bot.ts:66-95)
|
||||||
|
1. User sends /start command
|
||||||
|
2. Bot receives via `this.bot.onText(/\/start/)`
|
||||||
|
3. Direct bot.sendMessage() call works
|
||||||
|
|
||||||
|
### Broken Song Selection Flow
|
||||||
|
1. User selects song in Web App (public/script.ts:248)
|
||||||
|
2. Web App calls `this.tg.sendData()` with JSON payload
|
||||||
|
3. Should trigger `web_app_data` event in bot (src/bot.ts:159)
|
||||||
|
4. Bot should call `sendAudioFile()` method (src/bot.ts:224)
|
||||||
|
|
||||||
|
## Key Differences
|
||||||
|
- /start: Direct Telegram command → immediate bot response
|
||||||
|
- Song selection: Web App → sendData() → web_app_data event → bot response
|
||||||
|
|
||||||
|
## Potential Issues
|
||||||
|
1. `this.tg.sendData()` might not be working in production environment
|
||||||
|
2. `web_app_data` event handler might not be triggered
|
||||||
|
3. Web App URL environment variable mismatch
|
||||||
|
4. Telegram Web App integration issues in production
|
||||||
|
|
||||||
|
## Next Steps
|
||||||
|
- Check production environment variables (WEB_APP_URL, TELEGRAM_BOT_TOKEN)
|
||||||
|
- Add logging to web_app_data handler
|
||||||
|
- Verify Telegram Web App configuration
|
||||||
@@ -245,11 +245,13 @@ class QuixoticApp {
|
|||||||
|
|
||||||
if (this.tg) {
|
if (this.tg) {
|
||||||
// Send to Telegram chat
|
// Send to Telegram chat
|
||||||
this.tg.sendData(JSON.stringify({
|
const payload = {
|
||||||
action: 'send_audio',
|
action: 'send_audio',
|
||||||
audioUrl: data.audioUrl,
|
audioUrl: data.audioUrl,
|
||||||
title: title
|
title: title
|
||||||
}));
|
};
|
||||||
|
console.log('📤 Sending data to Telegram:', payload);
|
||||||
|
this.tg.sendData(JSON.stringify(payload));
|
||||||
this.showMessage('✓ MP3 готов! Отправляем в чат...', 'success');
|
this.showMessage('✓ MP3 готов! Отправляем в чат...', 'success');
|
||||||
} else {
|
} else {
|
||||||
// For testing in browser - download file
|
// For testing in browser - download file
|
||||||
|
|||||||
10
src/bot.ts
10
src/bot.ts
@@ -157,15 +157,23 @@ export class QuixoticBot {
|
|||||||
|
|
||||||
// Handle web app data
|
// Handle web app data
|
||||||
this.bot.on('web_app_data', async (msg: Message) => {
|
this.bot.on('web_app_data', async (msg: Message) => {
|
||||||
|
console.log('🔍 Web app data received:', msg.web_app?.data);
|
||||||
const chatId = msg.chat.id;
|
const chatId = msg.chat.id;
|
||||||
|
|
||||||
if (!msg.web_app?.data) return;
|
if (!msg.web_app?.data) {
|
||||||
|
console.log('❌ No web app data found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const data: WebAppData = JSON.parse(msg.web_app.data);
|
const data: WebAppData = JSON.parse(msg.web_app.data);
|
||||||
|
console.log('📝 Parsed data:', data);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (data.action === 'send_audio') {
|
if (data.action === 'send_audio') {
|
||||||
|
console.log('🎵 Sending audio file:', data.title);
|
||||||
await this.sendAudioFile(chatId, data.audioUrl, data.title);
|
await this.sendAudioFile(chatId, data.audioUrl, data.title);
|
||||||
|
} else {
|
||||||
|
console.log('⚠️ Unknown action:', data.action);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Web app data error:', error);
|
console.error('Web app data error:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user