diff --git a/app/Http/Controllers/WebHookController.php b/app/Http/Controllers/WebHookController.php index c1963a4e..eef9b2f5 100644 --- a/app/Http/Controllers/WebHookController.php +++ b/app/Http/Controllers/WebHookController.php @@ -32,7 +32,7 @@ public function telegram(Request $request): void TelegramMessage::dispatch( $request->collect('message'), - null, + $captcha, ); } diff --git a/app/Jobs/TelegramMessage.php b/app/Jobs/TelegramMessage.php index 90d9f663..898e0d05 100644 --- a/app/Jobs/TelegramMessage.php +++ b/app/Jobs/TelegramMessage.php @@ -11,6 +11,7 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Cache; class TelegramMessage implements ShouldQueue @@ -26,6 +27,8 @@ class TelegramMessage implements ShouldQueue public $newChatMember; + public $locale; + /** * Create a new job instance. */ @@ -37,6 +40,9 @@ public function __construct(public Collection $message, public ?CaptchaCallback $this->chatId = $this->message->dot()->get('chat.id'); $this->from = $this->message->dot()->get('from.id'); $this->newChatMember = (bool) $this->message->get('new_chat_member'); + + $this->locale = collect(config('telegram.chats')) + ->where('id', $this->chatId)->first ?? config('telegram.default_locale'); } /** @@ -46,6 +52,7 @@ public function handle(TelegramBot $telegramBot): void { // Ban new user without duration and send captcha button if ($this->newChatMember) { + App::setLocale($this->locale); $telegramBot->banUserInGroup($this->chatId, $this->from); $telegramBot->sendWelcomeButton($this->chatId, $this->from, $this->firstName); diff --git a/config/telegram.php b/config/telegram.php new file mode 100644 index 00000000..3a6a9a2c --- /dev/null +++ b/config/telegram.php @@ -0,0 +1,27 @@ + [ + [ + 'id' => '-1002111700088', + 'name' => 'Ахтунг laravel.su чат', + 'locale' => 'en', + ], + [ + 'id' => '-1001300166722', + 'name' => 'Laravel Orchid Russian Community', + 'locale' => 'ru', + ], + [ + 'id' => '-1001450006147', + 'name' => 'Laravel Orchid', + 'locale' => 'en', + ], + [ + 'id' => '-1001104353296', + 'name' => 'Laravel Framework Russian Community', + 'locale' => 'ru', + ], + ], + 'default_locale' => 'ru', +];