Skip to content

Commit

Permalink
Improve NEW_CHAT_MEMBERS handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Valery Vishnevskiy committed Apr 21, 2019
1 parent 45f43bc commit 00c0f2d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ async def command(message: Message):

@handlers(MessageType.NEW_CHAT_MEMBERS)
async def new_member(message: Message):
await message.bot.send_message("Приветствуем новичка! Шаурмы и донатов ему!)")
user = message.raw["message"]["new_chat_members"][0]
username = user.get("username")
name = " ".join([user[key] for key in ("first_name", "last_name") if key in user])
if username:
name = f"{name} (@{username})"
await message.bot.send_message(f"Приветствуем новичка {name}! Шаурмы и донатов ему!)")


@handlers(MessageType.TEXT, Contains("конструктор"))
Expand Down

0 comments on commit 00c0f2d

Please sign in to comment.