From 340103553cd9c9a229473bcc2ca8c32741fd48bb Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Sat, 14 Oct 2023 15:20:41 +0700 Subject: [PATCH] feat: check chat id from telegram permission with config --- config/jsons/tg-setting.json | 3 ++- src/Interfaces/TelegramInterface.php | 6 ++++++ src/Services/TelegramService.php | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/config/jsons/tg-setting.json b/config/jsons/tg-setting.json index 5607a90..23c4895 100644 --- a/config/jsons/tg-setting.json +++ b/config/jsons/tg-setting.json @@ -1,4 +1,5 @@ { "is_notified": true, - "all_events_notify": false + "all_events_notify": false, + "command_bot_only": false } diff --git a/src/Interfaces/TelegramInterface.php b/src/Interfaces/TelegramInterface.php index 9b11158..f6d95c4 100644 --- a/src/Interfaces/TelegramInterface.php +++ b/src/Interfaces/TelegramInterface.php @@ -40,4 +40,10 @@ public function isMessage(): bool; * @return bool */ public function isOwner(): bool; + + /** + * Check chat id from telegram permission with config + * @return bool + */ + public function isNotifyChat(): bool; } diff --git a/src/Services/TelegramService.php b/src/Services/TelegramService.php index 3712935..0b8d9c1 100644 --- a/src/Services/TelegramService.php +++ b/src/Services/TelegramService.php @@ -60,4 +60,14 @@ public function isOwner(): bool return false; } + + public function isNotifyChat(): bool + { + $chatIds = config('telegram-git-notifier.bot.notify_chat_ids'); + if (in_array($this->telegram->ChatID(), $chatIds)) { + return true; + } + + return false; + } }