From 6f1c3619b8dd0cf3fb6d9fd4f4804e6bfabf2992 Mon Sep 17 00:00:00 2001 From: pxthinh Date: Sun, 3 Dec 2023 00:21:00 +0700 Subject: [PATCH 1/2] fix: add the ignore message config variable --- config/tg-notifier.php | 2 ++ src/Structures/Notification.php | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/config/tg-notifier.php b/config/tg-notifier.php index 8c64192..9053997 100644 --- a/config/tg-notifier.php +++ b/config/tg-notifier.php @@ -52,6 +52,8 @@ /** Set the path to the view file */ 'view' => [ + 'ignore-message' => $_ENV['IGNORE_MESSAGE'] ?? 'ignore-message', + 'namespace' => ($_ENV['TGN_VIEW_NAMESPACE'] ?? 'tg-notifier'), 'path' => $_ENV['TGN_VIEW_PATH'] ?? diff --git a/src/Structures/Notification.php b/src/Structures/Notification.php index 56b10ac..4a6ce37 100644 --- a/src/Structures/Notification.php +++ b/src/Structures/Notification.php @@ -81,6 +81,10 @@ public function sendNotify(string $message = null, array $options = []): bool { $this->message = !empty($message) ? $message : $this->message; + if (trim($this->message) === config('telegram-git-notifier.view.ignore-message')) { + return false; + } + $queryParams = array_merge($this->createTelegramBaseContent(), ['text' => $this->message], $options); $url = 'https://api.telegram.org/bot' . config('telegram-git-notifier.bot.token') . '/sendMessage'; From 9f3abd32672a47277a751680b8cbe5cbad3b71b7 Mon Sep 17 00:00:00 2001 From: Tan Nguyen <35853002+tanhongit@users.noreply.github.com> Date: Sun, 3 Dec 2023 10:39:58 +0700 Subject: [PATCH 2/2] Update tg-notifier.php Remove redundant code in the config Co-authored-by: pxthinh --- config/tg-notifier.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/tg-notifier.php b/config/tg-notifier.php index 9053997..894ca7a 100644 --- a/config/tg-notifier.php +++ b/config/tg-notifier.php @@ -16,12 +16,12 @@ 'chat_id' => $_ENV['TELEGRAM_BOT_CHAT_ID'] ?? '', /** - * Set the chat ids that will receive notifications - * You can add the owner bot id, group id, ... + * Set the chat IDs that will receive notifications + * You can add the owner bot ID, group ID, ... * ------------------------------------------------------- * Note: * Please use semicolon ";" to separate chat ids - * And use colon ":" to separate chat id and thread id + * And use a colon ":" to separate chat ID and thread ID * And use comma "," if you want to add multiple thread ids * ------------------------------------------------------- * The environment variable is expected to be in the format: @@ -52,13 +52,13 @@ /** Set the path to the view file */ 'view' => [ - 'ignore-message' => $_ENV['IGNORE_MESSAGE'] ?? 'ignore-message', - - 'namespace' => ($_ENV['TGN_VIEW_NAMESPACE'] ?? 'tg-notifier'), + 'namespace' => $_ENV['TGN_VIEW_NAMESPACE'] ?? 'tg-notifier', 'path' => $_ENV['TGN_VIEW_PATH'] ?? 'resources/views', + 'ignore-message' => $_ENV['IGNORE_MESSAGE'] ?? 'ignore-message', + 'event' => [ 'default' => $_ENV['TGN_VIEW_EVENT_DEFAULT'] ?? 'default', ],