大家下午好!TG 机器人中有一个按钮,一个人点击它,时间应该开始倒计时,set_support 函数应该每 10 分钟调用一次,依此类推,直到我再次按下按钮。我已经玩过 Sleep 和 asyncio。我还没找到解决办法,请帮忙!我用艾图。有一个按钮:
support = KeyboardButton('Помощь')
我按下它,计时器应该启动,并且该功能应该每 10 分钟运行一次:
def set_support(active_collector):
date = datetime.date.today()
title = 'Помощь'
order_number = '-'
sql_select_query = """SELECT Support FROM settings"""
cursor.execute(sql_select_query)
order_volume = cursor.fetchone()[0] # обьём
coef = '0'
data = (date, active_collector, title, order_number, order_volume, coef)
cursor.executemany(
"""INSERT INTO archive(Date,name,title,order_number,order_volume,coef) VALUES (?, ?, ?, ?, ?,?)""", (data,))
conn.commit()
print('Добавлено!')
当我再次按下按钮时,这个过程应该停止。