C
C
Cheabatto2021-04-05 14:27:42
Python
Cheabatto, 2021-04-05 14:27:42

How to save user messages in a bot to a separate file?

I use the Telebot library
Question. How to save user messages in a separate file? All messages must be saved.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yupiter7575, 2021-04-05
@Cheabatto

@bot.message_handler(content_types=['text'])
def get_text_messages(message):
    f=open('db.txt', 'a')
    f.write(message.text)
    f.close

C
Chispy, 2021-04-05
@Chispy

It is possible in SQLite, etc.
Example.

def logs(message):
    with open("logs.txt", "w") as w:
        w.write(тут дальше сам придумай)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question