Skip to content

Commit

Permalink
Merge pull request #35 from pxthinh/fix/add_variable_ignore_message
Browse files Browse the repository at this point in the history
fix: add the ignore message config variable
  • Loading branch information
tanhongit authored Dec 3, 2023
2 parents fb9edc3 + 9f3abd3 commit 3ab8b00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 6 additions & 4 deletions config/tg-notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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',
],
Expand Down
4 changes: 4 additions & 0 deletions src/Structures/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 3ab8b00

Please sign in to comment.