1
0
Fork 0
mirror of https://github.com/EDeev/y.calendarkin.git synced 2026-10-07 16:37:50 +03:00
Telegram-бот уведомлений о событиях Яндекс.Календаря: сводка на день, напоминания, повторяющиеся события. aiogram 3, icalendar https://t.me/calendarkin_ybot
Find a file
Egor Deev 4055242ddf
Уведомления о новых, удалённых и перенесённых событиях (#5)
При обновлении календаря (раз в 13 минут) старая выгрузка сравнивается с новой по UID события.
Бот присылает одно сообщение со списком изменений: новое событие, удалено, перенесено (было/стало).
Учитываются и отдельные вхождения повторяющихся событий — перенос (RECURRENCE-ID) и удаление
(EXDATE). Прошедшие события пропускаются: Яндекс выгружает всю историю календаря. В сообщении —
не больше 10 изменений, остальные одной строкой «…и ещё N».

Команда /changes включает и выключает эти уведомления; по умолчанию включены у всех, колонка
alarms.changes добавляется при запуске. При подписке и замене ссылки сравнения нет.

Closes #2
2026-10-07 16:27:58 +03:00
.github/workflows Образы на git.deev.su вместо dcr.deev.su: реестр zot выведен из работы, копию из GHCR делает синхронизатор 2026-10-06 17:04:19 +03:00
code Уведомления о новых, удалённых и перенесённых событиях (#5) 2026-10-07 16:27:58 +03:00
data Исправлены ошибки и уязвимость, улучшены уведомления 2026-10-05 19:28:43 +00:00
scripts Хранилище — PostgreSQL вместо двух файлов SQLite 2026-10-06 11:46:39 +00:00
tests Уведомления о новых, удалённых и перенесённых событиях (#5) 2026-10-07 16:27:58 +03:00
.env.example Хранилище — PostgreSQL вместо двух файлов SQLite 2026-10-06 11:46:39 +00:00
.gitattributes Версия на aiogram 3 — та, что работает на сервере 2026-10-05 19:22:10 +00:00
.gitignore Хранилище — PostgreSQL вместо двух файлов SQLite 2026-10-06 11:46:39 +00:00
compose.yaml Хранилище — PostgreSQL вместо двух файлов SQLite 2026-10-06 11:46:39 +00:00
Dockerfile Хранилище — PostgreSQL вместо двух файлов SQLite 2026-10-06 11:46:39 +00:00
LICENSE Зависимости по рабочему окружению, тесты, CI, Docker и лицензия MIT 2026-10-05 19:28:43 +00:00
README.en.md Уведомления о новых, удалённых и перенесённых событиях (#5) 2026-10-07 16:27:58 +03:00
README.md Уведомления о новых, удалённых и перенесённых событиях (#5) 2026-10-07 16:27:58 +03:00
requirements-dev.txt Зависимости по рабочему окружению, тесты, CI, Docker и лицензия MIT 2026-10-05 19:28:43 +00:00
requirements.txt Хранилище — PostgreSQL вместо двух файлов SQLite 2026-10-06 11:46:39 +00:00

Y.Calendarkin

Русский · English

CI Docker License

A Telegram bot that sends notifications about Yandex Calendar events: a morning summary for the day, two reminders before an event and a message when it starts. All it needs is the calendar's export link. The bot speaks Russian.

Status: personal project, maintained · bot @calendarkin_ybot

Stack: Python 3.12 · aiogram 3 · aiohttp · icalendar · python-dateutil · pytz · PostgreSQL · Docker

Features

  • Subscription by iCal export link; the time zone is taken from the link
  • Recurring events (RRULE) are expanded for today
  • A day summary at 8:00 in the calendar's time zone (/daily)
  • Two reminders before an event: 15 and 5 minutes by default, changed with /edit_alarm
  • A message when an event starts (/moment)
  • A notification when an event is added, or an upcoming one is deleted or moved (/changes)
  • The calendar is refreshed every 13 minutes; if a refresh fails, the previous version stays

Commands

Command What it does
/link how to get the calendar link
/list today's events
/daily toggle the morning summary
/moment toggle the message at event start
/changes toggle notifications about added, deleted and moved events
/get_alarm, /edit_alarm view and change reminder times
/stop_alarm toggle the second reminder
/notif pause or resume all notifications
/unsubscribe remove the calendar subscription

Running

git clone https://github.com/EDeev/y.calendarkin.git && cd y.calendarkin
cp .env.example .env      # BOT_TOKEN from @BotFather
docker compose up -d

Prebuilt image: docker pull ghcr.io/edeev/y.calendarkin or docker pull git.deev.su/edeev/y.calendarkin. PostgreSQL tables are created on first start. Data from the old version (SQLite users.db and clock.db) is moved by python scripts/migrate_sqlite.py --sqlite-dir path/to/db --dsn postgresql://….

Without Docker: Python 3.10+, PostgreSQL, pip install -r requirements.txt, then cd code && BOT_TOKEN=… DATABASE_URL=postgresql://… python bot.py.

How it works

code/bot.py        entry point and two background loops: event checks every minute, calendar refresh
code/changes.py    compares the old and new download: added, deleted and moved events
code/handlers.py   commands and receiving the link
code/script.py     link validation, download, iCal and recurrence parsing, notification text
code/sql.py        users, subscriptions and reminder settings (PostgreSQL)
scripts/           migration from SQLite

Only https://calendar.yandex.* links are accepted, so the bot never downloads from arbitrary addresses. An error for one user (a broken calendar or a blocked bot) doesn't stop notifications for others.

Development

pip install -r requirements-dev.txt
ruff check --select E9,F code tests && pytest

The tests (storage on PostgreSQL from TEST_DATABASE_URL) cover calendar parsing: today's events, recurrences, UNTIL in different formats, link validation, the notification text and change detection between downloads. The Docker image is built on v* tags and published to GitHub Packages and git.deev.su.

License

MIT — see LICENSE.

Author

Egor Deev — GitHub · Telegram · egor@deev.space


⭐ If you find this project useful, give it a star on GitHub!

Made with ❤️ — deev.space