Give the code below:
def start(update, context):
context.bot.send_message(chat_id=update.effective_chat.id, text="I'm a bot, please talk to me!")
Is it possible to call this function periodically and make my bot send the message to the user automatically instead of the user typing “/start”
2
Answers
Maybe this answer helps with your question. Secondly what I can recommend you is to have a look at Flask and Node-RED. From this tutorial, I think you would understand how to create your structure easily.
you need to create a
job
object which is delivered bypython-telegram-bot
so to simply run the function
start
let’s say every minute you could use this approach:and if you wanted to run it every day at specific time you could use:
note that there’s no handlers to be added to the dispatcher.
and you probably should know that the
datetime.time
object uses the UTC time if not modified.for more information check Extensions – JobQueue here