From b1e659da283e964d6a6b76bd61adb73c3c055d89 Mon Sep 17 00:00:00 2001 From: Kondra007 Date: Thu, 3 Sep 2015 18:06:54 +0300 Subject: [PATCH] Check if field is None A slight change, still not very good though. Something like `{!s}{!s}{!s}.format(....)` seems a better aproach --- examples/telebot_bot/telebot_bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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))