#!/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; use danog\MadelineProto\Logger; /* * 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'; } /** * Event handler class. */ class MyEventHandler extends EventHandler { /** * @var int|string Username or ID of bot admin */ const ADMIN = "danogentili"; // Change this /** * Get peer(s) where to report errors. * * @return int|string|array */ public function getReportPeers() { return [self::ADMIN]; } /** * Handle updates from supergroups and channels. * * @param array $update Update */ public function onUpdateNewChannelMessage(array $update) { return $this->onUpdateNewMessage($update); } /** * Handle updates from users. * * @param array $update Update */ public function onUpdateNewMessage(array $update): void { if ($update['message']['_'] === 'messageEmpty' || $update['message']['out'] ?? false) { return; } $this->logger($update); } } $MadelineProtos = []; foreach ([ 'session1.madeline' => 'Bot Login', 'session2.madeline' => 'Userbot login', 'session3.madeline' => 'Userbot login (2)', ] as $session => $message) { Logger::log($message, Logger::WARNING); $MadelineProtos []= new API($session); } API::startAndLoopMulti($MadelineProtos, MyEventHandler::class);