upd
This commit is contained in:
55
messages.py
55
messages.py
@ -38,6 +38,20 @@ def get_theme_emoji(theme: str) -> str:
|
||||
"""Get emoji for the given theme."""
|
||||
return THEME_EMOJIS.get(theme, "🎉") # Default emoji
|
||||
|
||||
# Birthday greeting opening phrases (random variations)
|
||||
BIRTHDAY_GREETINGS = [
|
||||
"С днем рождения",
|
||||
"Поздравляю с днем рождения",
|
||||
"С твоим днем рождения",
|
||||
"Поздравляю тебя с днем рождения",
|
||||
"Поздравляю с днем рождения",
|
||||
]
|
||||
|
||||
|
||||
def get_birthday_greeting_opening() -> str:
|
||||
"""Get a random birthday greeting opening phrase."""
|
||||
return random.choice(BIRTHDAY_GREETINGS)
|
||||
|
||||
# Birthday messages for each theme
|
||||
BIRTHDAY_MESSAGES = {
|
||||
"Автомобили": [
|
||||
@ -132,8 +146,43 @@ def get_birthday_message(theme: str) -> str:
|
||||
return random.choice(messages)
|
||||
|
||||
|
||||
def format_birthday_greeting(first_name: str, theme: str) -> str:
|
||||
"""Format a complete birthday greeting with emoji."""
|
||||
def format_birthday_greeting(first_name: str, theme: str, user_id: int) -> str:
|
||||
"""Format a complete birthday greeting with emoji and user link."""
|
||||
emoji = get_theme_emoji(theme)
|
||||
greeting_opening = get_birthday_greeting_opening()
|
||||
message = get_birthday_message(theme)
|
||||
return f"{emoji} С днем рождения {first_name}, {message}"
|
||||
# Format: party popper + theme emoji + greeting + bold name with link
|
||||
user_link = f"tg://user?id={user_id}"
|
||||
return f"🎉 {greeting_opening}, <a href=\"{user_link}\">{emoji} <b>{first_name}</b></a>, {message}"
|
||||
|
||||
|
||||
def format_multiple_birthdays_greetings(users_data: list[tuple[str, str, int]]) -> str:
|
||||
"""Format greetings for multiple users celebrating birthday today.
|
||||
|
||||
Args:
|
||||
users_data: List of tuples (first_name, theme, user_id)
|
||||
|
||||
Returns:
|
||||
Formatted message with all greetings
|
||||
"""
|
||||
count = len(users_data)
|
||||
# Determine correct form of "человек"
|
||||
if count == 1:
|
||||
person_word = "человек"
|
||||
elif count in [2, 3, 4]:
|
||||
person_word = "человека"
|
||||
else:
|
||||
person_word = "человек"
|
||||
|
||||
header = f"🎉 Сегодня день рождения отмечают {count} {person_word}:\n\n"
|
||||
|
||||
greetings = []
|
||||
for first_name, theme, user_id in users_data:
|
||||
emoji = get_theme_emoji(theme)
|
||||
greeting_opening = get_birthday_greeting_opening()
|
||||
message = get_birthday_message(theme)
|
||||
user_link = f"tg://user?id={user_id}"
|
||||
greeting = f"<a href=\"{user_link}\">{emoji} <b>{first_name}</b></a> — {greeting_opening.lower()}, {message}"
|
||||
greetings.append(greeting)
|
||||
|
||||
return header + "\n\n".join(greetings)
|
||||
|
||||
Reference in New Issue
Block a user