From a14cd701d875705abccbadcbe594a9549304012a Mon Sep 17 00:00:00 2001 From: fernanduandrade Date: Sun, 30 Nov 2025 20:33:40 -0300 Subject: [PATCH 1/4] fix: add validation to reply greetins only on the general chat --- .env.example | 1 + app-modules/bot-discord/src/Events/GreetingsEvent.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/.env.example b/.env.example index d4e340f1..cb79e6ec 100644 --- a/.env.example +++ b/.env.example @@ -76,3 +76,4 @@ TWITCH_OAUTH_CLIENT_SECRET= TWITCH_OAUTH_REDIRECT_URI= DISCORD_TOKEN= +DISCORD_GENEREAL_CHAT_ID= \ No newline at end of file diff --git a/app-modules/bot-discord/src/Events/GreetingsEvent.php b/app-modules/bot-discord/src/Events/GreetingsEvent.php index 2bd644d5..df2ec9e6 100644 --- a/app-modules/bot-discord/src/Events/GreetingsEvent.php +++ b/app-modules/bot-discord/src/Events/GreetingsEvent.php @@ -27,6 +27,11 @@ public function handle(Message $message, Discord $discord): void return; } + $allowedChannel = env('DISCORD_GENEREAL_CHAT_ID'); + if ($message->channel_id != $allowedChannel) { + return; + } + $this->logger()->notice(sprintf('%s: %s', $message->author->username, $message->content)); $hour = now()->hour; From 80aa88dcdf642acdcbc3571a812568f283e10a04 Mon Sep 17 00:00:00 2001 From: Luiz Abreu Date: Mon, 1 Dec 2025 08:52:50 -0300 Subject: [PATCH 2/4] fix: add new env variable to config file --- app-modules/bot-discord/src/Events/GreetingsEvent.php | 5 +---- config/services.php | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app-modules/bot-discord/src/Events/GreetingsEvent.php b/app-modules/bot-discord/src/Events/GreetingsEvent.php index df2ec9e6..426e628d 100644 --- a/app-modules/bot-discord/src/Events/GreetingsEvent.php +++ b/app-modules/bot-discord/src/Events/GreetingsEvent.php @@ -27,10 +27,7 @@ public function handle(Message $message, Discord $discord): void return; } - $allowedChannel = env('DISCORD_GENEREAL_CHAT_ID'); - if ($message->channel_id != $allowedChannel) { - return; - } + $allowedChannel = config('services.discord.general_chat_id'); $this->logger()->notice(sprintf('%s: %s', $message->author->username, $message->content)); diff --git a/config/services.php b/config/services.php index 4382bbbf..1cadb5d1 100644 --- a/config/services.php +++ b/config/services.php @@ -39,6 +39,7 @@ 'redirect_uri' => env('DISCORD_OAUTH_REDIRECT_URI', 'https://localhost:8000/auth/oauth/discord'), 'scopes' => env('DISCORD_OAUTH_SCOPES', 'identify email'), 'enabled' => env('DISCORD_OAUTH_ENABLED', true), + 'general_chat_id' => env('DISCORD_GENERAL_CHAT_ID'), ], 'twitch' => [ 'client_id' => env('TWITCH_OAUTH_CLIENT_ID'), From d54441313181e556305122eca0cedc3deed7d2f6 Mon Sep 17 00:00:00 2001 From: Luiz Abreu Date: Mon, 1 Dec 2025 08:58:14 -0300 Subject: [PATCH 3/4] fix: adjust type coercion --- app-modules/bot-discord/src/Events/GreetingsEvent.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app-modules/bot-discord/src/Events/GreetingsEvent.php b/app-modules/bot-discord/src/Events/GreetingsEvent.php index 426e628d..95fa47a1 100644 --- a/app-modules/bot-discord/src/Events/GreetingsEvent.php +++ b/app-modules/bot-discord/src/Events/GreetingsEvent.php @@ -28,6 +28,9 @@ public function handle(Message $message, Discord $discord): void } $allowedChannel = config('services.discord.general_chat_id'); + if ($message->channel_id !== $allowedChannel) { + return; + } $this->logger()->notice(sprintf('%s: %s', $message->author->username, $message->content)); From 42193c923ecb4478c8d4de82a149780264303f4b Mon Sep 17 00:00:00 2001 From: Luiz Abreu Date: Mon, 1 Dec 2025 09:02:55 -0300 Subject: [PATCH 4/4] fix: env type --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index cb79e6ec..0d1d5607 100644 --- a/.env.example +++ b/.env.example @@ -76,4 +76,4 @@ TWITCH_OAUTH_CLIENT_SECRET= TWITCH_OAUTH_REDIRECT_URI= DISCORD_TOKEN= -DISCORD_GENEREAL_CHAT_ID= \ No newline at end of file +DISCORD_GENERAL_CHAT_ID= \ No newline at end of file