The name comes out as none. Can someone please help
def funtion_example(update, context):
#name of the bot user
chat_user_client = update.message.from_user.username
update.message.reply_text(str(chat_user_client))
The name comes out as none. Can someone please help
def funtion_example(update, context):
#name of the bot user
chat_user_client = update.message.from_user.username
update.message.reply_text(str(chat_user_client))
2
Answers
If you look at the bot api docs you will see that only
first_name
,id
andis_bot
are not marked as Optional.Thus a number of users will not have a username, which you have to take into account and work around.
if you are retriving message from channel you can try
sender_chat
, in this you will have username of channels and real users, instead in thefrom_user
you will find username of real users and bot. So you need to choose which one use depending of the use-case.