bot/event/week_file.py
2026-08-30 13:48:59 +03:00

36 lines
1.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import telebot
from .__events__ import Event, Time, addEvent
from models.user import getAllUsers
from models.bot import bot
from utils.calendar import ICS
class CalendarFile(Event):
weekdays = [6]
time = [Time(21, 0)]
sleep = 60*61
@staticmethod
def execute() -> None:
for user in getAllUsers():
if 'week_file' not in user.notifications: continue
try: ics = ICS(user)
except ValueError: continue
path = ics.save()
bot.send_document(
user.id,
telebot.types.InputFile(path, f'Расписание.ics'),
caption='''\
<b>Расписание на следующую неделю файлом</b>
<blockquote><b>Как использовать файл?</b>
1. Загрузи файл <code>Расписание.ics</code> и открой его
2. Телефон предложит открыть календарь - согласись
3. В приложении календаря появятся новые события, найди кнопку "Добавить все", если это не произошло автоматически</blockquote>'''
)
addEvent(CalendarFile)