diff --git a/examples/telebot_bot/telebot_bot.py b/examples/telebot_bot/telebot_bot.py index 7cf76cb..cd29276 100644 --- a/examples/telebot_bot/telebot_bot.py +++ b/examples/telebot_bot/telebot_bot.py @@ -42,10 +42,10 @@ def on_user_joins(message): return name = message.new_chat_participant.first_name - if hasattr(message.new_chat_participant, 'last_name'): + if hasattr(message.new_chat_participant, 'last_name') and message.new_chat_participant.last_name is not None: name += u" {}".format(message.new_chat_participant.last_name) - if hasattr(message.new_chat_participant, 'username'): + if hasattr(message.new_chat_participant, 'username') and message.new_chat_participant.username is not None: name += u" (@{})".format(message.new_chat_participant.username) bot.reply_to(message, text_messages['welcome'].format(name=name))