A Telegram bot for monitoring IPs/domains with global ping probes and country-based alerting.
Data Guardian lets users:
- register IPs or domains,
- monitor reachability from multiple countries (via Check-Host),
- configure per-address country notifications,
- run full checks on demand,
- receive scheduled alert messages when connectivity degrades.
- Telegram-first workflow using inline keyboards and conversations.
- IP/Domain registration with eligibility limits based on user rank.
- Country-specific notification rules per monitored address.
- Scheduled checks for 10/20/30 minute notification windows.
- Multi-language UX (English and Farsi) for text and keyboard labels.
- PostgreSQL persistence for users, addresses, countries, notification rules, and ranks.
.
├── main.py # App entrypoint, handlers, and scheduler registration
├── create_database.py # Schema and seed helpers
├── posgres_manager.py # PostgreSQL connection pool + query/transaction abstraction
├── language.py # Localized bot text and keyboard labels
├── utilities.py # Error handling, language lookup, helpers
├── private.py # Runtime secrets and DB credentials (local-only)
├── api/
│ ├── checkHostApi.py # Check-Host API client and data cleaning
│ └── virtualizorApi.py # Virtualizor integration (work in progress)
├── ipGuardian/
│ ├── ip_guardian.py # IP guardian menu + add IP conversation
│ ├── ip_guardianCore.py # Core IP registration/check logic
│ └── myIPs.py # User IP management and per-address settings
├── notification/
│ ├── check_addreses_ping.py # Queue and periodic notification jobs
│ └── check_address_pingsCore.py # Notification data selection and formatting
├── user/
│ └── registerCore.py # User registration flow
└── admin/
└── adminTelegram.py # Admin-side bot notifications
- Python 3.11+
- PostgreSQL 13+
- A valid Telegram bot token
- Network access to:
api.telegram.orgcheck-host.net
Install dependencies:
pip install -r req.txtThe project currently reads runtime configuration from private.py.
telegram_bot_tokentelegram_bot_urladmin_chat_idsdatabase_detail:db_namedb_hostdb_userdb_passworddb_port
Important security note: Do not commit real tokens/passwords. Use local secrets and rotate any credentials that were previously exposed.
- Create your PostgreSQL database.
- Update
database_detailinprivate.py. - Initialize schema:
python -c "from create_database import create; create()"- Seed initial reference data (countries + default rank):
python -c "from create_database import init; init()"python main.pyAt startup, main.py ensures schema creation (create()) and then starts polling updates from Telegram.
The bot registers three repeating jobs in the Telegram job queue:
- every 10 minutes (
Check10) - every 20 minutes (
Check20) - every 30 minutes (
Check30)
These jobs gather eligible addresses, queue checks, call Check-Host, and send user notifications when thresholds are crossed.
All user-facing messages and keyboard labels are centralized in language.py.
- Text dictionary:
text_transaction - Keyboard dictionary:
keyboard_transaction
Supported languages in the current implementation:
en(English)fa(Farsi)
- The project uses
python-telegram-botasync handlers. - Database access is abstracted by a small custom client in
posgres_manager.py. - Error handling decorators in
utilities.pyreport exceptions to admins and show user-friendly messages.
Recommended improvements for production hardening:
- Move secrets from
private.pyto environment variables. - Add automated tests (unit/integration).
- Add structured logging + log rotation.
- Containerize deployment and add CI checks.
- Bot does not start: verify token, internet access, and dependency installation.
- DB errors on startup: ensure PostgreSQL is running and
database_detailis correct. - No notifications received: confirm addresses/countries are registered and periodic jobs are running.
- Language fallback issues: verify user language value exists in
UserDetailand keys exist inlanguage.py.
No license file is currently included. Add a LICENSE file if you plan to distribute this project.