Add 'Upcoming Jackpot' button to Telegram bot menu

Shows current prize pool, ticket price, draw time, and time remaining
This commit is contained in:
Michilis
2025-12-09 01:04:27 +00:00
parent 404fdf2610
commit fcd180b7a4
2 changed files with 28 additions and 0 deletions

View File

@@ -238,6 +238,33 @@ bot.on('message', async (msg) => {
// Handle menu button presses // Handle menu button presses
switch (text) { switch (text) {
case '🎰 Upcoming Jackpot':
try {
const jackpot = await apiClient.getNextJackpot();
if (!jackpot) {
await bot.sendMessage(msg.chat.id, messages.buy.noActiveJackpot, {
parse_mode: 'Markdown',
});
return;
}
const drawTime = new Date(jackpot.cycle.scheduled_at);
const jackpotMessage = `🎰 *Upcoming Jackpot*
💰 *Prize Pool:* ${formatSats(jackpot.cycle.pot_total_sats)} sats
🎟 *Ticket Price:* ${formatSats(jackpot.lottery.ticket_price_sats)} sats
⏰ *Draw at:* ${formatDate(drawTime)}
⏳ *Time left:* ${formatTimeUntil(drawTime)}
Use /buyticket to get your tickets! 🍀`;
await bot.sendMessage(msg.chat.id, jackpotMessage, { parse_mode: 'Markdown' });
} catch (error) {
logger.error('Error showing jackpot', { error });
await bot.sendMessage(msg.chat.id, messages.errors.systemUnavailable);
}
return;
case '🎟 Buy Tickets': case '🎟 Buy Tickets':
await handleBuyCommand(bot, msg); await handleBuyCommand(bot, msg);
return; return;

View File

@@ -10,6 +10,7 @@ import { NotificationPreferences } from '../types';
export function getMainMenuKeyboard(): ReplyKeyboardMarkup { export function getMainMenuKeyboard(): ReplyKeyboardMarkup {
return { return {
keyboard: [ keyboard: [
[{ text: '🎰 Upcoming Jackpot' }],
[{ text: '🎟 Buy Tickets' }, { text: '🧾 My Tickets' }], [{ text: '🎟 Buy Tickets' }, { text: '🧾 My Tickets' }],
[{ text: '🏆 My Wins' }, { text: '⚡ Lightning Address' }], [{ text: '🏆 My Wins' }, { text: '⚡ Lightning Address' }],
[{ text: '⚙️ Settings' }, { text: ' Help' }], [{ text: '⚙️ Settings' }, { text: ' Help' }],