Skip to content

WizardLoop/BroadcastManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

80 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

BroadcastManager

High-Performance Telegram Broadcast Manager for MadelineProto. Manage broadcasts efficiently: send messages, media albums, pin/unpin messages, control broadcasts in real-time, and track live progress with advanced features.

AGPL License Made with ❀️ Packagist Version Packagist Downloads


🌟 Features

  • πŸš€ High-Performance Broadcasts Send messages concurrently to thousands of users, groups, or channels with configurable concurrency.

  • ⏸ Pause / Resume / Cancel Broadcasts Control ongoing broadcasts in real-time without restarting.

  • πŸ“Œ Pin & Unpin Messages

    • Pin the last broadcasted message automatically.
    • Unpin all messages for all subscribers.
  • 🧹 Delete Last Broadcast

    • Remove previously sent messages from all users.
    • Retries failed deletions and handles Telegram API limits automatically.
  • ♻️ Delete All Broadcasts

    • Remove previously all sent messages from all users.
    • Retries failed deletions and handles Telegram API limits automatically.
  • πŸ“Š Live Progress Tracking

    • Visual progress bars
    • Messages per second (TPS)
    • Sent, failed, and pending counts
    • Paused/cancelled indicators
  • πŸ–Ό Media Albums Support

    • Send multiple images/documents in a single broadcast using sendMultiMedia.
    • Supports captions and message entities.
  • πŸ’Ύ Saving & Reusing Albums
    Save albums to a JSON file for reuse in future broadcasts.
    Use album-bot as an example to store album files locally.

  • πŸ›‘ FLOOD_WAIT Handling & Retries Automatically respects Telegram rate limits and retries failed messages.

  • πŸ”˜ Inline Buttons / Reply Markup

    • Include interactive buttons for links, commands, or actions.

πŸ“ Repository Structure

BroadcastManager/
β”œβ”€β”€ src/
β”‚   └── BroadcastManager.php
β”œβ”€β”€ data/
β”‚   └── .gitkeep
β”œβ”€β”€ composer.json
β”œβ”€β”€ README.md
β”œβ”€β”€ LICENSE
└── CHANGELOG.md

πŸ’» Requirements


⚑ Installation

composer require wizardloop/broadcastmanager

Include autoload:

require 'vendor/autoload.php';

πŸš€ Usage Example

use BroadcastTool\BroadcastManager;

$manager = new BroadcastManager($api);

$manager->broadcastWithProgress(
    allUsers: $users,
    messages: $messages,
    chatId: $adminChatId,
    filterType: 'users',
    pin: true,
    concurrency: 25
);

⏸ Control Broadcasts

$manager->pause();
$manager->resume();
$manager->cancel();

Check state:

if ($manager->isPaused()) echo "Paused";
if ($manager->isCancelled()) echo "Cancelled";
if (!$manager->hasLastBroadcast()) echo "No last Broadcast do delete";
if (!$manager->hasAllBroadcast()) echo "No all Broadcast to delete";
print_r($manager->progress());

Set data dir:

BroadcastManager::setDataDir(__DIR__ . '/data');

default is: DIR . '/../data'


🧹 Delete Last Broadcast

$manager->deleteLastBroadcastForAll(
    allUsers: $users,
    chatId: $adminChatId,
    concurrency: 20
);

♻️ Delete All Broadcast

$manager->deleteAllBroadcastsForAll(
    allUsers: $users,
    chatId: $adminChatId,
    concurrency: 20
);

πŸ“Š Get Last Broadcast Data

$manager->lastBroadcastData();

πŸ“Œ Pin / Unpin Messages

Pin last broadcast automatically:

$manager->broadcastWithProgress(..., pin: true);

Unpin all messages:

$manager->unpinAllMessagesForAll(...);

πŸ”˜ Inline Buttons & Reply Markup

$message = [
    'message' => "Click a button below:",
    'buttons' => [
        [['text' => "Visit Website", 'url' => "https://example.com"]],
        [['text' => "Start", 'callback_data' => "start_action"]]
    ]
];

βš™οΈ Advanced Options

  • Concurrency – Number of parallel workers.
  • Filter Types – 'users', 'groups', 'channels', 'all'
  • Album Handling – JSON-based albums with multiple media files.
  • Retries & Delays – Automatic retries with backoff.
  • Progress Tracking – Real-time broadcast stats with progress().

🀝 Contributing

  1. Fork repo
  2. Create branch: git checkout -b feature/my-feature
  3. Commit changes: git commit -m "Add feature"
  4. Push branch: git push origin feature/my-feature
  5. Open Pull Request

πŸ“„ License

GNU AGPL-3.0 β€” see LICENSE.


πŸ“ Changelog

See [CHANGELOG.md] for updates.


βœ… Pro Tips

  • Use pin: true to pin important broadcasts.
  • Include buttons for interactive messages.
  • Adjust concurrency for optimal performance.
  • Use pause/resume/cancel for safe broadcast control.

About

High-performance Telegram broadcast manager for MadelineProto.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages