Skip to content

anoop14613742/Telegram-Multi-User-Multi-Group-Monitor

Repository files navigation

Telegram Multi-User Multi-Group Monitor

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.

πŸš€ Features

  • 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

πŸ“‹ Requirements

  • Python 3.7+
  • Telegram API credentials (API_ID and API_HASH)
  • Phone number registered with Telegram
  • Required Python packages (see Installation)

πŸ› οΈ Installation

  1. Clone the repository:
git clone https://github.com/anoop14613742/Telegram-Multi-User-Multi-Group-Monitor.git
cd Telegram-Multi-User-Multi-Group-Monitor
  1. Install required packages:
pip install telethon pytz asyncio
  1. 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_ID and API_HASH

βš™οΈ Configuration

Single User Monitoring (telegram_monitor_bot.py)

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 timezone

Multi-User Monitoring (advanced_multi_monitor.py)

Edit 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
}

🚦 Usage

Single User Monitoring

python telegram_monitor_bot.py

Multi-User Monitoring

python advanced_multi_monitor.py

First Run Setup

  1. Run the script
  2. Enter the verification code sent to your phone
  3. The script will create session files for future runs
  4. Monitor will start automatically

πŸ“± Message Format

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!

πŸ”§ Advanced Features

Group ID Formats

  • Public Groups: Use @groupusername format
  • Private Groups: Use negative ID format -1001234567890
  • Mixed Monitoring: Combine both formats in arrays

Media Handling

The monitor automatically:

  • Forwards photos, videos, documents
  • Describes media types in notifications
  • Includes captions when available
  • Handles stickers, voice messages, and more

Error Handling

  • Automatic reconnection on network issues
  • Graceful handling of deleted users/groups
  • Detailed error logging for troubleshooting

πŸ“ File Structure

β”œβ”€β”€ 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

πŸ›‘οΈ Security Notes

  • Session Files: Keep .session files 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

πŸ› Troubleshooting

Common Issues

  1. "Could not find target user"

    • Verify username spelling
    • Try messaging the user first
    • Use user ID instead of username
  2. "Could not find destination chat"

    • Check group username/ID
    • Ensure you're a member of the destination group
    • Verify group permissions
  3. "Session expired"

    • Delete .session files
    • Run script again to re-authenticate
  4. "No messages detected"

    • Check MONITOR_GROUPS configuration
    • Verify target user is active in monitored groups
    • Enable debug logging

Debug Mode

Enable detailed logging by modifying the logging level:

logging.basicConfig(level=logging.DEBUG)

πŸ“„ License

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.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸ“ž Support

For issues and questions:

  1. Check the troubleshooting section
  2. Review the complete guide PDF
  3. Create an issue on GitHub

⚠️ Disclaimer

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages