Pydantic message models and optional FastStream/Redis transport for Approck Telegram delivery.
Project description
approck-messaging
Pydantic models and thin FastStream helpers for delivering Telegram-style messages over Redis streams. Used as the shared message contract between backend services and bots (for example with approck-aiogram-utils).
Python: 3.10+
Install
From PyPI:
uv add approck-messaging
Or with pip:
pip install approck-messaging
Optional Redis transport (FastStream + Redis streams):
uv add "approck-messaging[transport]"
Core install includes only Pydantic models — no broker runtime.
What is included
| Module | Purpose |
|---|---|
approck_messaging.models.message |
Message, TransportMessage, MessageType, MessageMedia, MessageButton |
approck_messaging.publisher |
Publisher — publish TransportMessage to a Redis stream |
approck_messaging.subscriber |
Subscriber — decorate handlers with @subscriber.message(...) |
Usage
Message models
Message describes the payload (caption, media, buttons, video note). TransportMessage adds routing metadata (recipient, optional extra, valid_until).
from approck_messaging.models.message import (
MessageMedia,
MessageType,
TransportMessage,
TransportMessageRecipient,
)
message = TransportMessage(
type=MessageType.GENERIC,
caption="Hello",
recipient=TransportMessageRecipient(telegram_id=123456789),
)
Supported MessageType values: generic, video_note.
Publish to a Redis stream
Requires the transport extra (faststream[redis]).
from faststream.redis import RedisBroker
from approck_messaging.models.message import MessageType, TransportMessage, TransportMessageRecipient
from approck_messaging.publisher import Publisher
broker = RedisBroker("redis://localhost:6379")
publisher = Publisher(broker=broker, stream="outbound-messages")
await publisher.send_message(
TransportMessage(
type=MessageType.GENERIC,
caption="Hello",
recipient=TransportMessageRecipient(telegram_id=123456789),
)
)
Publisher.from_uri(redis_uri, stream=...) is a shortcut when you do not share a broker instance.
Subscribe to a Redis stream
from faststream import Context
from faststream.redis import RedisBroker, StreamSub
from approck_messaging.models.message import TransportMessage
from approck_messaging.subscriber import Subscriber
broker = RedisBroker("redis://localhost:6379")
subscriber = Subscriber(broker=broker, my_var=42)
@subscriber.message(StreamSub("outbound-messages", group="bot", consumer="1"))
async def handle(message: TransportMessage, my_var: int = Context()):
assert my_var == 42
...
Extra keyword arguments passed to Subscriber(...) are registered as FastStream global context values (context.set_global).
Development
uv sync --group dev --extra transport
uv run ruff check .
uv run ruff format --check .
uv run mypy approck_messaging
uv run pytest
Related packages
approck-aiogram-utils— sendMessage/TransportMessagepayloads to Telegram via aiogram.
License
MIT — 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 approck_messaging-0.1.10.tar.gz.
File metadata
- Download URL: approck_messaging-0.1.10.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a22672ad47dc066fe7ddc618a16b000226f65bd07051cbf6ca6aa2de7d68f1b
|
|
| MD5 |
004a46dbb0d60b508d4892c2fec201b7
|
|
| BLAKE2b-256 |
c79ee35b8b972f1b14bc25b58edbab1aa523a7afb7d8d947316af169a6d82c9a
|
File details
Details for the file approck_messaging-0.1.10-py3-none-any.whl.
File metadata
- Download URL: approck_messaging-0.1.10-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4890c07318bb1ccaef7dd60fbd6d8377257c8612959a7ff56d030a796eb747e8
|
|
| MD5 |
538128819ffb53f473501381f979b1df
|
|
| BLAKE2b-256 |
1903485377351c0a9dc6d2f41ce87ebe5d21ddbf7943995cd975702cab973c3e
|