J
J
jshaha2019-08-21 21:07:56
Bots
jshaha, 2019-08-21 21:07:56

How to view messages that were sent to the bot in telegram?

Created a bot.
And I would like to view the messages coming to the bot.
How can they be viewed?
Unfortunately I have not figured out the API yet, please help.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey S., 2019-08-21
@Winsik

remember all read messages, as you remember, move the counter of read messages to the last one, after that you can’t read the old one

S
Sergey, 2019-08-21
@greenglaz

I was not wise, I installed it on the basis of longman / telegram-bot, deployed the necessary databases and now everything is written in DB.

D
Danil K., 2019-08-28
@Danya_Violet

you can simply log to a file, like this:

def log(message):
    print("<!------!>")
    print(datetime.now())
    print("Сообщение от {0} {1} (id = {2}) \n {3}".format(message.from_user.first_name,
                                                              message.from_user.last_name,
                                                              str(message.from_user.id), message.text))

@bot.message_handler(commands=['create'])
def cmd_create(message):
    send = bot.send_message(message.chat.id, 'Введи название задачи')
    bot.register_next_step_handler(send, create)
    log(message)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question