Fork of Pyrogram maintained by xydevs - Telegram MTProto API Client Library for Python
Project description
Pyrogram XyDevs Fork
Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
This is a fork of the original Pyrogram library, maintained by XyDevs with additional features and improvements.
Key Features
- Ready: Install Pyrogram with pip and start building your applications right away.
- Easy: Makes the Telegram API simple and intuitive, while still allowing advanced usages.
- Elegant: Low-level details are abstracted and re-presented in a more convenient way.
- Fast: Boosted up by TgCrypto, a high-performance cryptography library written in C.
- Type-hinted: Types and methods are all type-hinted, enabling excellent editor support.
- Async: Fully asynchronous (also usable synchronously if wanted, for convenience).
- Powerful: Full access to Telegram's API to execute any official client action and more.
Installation
For End Users
pip install pyrogram-xydevs
For Development
Follow the development setup guide below to contribute to this project.
Quick Start
from pyrogram import Client, filters
app = Client("my_account")
@app.on_message(filters.private)
async def hello(client, message):
await message.reply("Hello from Pyrogram XyDevs!")
app.run()
Development Setup
This section is for contributors who want to modify the source code and contribute to the project.
Prerequisites
- Python 3.8 or higher
- Git
- A Telegram API key (for testing)
1. Clone the Repository
git clone https://github.com/xydevs/pyrogram-fork.git
cd pyrogram-fork
2. Set Up Virtual Environment
On Windows (PowerShell):
# Create virtual environment
python -m venv venv
# Activate virtual environment
& "venv\Scripts\Activate.ps1"
# Verify activation (should show venv path)
echo $env:VIRTUAL_ENV
On Linux/macOS:
# Create virtual environment
python -m venv venv
# Activate virtual environment
source venv/bin/activate
# Verify activation
echo $VIRTUAL_ENV
3. Install Dependencies
# Upgrade pip
pip install --upgrade pip
# Install build tools
pip install build twine
# Install the package in development mode
pip install -e .
# Install additional dependencies
pip install PySocks
4. Verify Installation
Create a test file to verify everything works:
# test.py
import pyrogram
print("Pyrogram location:", pyrogram.__file__)
print("Import successful!")
Run the test:
python test.py
You should see output pointing to your local development directory.
5. Making Changes
Project Structure
pyrogram-fork/
├── main/pyrogram/ # Main source code
│ ├── __init__.py
│ ├── client.py
│ ├── types/
│ ├── methods/
│ ├── handlers/
│ └── ...
├── pyproject.toml # Package configuration
├── README.md
└── test.py
Code Editing
- Make your changes in the
main/pyrogram/directory - Test your changes:
python test.py # or run your own test scripts
6. Building and Publishing
Step 1: Update Version
Edit pyproject.toml and increment the version number:
[project]
name = "pyrogram-xydevs"
version = "2.1.107" # Increment this number
description = "Fork of Pyrogram maintained by xydevs"
# ... rest of config
Step 2: Clean Previous Builds
# Remove old build files
Remove-Item -Recurse -Force dist/ # Windows PowerShell
# rm -rf dist/ # Linux/macOS
Step 3: Build Package
python -m build
This creates:
dist/pyrogram_xydevs-x.x.x-py3-none-any.whldist/pyrogram_xydevs-x.x.x.tar.gz
Step 4: Validate Package
python -m twine check dist/*
Should output: PASSED for all files.
Step 5: Upload to PyPI
⚠️ Important: Always test on TestPyPI first!
Test Upload (TestPyPI):
# Upload to TestPyPI
python -m twine upload --repository testpypi dist/*
# Test installation from TestPyPI
pip install --index-url https://test.pypi.org/simple/ pyrogram-xydevs
Production Upload (PyPI):
# Upload to PyPI (only after TestPyPI works)
python -m twine upload dist/*
7. PyPI Credentials Setup
Method 1: API Tokens (Recommended)
-
Create accounts on:
-
Generate API tokens in account settings
-
Create
~/.pypirc:
[distutils]
index-servers =
pypi
testpypi
[pypi]
username = __token__
password = pypi-your_real_api_token_here
[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = pypi-your_test_api_token_here
Method 2: Environment Variables
# Set environment variables
export TWINE_USERNAME=__token__
export TWINE_PASSWORD=your_api_token_here
8. Release Workflow
- Make changes in
main/pyrogram/ - Test locally:
python test.py - Update version in
pyproject.toml - Build package:
python -m build - Validate:
python -m twine check dist/* - Test upload:
python -m twine upload --repository testpypi dist/* - Test install:
pip install --index-url https://test.pypi.org/simple/ pyrogram-xydevs - Production upload:
python -m twine upload dist/* - Tag release:
git tag v2.1.x && git push --tags
9. Common Commands Reference
# Development workflow
& "venv\Scripts\Activate.ps1" # Activate venv (Windows)
source venv/bin/activate # Activate venv (Linux/macOS)
python test.py # Test changes
python -m build # Build package
python -m twine check dist/* # Validate package
python -m twine upload --repository testpypi dist/* # Test upload
python -m twine upload dist/* # Production upload
# Package management
pip install -e . # Install in development mode
pip list # List installed packages
pip uninstall pyrogram-xydevs # Uninstall package
10. Troubleshooting
Virtual Environment Issues
# If venv activation fails
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser # Windows
# If wrong Python version
python --version
which python # Should point to venv
Import Issues
# Reinstall in development mode
pip uninstall pyrogram-xydevs
pip install -e .
Upload Issues
# Version already exists error
# Solution: Increment version in pyproject.toml
# Authentication error
# Solution: Check API tokens and .pypirc file
Requirements
- Python 3.8 or higher.
- A Telegram API key.
Resources
- Check out the docs at https://docs.pyrogram.org to learn more about Pyrogram, get started right away and discover more in-depth material for building your client applications.
- Join the official channel at https://t.me/pyrogram and stay tuned for news, updates and announcements.
Changes from Original Pyrogram
This fork includes additional features and improvements maintained by XyDevs team. For detailed changelog, please check our releases.
Contributing
We welcome contributions! Please follow the development setup guide above to get started.
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Test thoroughly
- Submit a pull request
License
This project is licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyrogram_xydevs-2.1.107.tar.gz.
File metadata
- Download URL: pyrogram_xydevs-2.1.107.tar.gz
- Upload date:
- Size: 739.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cca2023f8ef1dc58d1c619832ab3abb8225ae52d59973f825bca4d1a44d72d4b
|
|
| MD5 |
d0e05f5ed2367df1e33269c91f0f748b
|
|
| BLAKE2b-256 |
55d377be3a810cf8f2d28e04ef3f9a5e0193a10dfa8cc8606ac6e40c17091ffc
|
File details
Details for the file pyrogram_xydevs-2.1.107-py3-none-any.whl.
File metadata
- Download URL: pyrogram_xydevs-2.1.107-py3-none-any.whl
- Upload date:
- Size: 3.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc1d1d2ae75c2ec11c2e9a5cae02729752043dd6de7594a7e2c2e96d82ab4fa0
|
|
| MD5 |
39a1a3f2f9fbf28a43209c173caa3f66
|
|
| BLAKE2b-256 |
4344d263cdaf21fb81e88993ace30f9b6dc298372dec69eb375ff1500eeb49f2
|