A powerful Python-based monitoring system for tracking specific users across multiple Telegram groups and channels. This project provides two monitoring modes: single-user monitoring and advanced multi-user monitoring.
- Single User Monitoring: Track one specific user across all or selected groups
- Multi-User Monitoring: Monitor multiple users with customizable group configurations
- Real-time Notifications: Instant alerts sent to your designated chat/group
- Media Support: Forwards photos, videos, documents, and other media types
- Message Links: Direct links to original messages for easy navigation
- Timezone Support: Configurable timezone for accurate timestamps
- Detailed Logging: Comprehensive logging for debugging and monitoring
- Session Management: Persistent Telegram sessions for reliable operation
- Python 3.7+
- Telegram API credentials (API_ID and API_HASH)
- Phone number registered with Telegram
- Required Python packages (see Installation)
- Clone the repository:
git clone https://github.com/anoop14613742/Telegram-Multi-User-Multi-Group-Monitor.git
cd Telegram-Multi-User-Multi-Group-Monitor- Install required packages:
pip install telethon pytz asyncio- Get Telegram API credentials:
- Visit https://my.telegram.org
- Log in with your phone number
- Go to "API Development Tools"
- Create a new application
- Note down your
API_IDandAPI_HASH
Edit the configuration section in telegram_monitor_bot.py:
# API Configuration
API_ID = 2040 # Your API ID
API_HASH = 'your_api_hash_here' # Your API Hash
PHONE_NUMBER = '+1234567890' # Your phone number
# Target user to monitor
TARGET_USERNAME = 'username' # Username without @
TARGET_USER_ID = None # Optional: Use user ID instead
# Where to send notifications
DESTINATION_CHAT = '@your_group_username' # Your notification group
# Groups to monitor (empty = all groups)
MONITOR_GROUPS = [] # Examples:
# MONITOR_GROUPS = ['@public_group1', '@public_group2'] # Public groups
# MONITOR_GROUPS = [-1001234567890, -1009876543210] # Private groups
# MONITOR_GROUPS = ['@public_group', -1001234567890] # Mixed
TIMEZONE = "UTC" # Your timezoneEdit the configuration section in advanced_multi_monitor.py:
# API Configuration (same as above)
API_ID = 2040
API_HASH = 'your_api_hash_here'
PHONE_NUMBER = '+1234567890'
DESTINATION_CHAT = '@your_group_username'
# Advanced Configuration - Option 1: Specific user-group mapping
USER_GROUP_CONFIG = {
'user1': ['@group1', -1001234567890], # Monitor user1 in specific groups
'user2': [], # Monitor user2 in ALL groups
'user3': ['@group2'], # Monitor user3 in one group
}
# Advanced Configuration - Option 2: Simple mode (all users in all groups)
SIMPLE_MONITOR_ALL = {
'enabled': False, # Set to True to use this mode
'users': ['user1', 'user2', 'user3'],
'groups': ['@group1', '@group2'] # Empty = all groups
}python telegram_monitor_bot.pypython advanced_multi_monitor.py- Run the script
- Enter the verification code sent to your phone
- The script will create session files for future runs
- Monitor will start automatically
The bot sends detailed notifications including:
π Message Monitor Alert
π€ User: John Doe (@johndoe)
π¬ Group: Example Group
π Sent: 2024-01-15 14:30:25 UTC
π₯ Detected: 2024-01-15 14:30:26 UTC
π± Message ID: 12345
π Link: https://t.me/group/12345
========================================
π Message:
Hello, this is the monitored message!
- Public Groups: Use
@groupusernameformat - Private Groups: Use negative ID format
-1001234567890 - Mixed Monitoring: Combine both formats in arrays
The monitor automatically:
- Forwards photos, videos, documents
- Describes media types in notifications
- Includes captions when available
- Handles stickers, voice messages, and more
- Automatic reconnection on network issues
- Graceful handling of deleted users/groups
- Detailed error logging for troubleshooting
βββ telegram_monitor_bot.py # Single user monitoring script
βββ advanced_multi_monitor.py # Multi-user monitoring script
βββ monitor_session.session # Telegram session file (auto-generated)
βββ monitor_session.session-journal # Session journal (auto-generated)
βββ README.md # This file
βββ Telegram Multi-User Multi-Group Monitor - Complete Guide.pdf
- Session Files: Keep
.sessionfiles secure - they contain authentication tokens - API Credentials: Never share your API_ID and API_HASH
- Phone Number: Use a dedicated number for monitoring if possible
- Group Access: Ensure you have proper permissions in monitored groups
-
"Could not find target user"
- Verify username spelling
- Try messaging the user first
- Use user ID instead of username
-
"Could not find destination chat"
- Check group username/ID
- Ensure you're a member of the destination group
- Verify group permissions
-
"Session expired"
- Delete
.sessionfiles - Run script again to re-authenticate
- Delete
-
"No messages detected"
- Check MONITOR_GROUPS configuration
- Verify target user is active in monitored groups
- Enable debug logging
Enable detailed logging by modifying the logging level:
logging.basicConfig(level=logging.DEBUG)This project is provided as-is for educational and monitoring purposes. Please ensure compliance with Telegram's Terms of Service and applicable laws in your jurisdiction.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For issues and questions:
- Check the troubleshooting section
- Review the complete guide PDF
- Create an issue on GitHub
This tool is for legitimate monitoring purposes only. Users are responsible for:
- Complying with Telegram's Terms of Service
- Respecting privacy and legal requirements
- Using the tool ethically and responsibly
Made with β€οΈ for the Telegram monitoring community