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?
Advertisement
Answer
You could use modules like apscheduler
example usage:
JavaScript
x
14
14
1
import telebot
2
from apscheduler.schedulers.blocking import BlockingScheduler
3
4
sched = BlockingScheduler()
5
bot = telebot.TeleBot('token')
6
7
def my_interval_job():
8
bot.send_message("WARNERSTARK", "Goodmorning. its 6am!")
9
# do more at 6 am
10
11
12
sched.add_job(my_interval_job, trigger="cron", hour=6)
13
sched.start()
14
The above example sends a message to user at 6 am.
Read More