Alexainc commited on
Commit ·
da9604c
1
Parent(s): 2bb34d7
add bot debug logging and fallback logic
Browse files- server/bot.js +15 -9
server/bot.js
CHANGED
|
@@ -8,6 +8,7 @@ bot.start(async (ctx) => {
|
|
| 8 |
const payload = ctx.startPayload;
|
| 9 |
const isGroup = ctx.chat.type === 'group' || ctx.chat.type === 'supergroup';
|
| 10 |
const botUser = ctx.botInfo.username;
|
|
|
|
| 11 |
|
| 12 |
if (isGroup) {
|
| 13 |
const rawPayload = `${ctx.chat.id}|${ctx.chat.title}`;
|
|
@@ -23,21 +24,26 @@ bot.start(async (ctx) => {
|
|
| 23 |
if (payload) {
|
| 24 |
try {
|
| 25 |
const decoded = Buffer.from(payload.replace(/-/g, '+').replace(/_/g, '/'), 'base64').toString();
|
| 26 |
-
|
| 27 |
-
const
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
} catch (e) {
|
| 34 |
console.error('Payload error:', e);
|
| 35 |
}
|
| 36 |
}
|
| 37 |
|
|
|
|
| 38 |
return ctx.replyWithMarkdown(
|
| 39 |
-
`🏮 **Welcome to the Aurudu Festival!** 🏮\n\nJoin a village group
|
| 40 |
-
Markup.inlineKeyboard([[Markup.button.webApp('🏮 ENTER BATTLE GROUND', APP_URL)]])
|
| 41 |
);
|
| 42 |
});
|
| 43 |
|
|
|
|
| 8 |
const payload = ctx.startPayload;
|
| 9 |
const isGroup = ctx.chat.type === 'group' || ctx.chat.type === 'supergroup';
|
| 10 |
const botUser = ctx.botInfo.username;
|
| 11 |
+
console.log(`[Bot Start] Chat: ${ctx.chat.id} (${ctx.chat.type}), Payload: ${payload}`);
|
| 12 |
|
| 13 |
if (isGroup) {
|
| 14 |
const rawPayload = `${ctx.chat.id}|${ctx.chat.title}`;
|
|
|
|
| 24 |
if (payload) {
|
| 25 |
try {
|
| 26 |
const decoded = Buffer.from(payload.replace(/-/g, '+').replace(/_/g, '/'), 'base64').toString();
|
| 27 |
+
console.log("[Payload Decoded]", decoded);
|
| 28 |
+
const parts = decoded.split('|');
|
| 29 |
+
if (parts.length >= 2) {
|
| 30 |
+
const [vId, vName] = parts;
|
| 31 |
+
const finalUrl = `${APP_URL}?vId=${vId}&vName=${encodeURIComponent(vName)}&uName=${encodeURIComponent(ctx.from.first_name)}`;
|
| 32 |
+
|
| 33 |
+
return ctx.replyWithMarkdown(
|
| 34 |
+
`🏺 **Invitation to ${vName}**\n\nYou've been invited to join the festival as a hero for **${vName}**. Are you ready to battle?`,
|
| 35 |
+
Markup.inlineKeyboard([[Markup.button.webApp(`🏮 JOIN VILLAGE ${vName.toUpperCase()}`, finalUrl)]])
|
| 36 |
+
);
|
| 37 |
+
}
|
| 38 |
} catch (e) {
|
| 39 |
console.error('Payload error:', e);
|
| 40 |
}
|
| 41 |
}
|
| 42 |
|
| 43 |
+
// Default Fallback
|
| 44 |
return ctx.replyWithMarkdown(
|
| 45 |
+
`🏮 **Welcome to the Aurudu Festival!** 🏮\n\nJoin a village group and click their **JOIN** button to compete for your community, or practice solo right now!`,
|
| 46 |
+
Markup.inlineKeyboard([[Markup.button.webApp('🏮 ENTER BATTLE GROUND (SOLO)', APP_URL)]])
|
| 47 |
);
|
| 48 |
});
|
| 49 |
|