Telebot MTProto for Python
A lightweight wrapper that brings the simple and familiar decorator-based syntax of pyTelegramBotAPI (Telebot) to the high-performance MTProto protocol (using Telethon under the hood).
Why Telebot MTProto?
When building Telegram bots with pyTelegramBotAPI (telebot), you are limited by the HTTP-based Bot API:
- Cannot download files larger than 20MB.
- Cannot upload files larger than 50MB.
- HTTP overhead slows down responses.
Telebot MTProto solves this! By running directly over MTProto (TCP):
- Send & Download files up to 2GB (or 4GB with Telegram Premium).
- Run as a Bot (using bot token) or as a Userbot (using phone login session).
- Enjoy direct TCP speed with zero-change friendly Telebot syntax.
Installation
Install using pip:
pip install telebot-mtproto
Quick Start
1. Run as a Bot Account (with Token)
from telebot_mtproto import MTProtoTeleBot
# Get api_id and api_hash from https://my.telegram.org
bot = MTProtoTeleBot(
api_id=123456,
api_hash="your_api_hash",
bot_token="your_bot_token_from_botfather"
)
@bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
bot.reply_to(message, "Hello! I am running on MTProto protocol.")
@bot.message_handler(func=lambda message: True)
def echo_all(message):
bot.reply_to(message, f"You said: {message.text}")
# Start the bot
bot.run()
2. Run as a Userbot Account (with Phone Login)
If you don't provide a bot_token, it will act as a Userbot. During the first run, it will prompt you in the terminal to enter your phone number and the OTP code sent by Telegram.
from telebot_mtproto import MTProtoTeleBot
bot = MTProtoTeleBot(
api_id=123456,
api_hash="your_api_hash",
session_name="my_userbot_session"
)
@bot.message_handler(commands=['ping'])
def ping(message):
bot.reply_to(message, "Pong from userbot!")
bot.run()
3. Send and Download Large Files (> 20MB)
@bot.message_handler(commands=['download'])
def get_large_file(message):
if message.reply_to_message:
bot.reply_to(message, "Downloading large file... (up to 2GB supported)")
# Download file directly over MTProto TCP
dest = "./downloads/large_file.zip"
bot.download_file(message.reply_to_message, dest)
bot.reply_to(message, f"File saved to {dest}")
License
MIT License.
Metadata
Release files for telebot-mtproto 1.2.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 | Provenance | Actions |
|---|---|---|---|---|
| telebot_mtproto-1.2.0.tar.gz | 9.1 kB | Without provenance | Details for telebot_mtproto-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| telebot_mtproto-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for telebot_mtproto-1.2.0-py3-none-any.whl |
Total release size: 17.6 kB
Release files / telebot_mtproto-1.2.0.tar.gz
| Download URL | telebot_mtproto-1.2.0.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e82368d70b46b54afdec3f730937a003f03052e3d5b29b3d72ed7d5206a29763
|
|
BLAKE2b-256 checksum How to use checksums |
01927555acca7b8ac1bbb77ea86bf5a817e776ecab0a9e3f9f00d79f8a2937b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / telebot_mtproto-1.2.0-py3-none-any.whl
| Download URL | telebot_mtproto-1.2.0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be7e82e62d31120bcc40d06858f60a07ada5f6cad5d890a4dfae4823a8d085f5
|
|
BLAKE2b-256 checksum How to use checksums |
4051dae19634a1058e5fd818feac276a85bc833cebeb9ab4ce62cd5b6fe05500
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Security for telebot-mtproto 1.2.0
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.