Reputation: 29
I'm new in telegram bot building, the problem is, how is possible to send a message to the user if he does nothing for 12 hours, then send another one if he continues to do nothing? But if he clicks on the button in the message 4 for example, it skips message 5.
if call.data == 'GetLesson1':
bot.send_message(call.message.chat.id, mg.third_message, reply_markup=kb.check_exercise())
push_data.append(call.data)
if call.data == 'Exercise':
bot.send_message(call.message.chat.id, mg.sixth_message, reply_markup=kb.check_exercise())
time.sleep(54000)
if call.data is None:
bot.send_message(call.message.chat.id, mg.fourth_message, reply_markup=kb.check_exercise())
time.sleep(54000)
if call.data is None:
bot.send_message(call.message.chat.id, mg.fives_message, reply_markup=kb.check_exercise())
Upvotes: 1
Views: 942
Reputation: 6355
You need to read about JobQueue
that is available in python-telegram-bot.
Here is an example, how to send message in a minute:
def callback_minute(context: telegram.ext.CallbackContext):
context.bot.send_message(chat_id='@examplechannel',
text='One message every minute')
job_minute = j.run_repeating(callback_minute, interval=60, first=0)
Inside that callback you can have some check if user send anything from that time, or even remove this job completely when you get new message (so no checks needed).
job_minute.schedule_removal()
See more examples in documentation.
Upvotes: 1