I have written a telegram bot in python. In particular, I am working on this flow: "recheck2" has an inlinekeyboardbutton that links to "timer", and "timer" will wait for an hour before activating "recheck3". "recheck3" runs a database query and sends a message to the telegram user.
The purpose of the bot is to allow the user to have an option to re-run the same query after an hour (or any predefined duration).
I receive an error on the line "context.job_queue.run_once...." saying that "ValueError: The following arguments have not been supplied: context".
I've based on code on timerbot.py and inlinekeyboard2.py avail at https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/README.md.... I've scanned thru many forums and QnAs, but unable to find any solution. I'm trying to avoid using sleep() as it suspends/blocks the code. Also, I tried asyncio.sleep but it doesn't work with bots with CallbackQueryHandlers.
Could a kind soul please point me in the right direction please? Thanks!
def timer(update: Update,context: CallbackContext)-> None:
chat_id=CallbackContext.chat_id
due = int(3600) #to run recheck3 after one hour
****context.job_queue.run_once(recheck3, due, context=chat_id, name=str(chat_id))****
def recheck3(update: Update, context: CallbackContext) -> int:
"""Stores the info about the user and ends the conversation."""
#user = update.message.from_user
logger.info("%s: rechecked for %s with timed delay", CallbackContext.firstname, CallbackContext.tag)
update.callback_query.message.edit_text('Sure, will send you a message again in xxmins.')
connection = cx_Oracle.connect(dsn="XXXXXX") ## ,encoding="UTF-8"
cur = connection.cursor()
tag=CallbackContext.tag #recall the user input
cur.execute("SELECT * \
........ code truncated.....