Skip to main content

Broadcast/newsletter library for aiogram 3.x

Project description

aiogram-broadcast

PyPI CI

Broadcast/newsletter library for Telegram bots built with aiogram 3.x.

Features

  • Automatic subscriber registration via middleware
  • Rate-limited broadcasting to avoid Telegram API limits
  • Scheduled broadcasts with APScheduler
  • Redis subscriber storage
  • Progress callbacks for monitoring
  • Interactive UI menu with multi-language support (EN/RU)

Installation

pip install aiogram-broadcast

With scheduled broadcasts and UI:

pip install aiogram-broadcast[all]

Quick Start

from aiogram_broadcast import BroadcastMiddleware, BroadcastService, RedisBroadcastStorage

redis = Redis(host="localhost")
storage = RedisBroadcastStorage(redis)
service = BroadcastService(bot, storage)

# Auto-register subscribers
dp.update.outer_middleware.register(BroadcastMiddleware(storage))

# Broadcast to all
result = await service.broadcast_text("Hello everyone!", parse_mode="HTML")
print(f"{result.successful}/{result.total} sent, {result.success_rate:.0f}%")

See examples/basic.py for a complete runnable bot.

Usage

Broadcasting

# Text, photo, video, document, or copy any message
await service.broadcast_text("Hello!", parse_mode="HTML")
await service.broadcast_photo(photo_file_id, caption="Check this out")
await service.broadcast_copy(from_chat_id=admin_id, message_id=msg_id)

# Custom sender for any message type
await service.broadcast_custom(my_sender_func)

Scheduled Broadcasts

from aiogram_broadcast import BroadcastScheduler

scheduler = BroadcastScheduler(service, AsyncIOScheduler())
task_id = await scheduler.schedule_text("Reminder!", run_date=some_datetime)
await scheduler.cancel(task_id)

See examples/scheduled.py for full setup.

Progress Tracking

async def on_progress(current, total, result):
    print(f"{current}/{total}{result.successful} sent, {result.failed} failed")

await service.broadcast_text("msg", progress_callback=on_progress)

See examples/progress.py.

Interactive UI Menu

A complete FSM-based wizard for composing and scheduling broadcasts from Telegram — supports text/photo/video/document messages, inline URL buttons, and scheduled delivery.

See examples/ui_menu.py.

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

aiogram_broadcast-0.1.1.tar.gz (32.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiogram_broadcast-0.1.1-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

File details

Details for the file aiogram_broadcast-0.1.1.tar.gz.

File metadata

  • Download URL: aiogram_broadcast-0.1.1.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiogram_broadcast-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f20e3d8718b8d9ba73d804b4621ef4cf468bf7df7dab18ad3a52999795675576
MD5 155ac44fd076c3169cba6b4dc0990b91
BLAKE2b-256 d980df85f183fd5d8cfa76064174cf4290b103f4bc7ef74d597c3185dac4d3df

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiogram_broadcast-0.1.1.tar.gz:

Publisher: publish.yml on DefaultPerson/aiogram-broadcast

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiogram_broadcast-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aiogram_broadcast-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0966cfab8c5737dcfe0bb3316cb3c12a9177c37296ed57a6aae81f6c81584e9a
MD5 92b6c2e1971bb03c1bbce60d1d65f166
BLAKE2b-256 d8d89c3f8884344574f2552a61aca2a8e94a33dd1dcf45e88dfc0d629470d925

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiogram_broadcast-0.1.1-py3-none-any.whl:

Publisher: publish.yml on DefaultPerson/aiogram-broadcast

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page