snell
snell

Reputation: 39

Sending message every 15 minutes in python-telegram-bot

I need to make my telegram bot, send django model object to chat every 15 minutes.

Any builtins functions in python-telegram-bot to send message every 15 minutes?

Upvotes: 0

Views: 1454

Answers (1)

wowkin2
wowkin2

Reputation: 6355

You can use run_repeating() method for that:

def callback_foo(callback_context):
   pass  # send message here


def scheduling_method(context_or_dispatcher):
    # context or dispatcher, depending on what you have available
    job_queue = context_or_dispatcher.job_queue  
    job_queue.run_repeating(
        callback=callback_foo, interval=60 * 15,
    )

This can help to do any periodic calls for your Telegram Bot. There are even shortcuts to run methods you need on daily or monthly basis.

Upvotes: 1

Related Questions