feat(telegram): improve group handling and default display name to @username

- /lottosettings now opens settings in private DM instead of group
- Bot only reacts to / commands in groups (keyboard buttons ignored)
- Reply keyboard buttons removed from group messages
- Default display name now uses @username instead of 'Anon'
- Users can still manually update display name in settings
- Updated all display name usages to use centralized getDisplayName()
This commit is contained in:
Michilis
2025-12-12 15:28:05 +00:00
parent 959268e7c1
commit 00f09236a3
8 changed files with 164 additions and 111 deletions

View File

@@ -35,7 +35,7 @@ export async function handleSettingsCommand(
// Ensure notifications object exists
const notifications = user.notifications || { ...DEFAULT_NOTIFICATIONS };
const displayName = user.displayName || 'Anon';
const displayName = stateManager.getDisplayName(user);
await bot.sendMessage(
chatId,
@@ -83,13 +83,14 @@ export async function handleSettingsCallback(
});
// Update message
const displayName = stateManager.getDisplayName(updatedUser);
await bot.editMessageText(
messages.settings.overview(updatedUser.displayName || 'Anon', updatedUser.notifications),
messages.settings.overview(displayName, updatedUser.notifications),
{
chat_id: chatId,
message_id: messageId,
parse_mode: 'Markdown',
reply_markup: getSettingsKeyboard(updatedUser.displayName || 'Anon', updatedUser.notifications),
reply_markup: getSettingsKeyboard(displayName, updatedUser.notifications),
}
);
}
@@ -145,8 +146,8 @@ export async function handleDisplayNameInput(
return;
}
// Clean the display name
const cleanName = text.replace(/[^\w\s\-_.]/g, '').trim() || 'Anon';
// Clean the display name (allow @ for usernames)
const cleanName = text.replace(/[^\w\s\-_.@]/g, '').trim() || 'Anon';
await stateManager.updateDisplayName(userId, cleanName);
logUserAction(userId, 'Set display name', { displayName: cleanName });