E
E
ElebrUS2019-10-01 14:00:40
Python
ElebrUS, 2019-10-01 14:00:40

How to get telebot message array?

Hello, I am writing a bot using telebot and python3. I ran
into a problem, namely, a lack of understanding of python.
In general, let's say I write to the bot "Print"
and it saves all messages after "Print"
And after the message "Done" it sends all saved messages including "Print" to another user

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Bashinsky, 2019-10-01
@BashkaMen

What's the problem?
You need to keep the context in order to understand what you should be doing now.
A simple solution is a boolean flag.
We saw the word Print - set isWrite = true then
a message came, check the flag, if it is true write to the array, if false ....
Personally, I do not support this option, implement the state pattern instead of flags, polymorphism will help compress the context and you will work only with logic states. With flags, litter the code with the context definition.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question