Telegram bot for managing OTT (Online Television Tuner) URLs with mandatory subscription to a Telegram channel.
- Forces users to subscribe to Telegram channel @onmyid before using the bot
- Direct verification using Telegram API
- Buttons for channel subscription and subscription verification
/start- Start the bot and access main menu/info- View your OTT URL information/resetdevice- Reset registered devices
- "π Redeem URL OTT" button to get a new URL
- Queue system to manage redeem requests
- Free trial period (10 days)
- "π΅ OTT Prices" button to view price list
- "βΉοΈ OTT URL Info" button to view account information
- "π Renew URL" button for users whose URL has expired
- Notifications before and after URL expiration (7, 3, 1 days)
- Scheduled system for sending notifications
/stats- View user statistics/queue- View redeem queue size/ping- Check system health
/notify <user_id|all> <days>- Send manual notifications/delete <user_id>- Delete user/resetnotify <user_id>- Reset user notifications
/broadcast- Send to ALL users (text only)/broadcastto <user_id>- Send to ONE user (text only)/broadcastlist <user_id1> <user_id2> ...- Send to a LIST of users (text only)
BOT_TOKEN- Telegram Bot TokenSAVE_PATH- Location for storing user filesLOG_FILE- Redeem log locationBROADCAST_LOG_FILE- Broadcast log locationNOTIFICATION_DAYS- Days to send notifications before expirationADMIN_ID- Telegram admin IDCHANNEL_USERNAME- Username of the mandatory Telegram channel
- Per-UUID files stored in database directory
- System logs using JSON format
- File lock system to prevent conflicts
- Users must subscribe to channel @onmyid to use the bot
- Direct verification using Telegram API
- All bot functions check user subscription status
- Retry system to avoid Telegram rate limits
- Scheduled notifications to reduce system load
- Queue to manage concurrent redeem requests
- System worker to process requests sequentially
- Queue status viewable by admin
{
"user_id": {
"nama": "User Name",
"uuid": "Unique ID",
"redeem_time": timestamp,
"expired_time": timestamp,
"notified_days": [7, 3, 1]
}
}{
"expired_time": timestamp,
"expired_desc": "Expiration Date",
"limit_device": "1",
"playlist_type": "all",
"created_by": "DilarangBodoh"
}/start- Start bot/info- View information/resetdevice- Reset device/help- Help
/stats- User statistics/notify- Manual notifications/delete- Delete user/resetnotify- Reset notifications/ping- Check system/queue- View queue/broadcast- Broadcast to all/broadcastto- Broadcast to one/broadcastlist- Broadcast to list
redeem- Redeem OTT URLinfo- OTT URL Infoharga- OTT Pricesresetdevice- Reset Devicerenew- Renew URLcheck_subscription- Check subscription
- Runs every 6 hours
- Checks users who will expire
- Sends notifications 7, 3, and 1 days before expiration
- Sends notifications when already expired
- Admin can send notifications at any time
- Can be sent to all users or specific users
- Can specify days before/after expiration
load_redeem_log()- Load redeem logsafe_write()- Write file safelysave_redeem_log()- Save redeem logget_user_name()- Get user nameshort_id()- Generate unique IDis_expired()- Check expiration statussafe_send()- Send message with retryalert_admin()- Send alert to adminload_broadcast_log()- Load broadcast logsave_broadcast_log()- Save broadcast loggenerate_message_hash()- Generate message hashis_user_subscribed()- Check user subscription
redeem_worker()- Process redeem queuenotification_task()- Scheduled notification task
broadcast()- Broadcast to all usersbroadcastto()- Broadcast to one userbroadcastlist()- Broadcast to list of usershandle_broadcast_confirmation()- Handle broadcast confirmation
- Automatic retry for network errors
- Delays between sends to avoid rate limits
- Background task scheduling
- Detailed error logging
- Automatic alerts to admin for critical errors
- Exception handling for all main functions
python-telegram-bot- Telegram APIpytz- Time zone managementasyncio- Asynchronous programmingjson- JSON data format managementlogging- Logging systemos- File system interactionrandom&string- Random ID generation
- Python 3.7+
- python-telegram-bot 20.0+
- Linux/Windows server with Python 3.7+
- Internet access for Telegram API connection
- Sufficient storage for database files
- Sufficient RAM for asynchronous operations
- Install dependencies:
pip install python-telegram-bot - Set configuration in code (bot token, paths, etc)
- Run bot:
python bot.py - Ensure database directory is writable
- Monitor system logs for errors
- Regularly backup database files
- Update bot token if needed
- Monitor server resource usage