feat: bot
This commit is contained in:
@@ -8,8 +8,8 @@ use SergiX44\Nutgram\Nutgram;
|
||||
use SergiX44\Nutgram\Telegram\Properties\ChatType;
|
||||
|
||||
/**
|
||||
* Allow only the configured owner group/supergroup for the current bot context
|
||||
* (official system chat or the active agent's chat_id).
|
||||
* Allow only the official owner chat or an enabled agent's chat_id.
|
||||
* Binds TelegramBotContext so later handlers know official vs agent.
|
||||
*/
|
||||
class AuthorizedChat
|
||||
{
|
||||
@@ -19,21 +19,11 @@ class AuthorizedChat
|
||||
|
||||
public function __invoke(Nutgram $bot, callable $next): mixed
|
||||
{
|
||||
$expected = $this->context->expectedChatId();
|
||||
if ($expected === '') {
|
||||
Log::warning('telegram AuthorizedChat: chat id empty', [
|
||||
'agent_id' => $this->context->agent()?->id,
|
||||
]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$chatId = $bot->chatId();
|
||||
if ($chatId === null || (string) $chatId !== $expected) {
|
||||
if (! $this->context->bindFromChatId($chatId)) {
|
||||
Log::info('telegram AuthorizedChat: chat rejected', [
|
||||
'chat_id' => $chatId,
|
||||
'expected' => $expected,
|
||||
'agent_id' => $this->context->agent()?->id,
|
||||
'expected_official' => trim((string) config('coruna.telegram.owner_chat_id', '')),
|
||||
]);
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user