26 lines
549 B
PHP
26 lines
549 B
PHP
<?php
|
|
|
|
namespace App\Telegram\Middleware;
|
|
|
|
use App\Telegram\TelegramBotContext;
|
|
use SergiX44\Nutgram\Nutgram;
|
|
|
|
/** Blocks /transfer (and similar) on agent bots. */
|
|
class OfficialOnly
|
|
{
|
|
public function __construct(
|
|
private readonly TelegramBotContext $context,
|
|
) {}
|
|
|
|
public function __invoke(Nutgram $bot, callable $next): mixed
|
|
{
|
|
if (! $this->context->isOfficial()) {
|
|
$bot->sendMessage('⛔ /transfer 仅限官方机器人使用');
|
|
|
|
return null;
|
|
}
|
|
|
|
return $next($bot);
|
|
}
|
|
}
|