N
N
Nikolai Neizvestny2020-04-26 16:43:27
Python
Nikolai Neizvestny, 2020-04-26 16:43:27

Python telegram bot after button click, response time or cancel after timer expires?

Here is part of the code

if message.text == 'Оплата':
            bottons = 
            keyboard = ReplyKeyboardMarkup(bottons, resize_keyboard=True)
            bot.send_photo(message.chat.id,'путь к картинке', parse_mode='markdown', caption = texts.tov % (tovar, city, rayon, tovari, random.randint(1, 100000)), reply_markup=keyboard)

It is necessary that after the transition to payment in 10 minutes. the bot wrote to the chat ✖Cancel Order

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alekssamos, 2020-04-26
@NHide

I would do it via threading.Timer

import threading

def ordertimeout():
    pass ## в этой функции  отменяй, пиши, отправляй...

t = threading.Timer(60*10, ordertimeout) # 10 минут (или 600 секунд)
t.start() # время пошло!
t.cancel() # отмена, не будет запущен

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question