Telegram bot middleware for Steeper — intercepts updates and outgoing messages to sync with the Steeper platform.
Project description
Steeper
Telegram bot middleware that syncs incoming user messages and outgoing bot replies with the Steeper platform.
Installation
# Core (pick one extra for your framework)
pip install steeper[aiogram] # aiogram v3
pip install steeper[telebot] # pyTelegramBotAPI
pip install steeper[ptb] # python-telegram-bot v20+
Configuration
Every integration requires three values:
| Parameter | Description |
|---|---|
base_url |
Steeper backend URL (e.g. http://localhost:8000) |
bot_id |
UUID of the bot registered in Steeper |
bot_token |
Raw Telegram bot token from BotFather |
Usage
aiogram v3
import asyncio
from aiogram import Bot, Dispatcher, Router
from aiogram.filters import CommandStart
from aiogram.types import Message
from steeper.integrations.aiogram import SteeperMiddleware
BOT_TOKEN = "123456:ABC-DEF..."
router = Router()
@router.message(CommandStart())
async def cmd_start(message: Message) -> None:
await message.answer("Hello!")
async def main() -> None:
bot = Bot(token=BOT_TOKEN)
dp = Dispatcher()
dp.include_router(router)
steeper = SteeperMiddleware(
base_url="http://localhost:8000",
bot_id="your-bot-uuid",
bot_token=BOT_TOKEN,
)
steeper.setup(dp, bot)
await dp.start_polling(bot)
if __name__ == "__main__":
asyncio.run(main())
pyTelegramBotAPI (telebot)
import telebot
from steeper.integrations.telebot import SteeperMiddleware
BOT_TOKEN = "123456:ABC-DEF..."
bot = telebot.TeleBot(BOT_TOKEN)
steeper = SteeperMiddleware(
base_url="http://localhost:8000",
bot_id="your-bot-uuid",
bot_token=BOT_TOKEN,
)
steeper.setup(bot)
# ... register your handlers as usual ...
bot.polling()
python-telegram-bot v20+
from telegram.ext import ApplicationBuilder
from steeper.integrations.ptb import SteeperMiddleware
BOT_TOKEN = "123456:ABC-DEF..."
app = ApplicationBuilder().token(BOT_TOKEN).build()
steeper = SteeperMiddleware(
base_url="http://localhost:8000",
bot_id="your-bot-uuid",
bot_token=BOT_TOKEN,
)
steeper.setup(app)
# ... register your handlers as usual ...
app.run_polling()
How it works
All HTTP calls to Steeper go through SteeperRepository (steeper.repository): it forwards incoming updates and records outgoing bot messages to your backend. Each SteeperMiddleware exposes .repository (and .client for the underlying async HTTP client).
-
Incoming — the integration passes each update as Telegram-shaped JSON to
repository.forward_update(...). Your handlers still run as usual. -
Outgoing — the integration hooks the framework so bot-originated messages are turned into
OutgoingMessageSnapshotvalues and sent withrepository.record_outgoing(...).- aiogram —
Bot.__call__is wrapped so any API call whose result is aMessage(or a list of them, e.g. media groups) is logged—not onlysend_message. - python-telegram-bot —
Bot._postis wrapped so JSON responses that decode toMessageinstances are logged (sends, edits, media groups, etc.). - telebot —
telebot.apihelper._make_requestis wrapped for your bot token so JSONresultpayloads that contain fullmessageobjects are logged.
- aiogram —
If you bypass the normal API (e.g. raw HTTP to Telegram), call the repository yourself:
from steeper.repository import OutgoingMessageSnapshot
await steeper.repository.record_outgoing(
OutgoingMessageSnapshot(
chat_id=chat_id,
message_id=message_id,
text="visible text or caption",
date=None, # optional Unix ts; if omitted, the client defaults it to the current time
)
)
Failures are never fatal: if the Steeper backend is unreachable or returns an error, a warning is logged and your bot keeps working. Note the dispatch model differs per framework — for aiogram and python-telegram-bot the sync calls are awaited inline, so a slow or unreachable backend can add latency (up to the client timeout, 10s by default) per update; telebot dispatches them as background tasks.
License
MIT
Project details
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 steeper-0.1.2.tar.gz.
File metadata
- Download URL: steeper-0.1.2.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53303d6516223d9f4fb4f5325e2bd3880efe4b05d09c80b551721f4c6b8496d6
|
|
| MD5 |
584c1876065e70ca811049072aae9021
|
|
| BLAKE2b-256 |
96d12e57cb736d6dd885da2aff73fed46d37dccfc6b427d47c135fcd7306bf83
|
File details
Details for the file steeper-0.1.2-py3-none-any.whl.
File metadata
- Download URL: steeper-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3a615085b9509c94d1cc1753a6b3570718b111d1bb37d73eb18ab5f144fa793
|
|
| MD5 |
6ec101583e06ac6ede227933511958f8
|
|
| BLAKE2b-256 |
a55e87b96a6a490c55ca491d3c874db28f49bfc0a1e1857de01acd466aada40a
|