Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff9c1f1dcf |
@@ -223,17 +223,45 @@ bot.onText(/\/lottosettings/, async (msg) => {
|
||||
// TEXT MESSAGES
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
// Keyboard button texts that should trigger keyboard removal in groups
|
||||
const KEYBOARD_BUTTON_TEXTS = [
|
||||
'🎰 Upcoming Jackpot',
|
||||
'🎟 Buy Tickets',
|
||||
'🧾 My Tickets',
|
||||
'🏆 My Wins',
|
||||
'⚡ Lightning Address',
|
||||
'⚙️ Settings',
|
||||
'ℹ️ Help',
|
||||
];
|
||||
|
||||
// Handle keyboard button presses (text messages)
|
||||
bot.on('message', async (msg) => {
|
||||
if (!msg.text || msg.text.startsWith('/')) return;
|
||||
if (!shouldProcessMessage(msg.message_id)) return;
|
||||
|
||||
// Ignore group messages for button handling
|
||||
if (isGroupChat(msg)) return;
|
||||
|
||||
const text = msg.text.trim();
|
||||
const userId = msg.from?.id;
|
||||
|
||||
// Handle keyboard button presses in groups - remove the keyboard for that user
|
||||
if (isGroupChat(msg)) {
|
||||
// Only trigger if the message matches an exact keyboard button text
|
||||
if (KEYBOARD_BUTTON_TEXTS.includes(text)) {
|
||||
try {
|
||||
// Send a temporary message to remove the keyboard for this user only
|
||||
const sentMessage = await bot.sendMessage(msg.chat.id, '⚡', {
|
||||
reply_to_message_id: msg.message_id,
|
||||
reply_markup: { remove_keyboard: true, selective: true },
|
||||
});
|
||||
// Delete the message immediately so nothing is visible in the group
|
||||
await bot.deleteMessage(msg.chat.id, sentMessage.message_id);
|
||||
} catch (error) {
|
||||
// Silently fail - bot might not have delete permissions
|
||||
logger.error('Error removing keyboard in group', { error, chatId: msg.chat.id, userId });
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!userId) return;
|
||||
|
||||
// Handle menu button presses
|
||||
|
||||
Reference in New Issue
Block a user