sent
sent is an async MTProto client library for Telegram. It speaks the raw Telegram protocol and supports both user accounts and bots with an event-driven, developer-friendly API.
Features
- Async MTProto 2.0 — encryption, sessions, RPC with
RpcResult/MsgContainerhandling - User accounts and bots — phone + code login, SRP 2FA, bot token, QR login
- Event system —
NewMessage,MessageDeleted,MessageRead,CallbackQuery,ChatAction,UserUpdate,Album - Friendly API —
send_message,send_file,get_dialogs,iter_messages,conversation() - TL layer 225 — auto-generated from the latest Telegram schema
- Session storage — SQLite (with entity cache), StringSession, or in-memory
- Transport — TCP abridged / intermediate / full, SOCKS5 proxy support
Installation
pip install sent
Optional extras for faster cryptography:
pip install sent[fast] # cryptg (recommended for production)
pip install sent[crypto] # pycryptodome fallback
For local development:
git clone https://github.com/kalanakt/sent.git
cd sent
uv sync --all-extras
Quick start
Get your api_id and api_hash from my.telegram.org.
Bot
import asyncio
import os
from sent import TelegramClient, events
API_ID = int(os.environ["TELEGRAM_API_ID"])
API_HASH = os.environ["TELEGRAM_API_HASH"]
BOT_TOKEN = os.environ["TELEGRAM_BOT_TOKEN"]
async def main():
client = TelegramClient("echo_bot", API_ID, API_HASH)
@client.on(events.NewMessage)
async def handler(event):
await event.reply(event.text)
await client.start(bot_token=BOT_TOKEN)
await client.run_until_disconnected()
asyncio.run(main())
See examples/echo_bot.py for a complete echo bot.
User account
import asyncio
import os
from sent import TelegramClient, events
API_ID = int(os.environ["TELEGRAM_API_ID"])
API_HASH = os.environ["TELEGRAM_API_HASH"]
async def main():
client = TelegramClient("my_account", API_ID, API_HASH)
@client.on(events.NewMessage(incoming=True))
async def handler(event):
await event.reply("Hello!")
await client.start() # prompts for phone, code, and 2FA when needed
me = await client.get_me()
print(f"Logged in as {me.first_name}")
await client.run_until_disconnected()
asyncio.run(main())
See examples/user_bot.py for a fuller user-account example.
Conversation helper
async with client.conversation("username") as conv:
await conv.send_message("What's your name?")
response = await conv.get_response()
print(response.text)
Development
uv sync --group test
uv run pytest test/ -v
Run benchmarks:
uv run python bench/run.py
Regenerate TL types after updating the schema:
python -m sent._codegen.generate
See CONTRIBUTING.md for full contributor and release guidelines.
Project links
- Source: https://github.com/kalanakt/sent
- Issues: https://github.com/kalanakt/sent/issues
- PyPI: https://pypi.org/project/sent/
License
MIT — see LICENSE.
Metadata
Release files for sent 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sent-1.0.0.tar.gz | 365.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sent-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 775.6 kB
Release files / sent-1.0.0.tar.gz
| Download URL | sent-1.0.0.tar.gz |
|---|---|
| Size | 365.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1a61ccc7fc4c8daf9ba40415f5ebf1ed5faeebc9cfa077dcb7605ef14d0396f
|
|
BLAKE2b-256 checksum How to use checksums |
965277c1106aa7a8c35b54502efde1ea62348283aff47ffa890ed3e7b2294964
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 5, 2026.
Transparency logRelease files / sent-1.0.0-py3-none-any.whl
| Download URL | sent-1.0.0-py3-none-any.whl |
|---|---|
| Size | 409.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
614872f1c94c8f63ab42a84e3217d52e52758a06e47dd27bdd9b2436296a1319
|
|
BLAKE2b-256 checksum How to use checksums |
b720b54ec206b05bbc9493a9ccc3b63810d33c8f24d73450de8c8a5744152ea8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 5, 2026.
Transparency log