Telegram Async
An asynchronous Telegram API client library for Python, using aiohttp for efficient communication with Telegram servers.
👤 Author
Denys Ostrovskyi
- 📧 Email: ostrovskyidenys30@gmail.com
- 💼 GitHub: https://github.com/Denba236
📋 Table of Contents
- Features
- Requirements
- Installation
- Quick Start
- Usage Examples
- Coding Guidelines
- API Documentation
- Benchmarks
- Project Structure
- Testing
- Multilingualism
- Contribution
- License
- Contact and Support
✨ Features
- ✅ Fully asynchronous - uses async/await for maximum performance
- ✅ Full Telegram Bot API 9.6 - complete coverage including:
- 🤖 Managed Bots - Create and manage sub-bots
- 📊 Enhanced Polls - Multiple correct answers, revoting, descriptions
- 💳 Paid Media - Premium content for Telegram Stars
- 🔗 Invite Links - Full management with limits/expiration
- 📌 Pin/Unpin Messages - Complete pinning support
- 🚪 Join Requests - Approve/decline membership
- 🔐 Chat Permissions - Granular member control
- 👑 Admin Rights - Set/get administrator rights
- ✅ Session management - automatic connection renewal
- ✅ Webhook support - easy configuration for receiving updates
- ✅ Multimedia sending - photos, videos, documents, audio
- ✅ Inline and reply keyboards - interactive messages
- ✅ Rate limiting - automatic adaptation to API limits
- ✅ Full typing - support for IDEs and type checkers
- ✅ Error handling - advanced retry system and exception handling
- ✅ Multilingualism - support for different languages in bot responses
- ✅ Middleware - request processing system
- ✅ Unit tests - 36 tests with comprehensive coverage
🔧 Requirements
- Python 3.7 or later
- aiohttp >= 3.8.0
- Telegram bot account (token from @BotFather)
📦 Installation
Installation from PyPI
pip install telegram-async
Installation from Source
git clone https://github.com/Denba236/telegram-async.git
cd telegram-async
pip install -e .
Installation with Dev Dependencies
pip install -e ".[dev]"
🚀 Quick Start
Minimal Bot
from telegram_async import Bot, Dispatcher, Router
TOKEN = "YOUR_BOT_TOKEN"
bot = Bot(token=TOKEN)
dp = Dispatcher(bot)
router = Router()
@router.command("start")
async def cmd_start(ctx):
await ctx.reply("Hello! Use /help for commands.")
@router.message()
async def echo(ctx):
await ctx.reply(ctx.text)
dp.include_router(router)
if __name__ == "__main__":
dp.run_polling(bot)
📚 API Documentation
Full API documentation with examples for all 115+ methods:
-
API 9.6 Full Support Guide - Complete documentation for all new features:
- 🤖 Managed Bots - Create and manage sub-bots
- 📊 Enhanced Polls - Multiple correct answers, revoting, descriptions
- 💳 Paid Media - Premium content for Telegram Stars
- 🔗 Invite Links - Full management with limits/expiration
- 📌 Pin/Unpin Messages - Complete pinning support
- 🚪 Join Requests - Approve/decline membership
- 🔐 Chat Permissions - Granular member control
- 👑 Admin Rights - Set/get administrator rights
-
Colored Buttons Guide - Guide for colored buttons (API 9.4+)
-
Migration Guide - How to migrate to new structure
-
Restructure Summary - Project improvements
📖 Usage Examples
Check out the examples/ directory for complete working examples:
examples/main.py- Basic echo botexamples/examples_api_95.py- API 9.5 featuresexamples/examples_colored_buttons.py- Colored buttons guideexamples/examples_new_features.py- 20+ feature examples
Run any example:
python examples/main.py
🧪 Testing
# Run all tests
pytest
# Run with coverage
pytest --cov=telegram_async --cov-report=html
# Run specific test file
pytest tests/test_basic.py
pytest tests/test_api_96.py
# Run with verbose output
pytest -v
Test Results: 36 tests passing ✅
🏗️ Project Structure
telegram_async/
├── examples/ # All example files
├── tests/ # Test suite
│ ├── test_basic.py # Basic tests
│ └── test_api_96.py # API 9.6 tests
├── docs/ # Documentation
│ ├── API_96_FULL_SUPPORT.md
│ └── COLORED_BUTTONS_GUIDE.md
├── telegram_async/ # Main package
│ ├── client/ # API client
│ ├── dispatcher/ # Dispatcher & Router
│ ├── exceptions/ # Exceptions
│ ├── filters/ # Filter system
│ ├── fsm/ # Finite State Machine
│ ├── handlers/ # Handler utilities
│ ├── keyboards/ # Keyboard builders
│ ├── middleware/ # Middleware
│ ├── telegram_types/ # Telegram types
│ ├── utils/ # Utilities
│ └── contrib/ # Community modules
├── README.md
├── MIGRATION_GUIDE.md
├── RESTRUCTURE_SUMMARY.md
├── pyproject.toml
└── .env.example
🌍 Multilingualism
The library supports internationalization (i18n):
from telegram_async.utils import I18n
i18n = I18n(locales_dir='locales', default_locale='en')
# In handler
@router.command("start")
async def cmd_start(ctx):
greeting = await i18n.gettext(ctx.user_id, "Hello!")
await ctx.reply(greeting)
🤝 Contribution
Contributions are welcome! Please:
- Fork the repository
- Create a 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
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🆘 Contact and Support
- 📧 Email: ostrovskyidenys30@gmail.com
- 💼 GitHub: https://github.com/Denba236
- 🐛 Bug Reports: https://github.com/Denba236/telegram-async/issues
- 💬 Discussions: https://github.com/Denba236/telegram-async/discussions
📊 Statistics
- Total Methods: 115+
- API Version: 9.6 (Latest)
- Test Coverage: 36 tests
- Python Versions: 3.7+
- External Dependencies: 1 (aiohttp)
Made with ❤️ by Denys Ostrovskyi
Metadata
Release files for telegram-async 3.15.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| telegram_async-3.15.1.tar.gz | 169.7 kB | Without provenance | Details for telegram_async-3.15.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| telegram_async-3.15.1-py3-none-any.whl | Python 3 | none | any | Details for telegram_async-3.15.1-py3-none-any.whl |
Total release size: 345.8 kB
Release files / telegram_async-3.15.1.tar.gz
| Download URL | telegram_async-3.15.1.tar.gz |
|---|---|
| Size | 169.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25206c9fc96637610e06ca6f8b030d13cc9735bfb266f0689713ab217da41928
|
|
BLAKE2b-256 checksum How to use checksums |
e19a1cdbf818b8a224e3624afe60cb2101514d365856660250bc08ef180fe351
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.2
|
Release files / telegram_async-3.15.1-py3-none-any.whl
| Download URL | telegram_async-3.15.1-py3-none-any.whl |
|---|---|
| Size | 176.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a5af5e40047586ec6debaf91dcbdb558b6172184f4a7062914784e3f8201f377
|
|
BLAKE2b-256 checksum How to use checksums |
e416692f8c8879b12e608751fdf60191a9e17c86c618eecf6cefc93bad5f7049
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.2
|
Security for telegram-async 3.15.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.