Answer the question
In order to leave comments, you need to log in
Error AttributeError: 'NoneType' object has no attribute 'from_user', how to fix?
If we write !hug without replying to the message, then I get an error
File "/home/ganymede1/main.py", line 1734, in get_text_messages
bot.send_message(message.chat.id, ~f'@{message.from_user. username} Embraced @{message.reply_to_message.from_user.username}')
AttributeError: 'NoneType' object has no attribute 'from_user'
and if the message is answered then everything is fine, how to fix it? What if you write !hug without replying to the message then nothing happens
if message.text.lower() == '!hug':
bot.send_message(message.chat.id, ~f'@{message.from_user.username} Hugs @{message.reply_to_message.from_user.username}')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question