Answer the question
In order to leave comments, you need to log in
How to stop loop on click of inline button in aiogram?
I have 2 inline buttons. One starts the cycle, and the other must stop it.
bot.py
loop = StartLoop()
if call.data == 'start_loop':
loop.start()
elif call.data == 'stop_loop':
loop.stop()
loopbot.py
class StartLoop():
def __init__(self):
self.loopflag = True
def start(self):
while self.loopflag:
<do something>
def stop(self):
self.loopflag = False
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