'How to send scheduled message using telebot python

In telegram client you can send a scheduled message and select a time at which it will be sent. Is there a way to do that using python Telebot library and not keep the script running and checking time manually?



Solution 1:[1]

You could use modules like apscheduler

example usage:

import telebot
from apscheduler.schedulers.blocking import BlockingScheduler

sched = BlockingScheduler()
bot = telebot.TeleBot(token)

def my_interval_job():
    bot.send_message("someusernameorid", "Hello. its 6am!")
    

sched.add_job(my_interval_job, trigger="cron", hour=6)
sched.start()
...

The above example sends a message to user at 6 am.

Read More

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 WarnerStark