Unified Telegram Bot and Userbot automation framework
Project description
TeleBridge
telebridge is a unified Telegram automation framework for developers who want one async API for both Telegram bots and Telegram user accounts. It combines aiogram for the Bot API and telethon for MTProto userbot workflows behind one decorator-first application object.
GitHub Repository: https://github.com/dtvanshull/telebridge
Introduction
With telebridge, you can build command-driven Telegram automations without wiring separate dispatchers, schedulers, plugin systems, and queue safety layers by hand. One app instance can run bot mode, userbot mode, or both together while sharing handlers, middleware, plugins, and outbound safety controls.
Source Code
The TeleBridge source code and examples are available on GitHub:
https://github.com/dtvanshull/telebridge
Use the repository to:
- browse the full source code
- review runnable examples in
examples/ - report bugs in the issue tracker
- contribute fixes, features, and documentation improvements
Features
- Unified
from telebridge import appdeveloper experience - Telegram Bot API support with
aiogram - Telegram userbot support with
telethon - Command decorators for bot and userbot handlers
- Plugin loading from a directory
- Middleware support
- Background scheduler for recurring jobs
- Safe outbound request queue with retries, rate limiting, and flood wait handling
- OTP login flow for userbot sessions
- Inline buttons and callback handling
- Message editing and deletion helpers
- Media sending and downloading utilities
Installation
Install from PyPI:
pip install telebridge
Install for local development:
pip install -e .[dev]
Quick Start
from telebridge import app
app.setup(
bot_token="123456:ABCdefGhIJKlmNOpQRstuVWxyZ0123456789",
api_id=12345,
api_hash="0123456789abcdef0123456789abcdef",
)
@app.command("start")
async def start(ctx):
await ctx.reply("TeleBridge is ready.")
app.run()
Bot Example
from telebridge import app
app.setup(
bot_token="123456:ABCdefGhIJKlmNOpQRstuVWxyZ0123456789",
auto_load_plugins=False,
)
@app.command("ping")
async def ping(ctx):
await ctx.reply("pong")
if __name__ == "__main__":
app.run()
Userbot Login Example
See examples/userbot_login.py.
from telebridge import app
app.setup(
api_id=12345,
api_hash="0123456789abcdef0123456789abcdef",
session_name="telebridge-user",
auto_load_plugins=False,
)
@app.command("ping")
async def ping(ctx):
await ctx.reply("pong from your userbot")
if __name__ == "__main__":
app.run()
telebridge prompts for the phone number, login code, and optional 2FA password when a valid session is not already available.
Plugin Example
Plugins are regular Python files loaded from a directory.
from telebridge import app
@app.command("hello")
async def hello(ctx):
await ctx.reply("Hello from a plugin")
from telebridge import app
app.setup(
bot_token="123456:ABCdefGhIJKlmNOpQRstuVWxyZ0123456789",
plugins_dir="plugins",
)
if __name__ == "__main__":
app.run()
Middleware Example
from telebridge import app
@app.middleware
async def access_log(ctx, next_call):
print(f"{ctx.backend}: {ctx.text}")
return await next_call()
Message Deletion Example
from telebridge import app
@app.command("cleanup")
async def cleanup(ctx):
reply = await ctx.reply("This message will be deleted.")
await reply.delete()
Channel Automation Example
See examples/channel_automation.py.
from telebridge import app
app.setup(
api_id=12345,
api_hash="0123456789abcdef0123456789abcdef",
session_name="telebridge-channel-tools",
auto_load_plugins=False,
)
@app.command("forwardlast")
async def forward_last(ctx):
if ctx.client.user_client is None:
return
await ctx.client.safe_request(
lambda: ctx.client.user_client.forward_messages("target_channel", ctx.message),
label="forward_messages",
backend=ctx.backend,
)
Contributing
- Install development dependencies with
pip install -e .[dev]. - Update code, tests, and examples together.
- Run
python scripts/release_check.py,pytest, andpython -m build. - Review the generated
dist/artifacts before publishing.
License
Released under the MIT License. See LICENSE.
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 telebridge-0.1.0.tar.gz.
File metadata
- Download URL: telebridge-0.1.0.tar.gz
- Upload date:
- Size: 29.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11cb89137c469b3d6e90cda077abee5a5a26f6b63164d8fd9f98d6bf2ae384af
|
|
| MD5 |
f029f7b964d76a25a459aeb8adee459c
|
|
| BLAKE2b-256 |
6f9713917e76fa713b43c7530469c8f7953c9401f683b5791a1d31e09f3b8012
|
File details
Details for the file telebridge-0.1.0-py3-none-any.whl.
File metadata
- Download URL: telebridge-0.1.0-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cb1b4c6f4243fbc4b66e242a5cee4535202bc17c8c88fdf9bdd1be00d33b731
|
|
| MD5 |
f4e2f43e00b79b36aef8b7dd33ecf441
|
|
| BLAKE2b-256 |
c1c6dc12f7d6f7aa79fa45de3fca4b71a5de57b55ccc406268a6633e29fc0010
|