Check if field is None

A slight change, still not very good though. Something like `{!s}{!s}{!s}.format(....)` seems a better aproach
This commit is contained in:
Kondra007 2015-09-03 18:06:54 +03:00
parent 4526c4f8a7
commit b1e659da28
1 changed files with 2 additions and 2 deletions

View File

@ -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))