How fox-io/hydrus_telegram_bot works
Project Type and Purpose
• This is a backend automation service (“bot”) that:
• Reads configuration (config/config.json)
• Periodically queries the Hydrus Network client for images tagged to be posted
• Downloads/processes those images
• Posts them to a Telegram channel via the Bot API
• Updates the tags in Hydrus once posting is complete
a. Core Bot Application (bot.py)
b. Configuration Layer
– Config Manager module (modules/config_manager.py) reads config/config.json
c. Scheduling Layer
– Schedule Manager (modules/schedule_manager.py) triggers posting at configured intervals
d. Queue Management
– Queue Manager (modules/queue_manager.py) handles in-memory or on-disk queue of image tasks
– Local Queue Storage (queue/QUEUED_IMAGES folder)
e. Hydrus Integration
– Hydrus Manager (modules/hydrus_manager.py) calls the Hydrus Client API
f. File & Media Processing
– File Manager (modules/file_manager.py) downloads images, invokes ImageMagick/Wand or ffmpeg as needed
g. Telegram Integration
– Telegram Manager (modules/telegram_manager.py) calls the Telegram Bot API to post images
h. Logging
– Log Manager (modules/log_manager.py) writes logs to console/files
1. At startup, Core Bot reads config.json through Config Manager.
2. Schedule Manager → triggers every N minutes (time configured).
3. On trigger, Schedule Manager → Queue Manager to enqueue work.
4. Queue Manager → Hydrus Manager: “give me all images tagged with queue_tag.”
5. Hydrus Manager ↔ Hydrus API (HTTP calls) → returns metadata + file URLs.
6. Queue Manager stores tasks in Local Queue Storage.
7. Worker loop:
a. Queue Manager → File Manager: “download this image.”
b. File Manager ↔ Hydrus API (file download) → writes file locally.
c. File Manager → (optionally) ffmpeg/ImageMagick for resizing/format conversion.
d. File Manager → Telegram Manager: “post this file + metadata.”
e. Telegram Manager ↔ Telegram API → posts to channel.
f. On success, Telegram Manager → Hydrus Manager: “update tags (remove queue_tag, add posted_tag).”
8. Throughout all steps, modules call Log Manager to record events and errors.
Architectural Patterns & Principles
• Modularity: Each “manager” module has a single responsibility.
• Layering: Config → Scheduling → Queue → Integration → External Services
• Separation of concerns: Keeps API-specific logic (Hydrus, Telegram) out of scheduling and file logic.