Modern Telegram assistant built with pyTelegramBotAPI that keeps your audience subscribed to required channels, provides an admin dashboard, and ships broadcasts (text or photo) with live delivery stats.
/startdetects which channels a user still needs to join and hides the subscription screen if everything is already complete.- Inline keyboards dynamically list only the missing channels, so users always know what’s left.
/adminexposes user count, broadcast launcher, and automatic logging for easier maintenance.- Broadcasts go out immediately (no extra
/sendconfirmation) and support text, photo + caption, plus per-user error tracking. - SQLite storage (
users.db) keeps the bot lightweight while enabling safe concurrent access.
python -m venv env
env\Scripts\activate # or source env/bin/activate on Linux/macOS
pip install -r requirements.txtCreate a .env file in the project root:
BOT_TOKEN=123456:ABCDEF...
REQUIRED_CHANNELS=@channel1,@channel2,@channel3
ADMIN_IDS=111111111,222222222
Then launch the bot:
python main.pymain.py– boots the bot, configures logging, and startsinfinity_polling.config.py– loads secrets from.env, validates required settings.handlers/–/start, admin tools, and broadcast logic.keyboards/– builders for subscription, main menu, and admin inline keyboards.database.py– SQLite helpers (auto-createsuserstable).users.db– generated automatically; ignored by Git.
Install dev deps (pip install -r requirements.txt) and run:
pytestCurrent coverage validates the SQLite user store; extend with handler tests as needed.
- When adding new channels or admins, just update
.envand restart the bot. - Consider batching broadcasts or adding rate-limiting if the user base grows large.
- Logging already captures subscription failures and broadcast errors—watch the console while testing.
- For production hosting, run the bot inside a supervisor or systemd service so it restarts automatically.
Enjoy building your community bot! 💬