B
B
Baga2021-05-30 16:16:07
Python
Baga, 2021-05-30 16:16:07

How to prevent the bot from stopping?

Code example:

@bot.message_handler(commands=["uid"])
def userid(message):
        chat_id = message.chat.id
        message_id = message.message_id
        bot.send_message(chat_id=chat_id, parse_mode='html', text=f'<code>\n{message.reply_to_message.from_user.id}</code>', reply_to_message_id=message_id)


If a person does not respond to a message, but simply writes /uid to the chat, then the bot falls, how to prevent it from falling?

Here's the error I got:

AttributeError: 'NoneType' object has no attribute 'from_user'
Process finished with exit code 1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2021-05-30
@Baga12324

Check if this is the answer or not. If no answer, do nothing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question