Answer the question
In order to leave comments, you need to log in
Is it possible to make a notification system in a telegram bot in Python, by time?
I want to teach the bot to send notifications to the user about his record regarding the time, but I don’t know how to do this and I can’t find anything on the Internet.
Library: pytelegrambotapi
If someone has experience please help!
Answer the question
In order to leave comments, you need to log in
To add days/hours/minutes to dates, you can use:
1. To add a date/time to the current value:
from datetime import timedelta, datetime, timezone
def minus_week():
offset = timezone(timedelta(hours=3)) # Московское время
now = datetime.now(offset) # Текущая дата
min_week = now + timedelta(7) # Плюс одна неделя (7 дней)
day = str(min_week.day) # Получение значения дня
month = str(min_week.month) # Получение месяца
if min_week.day < 10:
day = f'0{min_week.day}' #Чтобы день выводился было "09" а не "9"
if min_week.month < 10:
month = f'0{min_week.month}'
result = f'{month}-{day}'
return result # Возвращает время в виде "06-26"
# Функция для отправки сообщения с инфой
def send_stats():
def send_stat():
bot.send_message(chat_id, 'Мое сообщение')
schedule.every().day.at('23:55').do(send_stat)
while True:
schedule.run_pending()
time.sleep(5)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question