Modern asynchronous library for Telegram Bot API
Project description
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
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 telegram_async-3.11.3.tar.gz.
File metadata
- Download URL: telegram_async-3.11.3.tar.gz
- Upload date:
- Size: 122.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffd0a39be7b9f708609809776d230591cdef5c744952df40da454e99e793a519
|
|
| MD5 |
de5b3a55c01461594137367c1dee8efc
|
|
| BLAKE2b-256 |
6979c8407162311ebeb5a55d4c9e13fbb41e1b234644c44ad02c8a23eec51d65
|
File details
Details for the file telegram_async-3.11.3-py3-none-any.whl.
File metadata
- Download URL: telegram_async-3.11.3-py3-none-any.whl
- Upload date:
- Size: 138.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6e5f2e74ad357e4701c34f64d296f33d068142d901324da270efcf62bb614ba
|
|
| MD5 |
a2a9a56352da4251579f25f963d1dc59
|
|
| BLAKE2b-256 |
b25efbd51d032dcc12c293e54ce50304ff3a9efdc790c4959bbd146d97e1fd4a
|