Answer the question
In order to leave comments, you need to log in
How to save the responses sent by the bot to the user on the local drive?
Good afternoon. I can't understand/understand/find in Google the answer to this question above.
I use telebot.
The goal is the following: the bot needs to write to the txt file on the local disk not only what the user writes, but also his answers to him.
message.text only returns messages sent by the user.
Maybe someone came across how to mark the messages sent by the bot?
@bot.message_handler(content_types=["text"])
def get_text_messages(message):
if message.text.lower() == "привет":
bot.send_message(message.from_user.id, "И тебе привет")
doc = open( '.txt', 'a')
doc.write("Сообщение от пользователя: {userone}\n".format(userone=message.text))
else:
bot.send_message(message.from_user.id, "Напиши привет")
doc = open( '.txt', 'a')
doc.write("Сообщение от пользователя: {userone}\n".format(userone=message.text))
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