Push notify
  • Python 68.7%
  • Nix 31.3%
Find a file
Aleksandr be925b831a Autodiscover private repos the bot account belongs to
With autodiscover = true the bot polls /user/repos each tick and watches
every private repository where its account is a member (owner,
collaborator, org team) — granting the bot read access is enough, no
config edit needed. Public repos are never picked up automatically and
are watched only via explicit [[repos] ] entries, which also take
priority for branch overrides; exclude filters discovered repos.
Requires a Forgejo token. Discovery failure falls back to the last
successful list without stopping polling.

Co-Authored-By: Eva
2026-07-12 21:22:28 +03:00
gitbot Autodiscover private repos the bot account belongs to 2026-07-12 21:22:28 +03:00
nix Autodiscover private repos the bot account belongs to 2026-07-12 21:22:28 +03:00
.gitignore gitbot: Forgejo push notifier for Telegram 2026-07-12 21:14:18 +03:00
config.example.toml Autodiscover private repos the bot account belongs to 2026-07-12 21:22:28 +03:00
flake.lock gitbot: Forgejo push notifier for Telegram 2026-07-12 21:14:18 +03:00
flake.nix gitbot: Forgejo push notifier for Telegram 2026-07-12 21:14:18 +03:00
pyproject.toml gitbot: Forgejo push notifier for Telegram 2026-07-12 21:14:18 +03:00
README.md Autodiscover private repos the bot account belongs to 2026-07-12 21:22:28 +03:00

gitbot

Уведомления в Telegram-тред о пушах в основные ветки Forgejo-репозиториев.

Поллит Forgejo API по списку репозиториев из конфига; при смене head основной ветки шлёт в заданный чат/тред сообщение со списком новых коммитов и ссылкой на diff. Состояние (последний увиденный head) персистится в JSON, так что рестарт не дублирует уведомления.

Вместо явного списка можно включить autodiscover: бот следит за всеми приватными репозиториями, где состоит аккаунт его токена (владелец, коллаборатор, команда организации) — добавили бота читателем, репа под наблюдением. Публичные репы автоматически не подхватываются — их добавляют явными [[repos]] (членство бота для этого не нужно); явный список и autodiscover складываются.

Запуск

cp config.example.toml config.toml  # и отредактировать
nix run . -- --config config.toml

Секреты можно класть в файлы (token_file), в путях раскрываются переменные окружения ($CREDENTIALS_DIRECTORY под systemd). Для Bot API поддерживается прокси (telegram.proxy, socks5/http).

NixOS

{
  imports = [ inputs.gitbot.nixosModules.default ];

  services.gitbot = {
    enable = true;
    tokenFile = config.sops.secrets."gitbot_telegram_token".path;
    telegramProxy = "socks5://127.0.0.1:1080";
    chatId = -1001234567890;
    threadId = 42;

    # либо явный список…
    repos = [ "VienDesu/core" "VienDesu/frontend" ];
    # …либо всё, куда добавлен аккаунт бота:
    # autodiscover = true;
    # forgejoTokenFile = config.sops.secrets."gitbot_forgejo_token".path;
    # exclude = [ "VienDesu/plans" ];
  };
}