How draxkiller/uninotif-v2 works
1. Overall shape
- This repo is a single-script notification pipeline run on a GitHub Actions scheduler, not a hosted service.
- The core executable is scraper.py; the other JSON files are persistent state that the script updates and commits back to the repo.
2. Execution environment
- The workflow in .github/workflows/notify.yml runs every 5 minutes on a GitHub Actions runner.
- The runner is ephemeral, so persistence is achieved by reading and writing files in the repository and pushing them back with GitHub write permissions.
3. Primary data source
- The bot monitors Pondicherry University notifications using the WordPress REST API as the preferred source.
- If the API is unavailable, it falls back to HTML scraping of the notifications page.
- The source content appears to be organized by 7 notification categories, which the bot scans for new posts.
4. Notification detection flow
- scraper.py fetches the current set of notifications, normalizes each entry into a stable identifier, and compares it against seen.json.
- Anything not already recorded in seen.json is treated as a new notification and processed for delivery.
5. Deduplication and seeding
- seen.json is the main idempotency boundary: it prevents resend across runs, including after a crash.
- On the first run, the bot seeds seen.json with the existing notifications and does not send alerts.
- The README indicates entries older than 180 days are pruned automatically, while baseline seeded entries are retained.
6. Message delivery boundary
- New notifications are sent to Telegram using a bot token and one or more chat IDs from secrets.
- The first chat ID is special: it receives admin-only messages such as errors and the daily heartbeat.
- Additional chat IDs receive notification broadcasts only.
7. Attachment handling
- The bot attempts to fetch the notification’s PDF attachment and include it in the Telegram message.
- If PDF download fails, or if the file is too large for Telegram’s limit, it falls back to sending text plus the notification link.
- The README notes the bot only attaches the PDF associated with the notification content area, avoiding unrelated site PDFs.
8. Optional AI summarization subsystem
- If GEMINI_API_KEY is configured and AI summaries are enabled, the bot sends notification text through Google Gemini Flash for a short summary.
- pdfplumber is used to extract text from PDFs when summarization needs document content.
- This is an optional side path; the bot still functions without it.
9. Heartbeat and operational observability
- heartbeat.json tracks when the bot last sent its daily “I’m alive” message.
- Roughly once per day, the first run after a long enough gap sends a heartbeat alert to the admin chat ID.
- This gives the operator a simple liveness signal without external monitoring.
10. Error handling and admin alerts
- Failures are reported to the first Telegram chat ID only, keeping operational noise away from regular recipients.
- The README suggests the workflow retries repo push operations, which matters because state files must be committed successfully to preserve deduplication.
11. Persistence and self-updating state
- seen.json and heartbeat.json are both part of the repo and are updated by the bot after each run.
- That makes the repository itself the state store, and GitHub Actions plus git push is the persistence mechanism.
12. Dependencies and runtime profile
- The script uses requests, beautifulsoup4, and lxml for source retrieval/parsing.
- google-generativeai and pdfplumber are optional, only relevant when AI summaries are enabled.
- This is a lightweight Python automation project whose architecture is centered on scheduled fetch → compare → notify → persist.
Main entry points: scraper.py Scraper bot · seen.json Seen state · heartbeat.json Heartbeat state · notify.yml Notify workflow
Components 16
GitHub Actions runtime
Scheduled execution and orchestration inside GitHub Actions.
- Notify workflow · Runs the bot every few minutes on an ephemeral runner.
.github/workflows/notify.yml - Scraper bot · Main executable that fetches notifications, deduplicates, sends alerts, and persists state.
scraper.py - Fetch parse · Retrieves notification listings and normalizes entries into stable identifiers.
scraper.py - Dedup check · Compares normalized notifications against seen.json and seeds on first run.
scraper.py - Deliver alerts · Sends new notifications, attaches PDFs when possible, otherwise sends text and link.
scraper.py - Summaries · Extracts text from PDFs and produces short summaries when enabled.
scraper.py - Persist state · Updates repository state files and relies on git push for durability.
scraper.py - Admin alerts · Routes errors and heartbeat messages to the first Telegram chat ID only.
scraper.py
Repository state
Persistent files updated and committed by the bot.
- Seen state · Persistent idempotency boundary for already-processed notifications.
seen.json - Heartbeat state · Tracks when the last daily heartbeat was sent.
heartbeat.json - Dependencies · Pinned runtime libraries used by the scraper and optional features.
requirements.txt - README · Describes behavior, seeding, pruning, fallback flow, and operational notes.
README.md
External services
Upstream source, delivery target, and optional AI services.
- WordPress API · Preferred upstream source for Pondicherry University notifications.
- HTML fallback · Fallback notifications page scraping when the API is unavailable.
- Telegram · Receives notification broadcasts, admin errors, and heartbeat messages.
- Gemini Flash · Optional summarization service used when AI summaries are enabled.
Connections 20
- Notify workflow → Scraper bot: runs · Scheduled GitHub Actions execution starts the Python script.
- Scraper bot → Fetch parse: starts · Main script begins by collecting current notifications.
- Fetch parse → WordPress API: prefers · Uses the WordPress REST API when available.
- Fetch parse → HTML fallback: falls back · Scrapes HTML when the API cannot be used.
- Fetch parse → Dedup check: normalizes · Transforms source entries into stable identifiers for comparison.
- Dedup check → Seen state: compares against · Checks whether each notification has already been processed.
- Dedup check → Deliver alerts: forwards new items · Only unseen notifications move on to delivery.
- Dedup check → Persist state: seeds/prunes · Initializes the ledger on first run and removes old entries over time.
- Deliver alerts → Telegram: broadcasts · Sends new notification alerts to one or more chats.
- Deliver alerts → Summaries: optional summarize · Invokes AI summary generation when configured.
- Summaries → Gemini Flash: calls · Uses Gemini Flash for short summaries.
- Summaries → Deliver alerts: enriches message · Summary output is included in the notification payload.
- Deliver alerts → Admin alerts: errors/heartbeat · Operational messages are routed only to the first chat ID.
- Admin alerts → Telegram: sends to admin chat · Admin-only Telegram channel receives liveness and failure notices.
- Scraper bot → Heartbeat state: checks/updates · Tracks when the daily heartbeat was last emitted.
- Scraper bot → Persist state: writes · Updates repo-backed state after processing completes.
- Persist state → Seen state: commits · Writes dedupe ledger back into the repository.
- Persist state → Heartbeat state: commits · Writes liveness state back into the repository.
- Scraper bot → Dependencies: depends on · Runtime libraries for HTTP, parsing, and optional AI/PDF features.
- README → Scraper bot: documents · Explains the pipeline, seeding, pruning, and delivery behavior.