diff --git a/config/tg-notifier.php b/config/tg-notifier.php index 8c64192..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,11 +52,13 @@ /** Set the path to the view file */ 'view' => [ - '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', ], 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';