Telegram Sentinel Bot is a Python-based Telegram bot that monitors admin activity and automatically locks a group if a daily check-in message is not acknowledged within 24 hours. The admin can unlock the group at any time using a simple command.
- Daily Check-in: Sends a daily verification message to a designated admin at a configurable time (default 21:00 UTC).
- Automated Lockdown: If the admin fails to confirm the message within 24 hours, the bot automatically restricts sending permissions for the entire group.
- Manual Unlock: The admin can restore full group access at any time using the
/reopencommand. - State Persistence: Bot state is saved to a local JSON file, ensuring it remembers the last check-in status even after restarts.
- Simple Deployment: Ready-to-use Docker configuration and environment variable setup.
- Python 3.11+
- A Telegram Bot Token (from @BotFather)
- A Telegram Group where the bot will act as an administrator
- Your Telegram User ID (can be obtained from @userinfobot)
-
Clone the repository
git clone https://github.com/ahmadrezagh671/telegram-sentinel-bot.git cd telegram-sentinel-bot -
Install dependencies
pip install -r requirements.txt
-
Configure environment variables Create a
.envfile or export the following variables:Variable Description Default BOT_TOKENYour Telegram bot token Required ADMIN_IDUser ID of the admin who will receive daily checks Required GROUP_IDID of the group to lock/unlock (must be integer) Required CHECK_HOURHour of the day to send the daily check (0–23) 21CHECK_MINUTEMinute of the hour for the daily check (0–59) 0 -
Run the bot
python main.py
The repository includes a Dockerfile and docker-compose.yml for easy containerization.
docker-compose up -d| Command | Description | Access |
|---|---|---|
/reopen |
Unlocks the group, restoring members' ability to send messages | Admin only |
/seen |
Acknowledges the daily check message, preventing automatic lock | Admin only |
Note: The bot will automatically lock the group if the
/seencommand is not received within 24 hours after a daily check is sent. The admin can always use/reopento manually unlock.
telegram-sentinel-bot/
├── main.py # Core bot logic and handlers
├── requirements.txt # Python dependencies
├── Dockerfile # Docker image definition
├── docker-compose.yml # Docker Compose configuration
├── .gitignore # Git ignore file
├── LICENSE # MIT License
└── README.md # Project documentation
- The bot sends a daily check message to the specified admin at
CHECK_HOUR:CHECK_MINUTEUTC. - The admin must reply with
/seenwithin 24 hours. - If the admin fails to acknowledge, the bot revokes
can_send_messagespermission for all members of the group. - The admin can restore sending permissions at any time using the
/reopencommand. - The cycle repeats daily, with the bot only locking the group if the previous day's check was missed.
Admin receives:
✅ Daily check.
Please read this message within 24 hours.
[If admin does not respond within 24h]
⚠️ Group locked because daily check was not seen in 24h.
Admin can unlock by sending:
/reopen
This project is licensed under the MIT License – see the LICENSE file for details.
Ahmadreza GH
GitHub: ahmadrezagh671
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
If this project helped you, please give it a ⭐ on GitHub!