#!/usr/bin/env php . * * @author Daniil Gentili * @copyright 2016-2023 Daniil Gentili * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 * @link https://docs.madelineproto.xyz MadelineProto documentation */ use danog\MadelineProto\API; use danog\MadelineProto\EventHandler\Attributes\Handler; use danog\MadelineProto\EventHandler\Message; use danog\MadelineProto\EventHandler\SimpleFilter\Incoming; use danog\MadelineProto\SimpleEventHandler; /* * Various ways to load MadelineProto */ if (file_exists('vendor/autoload.php')) { include 'vendor/autoload.php'; } else { if (!file_exists('madeline.php')) { copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php'); } include 'madeline.php'; } /** * Combined multiaccount event handler class. */ class CombinedEventHandler extends SimpleEventHandler { /** * @var int|string Username or ID of bot admin */ public const ADMIN = "danogentili"; // Change this /** * Get peer(s) where to report errors. */ public function getReportPeers() { // Can also return a different report peer depending on the ID returned by $this->getSelf()... return [self::ADMIN]; } public function onStart(): void { } /** * Handle incoming updates from users, chats and channels. */ #[Handler] public function handleMessage(Incoming&Message $message): void { // Code that uses $message... // See the following pages for more examples and documentation: // - https://github.com/danog/MadelineProto/blob/v8/examples/bot.php // - https://docs.madelineproto.xyz/docs/UPDATES.html // - https://docs.madelineproto.xyz/docs/FILTERS.html // - https://docs.madelineproto.xyz/ } } $MadelineProtos = []; foreach (['session1.madeline', 'session2.madeline', 'session3.madeline'] as $session) { $MadelineProtos []= new API($session); } API::startAndLoopMulti($MadelineProtos, CombinedEventHandler::class);