A Python-based Telegram account management system that provides comprehensive control over your Telegram dialogs, messages, and media. Built with Telethon, this tool allows you to manage and analyze your Telegram data programmatically.
- List and filter dialogs (chats, groups, channels)
- Access dialog folders
- Search through messages with various filters
- Handle media messages (photos, videos, documents)
- Date-based message filtering
- Comprehensive dialog and message information
telegram-copilot/
├── src/
│ ├── core/ # Core functionality
│ ├── models/ # Data models
│ ├── services/ # Business logic
│ └── utils/ # Helper functions
├── examples/ # Usage examples
└── tests/ # Test cases
- Python 3.8+
- Telegram API credentials (API ID and Hash)
- Clone the repository:
git clone https://github.com/yourusername/telegram-copilot.git
cd telegram-copilot
- Create and activate a virtual environment:
python -m venv venv
# On Windows:
venv\Scripts\activate
# On Unix or MacOS:
source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Create a
.env
file in the project root with your Telegram API credentials:
TELEGRAM_API_ID=your_api_id
TELEGRAM_API_HASH=your_api_hash
TELEGRAM_2FA_PASSWORD=your_2fa_password # Only if you have 2FA enabled
To get your Telegram API credentials:
- Visit https://my.telegram.org/auth
- Log in with your phone number
- Go to 'API development tools'
- Create a new application
- Copy the API ID and API Hash
Check out the examples directory for usage demonstrations. Here's a basic example:
from src.core.client import TelegramCopilotClient
from src.services.dialog_service import DialogService
from src.services.message_service import MessageService
async def main():
async with TelegramCopilotClient() as client:
dialog_service = DialogService(client)
message_service = MessageService(client)
# Get all dialogs
dialogs = await dialog_service.get_all_dialogs()
for dialog in dialogs:
print(f"{dialog.dialog_type}: {dialog.name}")
# Get recent messages from a dialog
if dialogs:
messages = await message_service.get_messages(dialogs[0].id, limit=10)
for msg in messages:
print(f"[{msg.date}] {msg.text}")
if __name__ == "__main__":
asyncio.run(main())
Run the example script:
python examples/basic_usage.py
- List all dialogs
- Filter by type (user, group, channel, bot)
- Search dialogs by name
- Access dialog folders
- Get unread message counts
- Fetch messages with pagination
- Filter by date range
- Search message content
- Handle different media types
- Access message metadata (forwards, replies, edits)
-
Dialog filters:
- By type (user/group/channel/bot)
- By name
- By unread status
- By archived status
-
Message filters:
- By date range
- By media type
- By content
- By sender
- With/without media
- Never commit your
.env
file or share your API credentials - The
.gitignore
file is configured to exclude sensitive files - Session files are stored locally and are also excluded from git
Contributions are welcome! Please feel free to submit a Pull Request. For major changes:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Web UI for easier interaction
- Message statistics and analytics
- Bulk message management
- Enhanced media handling
- Export/backup functionality