From e7d950c074967a4135de25e92224ce9c73f4af13 Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Wed, 2 Aug 2023 22:57:27 +0700 Subject: [PATCH 1/7] (#30) update answer callback queries --- src/Models/Event.php | 2 ++ src/Services/AppService.php | 19 ++++++++++ src/Services/EventService.php | 10 ++++-- src/Services/SettingService.php | 59 ++++++++++++++++++++------------ src/Services/TelegramService.php | 6 +--- 5 files changed, 68 insertions(+), 28 deletions(-) diff --git a/src/Models/Event.php b/src/Models/Event.php index 6ccad3e..43195a2 100644 --- a/src/Models/Event.php +++ b/src/Models/Event.php @@ -6,6 +6,8 @@ class Event { public const EVENT_FILE = __DIR__ . '/../../storage/tg-event.json'; + public const EVENT_PREFIX = Setting::SETTING_PREFIX . '.event.'; + public array $eventConfig = []; public function __construct() diff --git a/src/Services/AppService.php b/src/Services/AppService.php index 0544071..e0bfc28 100644 --- a/src/Services/AppService.php +++ b/src/Services/AppService.php @@ -47,4 +47,23 @@ public function sendMessage(string $message = '', array $options = [], string $s error_log($e->getMessage()); } } + + /** + * Send callback response to telegram (show alert) + * + * @param string|null $text + * @return void + */ + public function answerCallbackQuery(string $text = null): void + { + try { + $this->telegram->answerCallbackQuery([ + 'callback_query_id' => $this->telegram->Callback_ID(), + 'text' => $text, + 'show_alert' => true + ]); + } catch (Exception $e) { + error_log($e->getMessage()); + } + } } diff --git a/src/Services/EventService.php b/src/Services/EventService.php index 263e550..e797524 100644 --- a/src/Services/EventService.php +++ b/src/Services/EventService.php @@ -3,15 +3,21 @@ namespace TelegramGithubNotify\App\Services; use Symfony\Component\HttpFoundation\Request; +use TelegramGithubNotify\App\Models\Event; use TelegramGithubNotify\App\Models\Setting; -class EventService +class EventService extends AppService { protected Setting $setting; + protected Event $event; + public function __construct() { + parent::__construct(); + $this->setting = new Setting(); + $this->event = new Event(); } /** @@ -31,7 +37,7 @@ public function validateAccessEvent(Request $request, $payload): bool return true; } - $eventConfig = event_config(); + $eventConfig = $this->event->getEventConfig(); $event = singularity($request->server->get('HTTP_X_GITHUB_EVENT')); $eventConfig = $eventConfig[$event] ?? false; diff --git a/src/Services/SettingService.php b/src/Services/SettingService.php index e2e9985..850eba9 100644 --- a/src/Services/SettingService.php +++ b/src/Services/SettingService.php @@ -22,30 +22,44 @@ public function __construct() */ public function settingHandle(): void { - if ($this->settingConfig['is_notified']) { - $notificationSetting = $this->telegram->buildInlineKeyBoardButton('✅ Github notification', '', $this->setting::SETTING_IS_NOTIFIED); - } else { - $notificationSetting = $this->telegram->buildInlineKeyBoardButton('Github notification', '', $this->setting::SETTING_IS_NOTIFIED); - } - - if ($this->settingConfig['all_events_notify']) { - $eventSetting = $this->telegram->buildInlineKeyBoardButton('✅ Enable All Events Notify', '', $this->setting::SETTING_ALL_EVENTS_NOTIFY); - } else { - $eventSetting = $this->telegram->buildInlineKeyBoardButton('Enable All Events Notify', '', $this->setting::SETTING_ALL_EVENTS_NOTIFY); - } + $this->sendMessage(view('tools.settings'), $this->settingMarkup()); + } + public function settingMarkup(): array + { $keyboard = [ [ - $notificationSetting, - ], [ - $eventSetting, - $this->telegram->buildInlineKeyBoardButton('⚙ Custom individual events', '', $this->setting::SETTING_CUSTOM_EVENTS), - ], [ - $this->telegram->buildInlineKeyBoardButton('🔙 Back to menu', '', 'back.menu'), + $this->telegram->buildInlineKeyBoardButton( + $this->settingConfig['is_notified'] + ? '✅ Github notification' : 'Github notification', + '', + $this->setting::SETTING_IS_NOTIFIED + ), + ], + [ + $this->telegram->buildInlineKeyBoardButton( + $this->settingConfig['all_events_notify'] + ? '✅ Enable All Events Notify' + : 'Enable All Events Notify', + '', + $this->setting::SETTING_ALL_EVENTS_NOTIFY + ), + $this->telegram->buildInlineKeyBoardButton( + '⚙ Custom individual events', + '', + $this->setting::SETTING_CUSTOM_EVENTS + ), + ], + [ + $this->telegram->buildInlineKeyBoardButton( + '🔙 Back to menu', + '', + $this->setting::SETTING_PREFIX . '.back.menu' + ), ] ]; - $this->sendMessage(view('tools.settings'), ['reply_markup' => $keyboard]); + return ['reply_markup' => $keyboard]; } /** @@ -61,8 +75,11 @@ public function settingCallbackHandler(string $callback): void $callback = str_replace($this->setting::SETTING_PREFIX, '', $callback); - $this->updateSetting($callback, !$this->settingConfig[$callback]); - $this->settingHandle(); + if ($this->updateSettingItem($callback, !$this->settingConfig[$callback])) { + $this->settingHandle(); + } else { + $this->answerCallbackQuery('Something went wrong!'); + } } /** @@ -70,7 +87,7 @@ public function settingCallbackHandler(string $callback): void * @param $settingValue * @return bool */ - public function updateSetting(string $settingName, $settingValue = null): bool + public function updateSettingItem(string $settingName, $settingValue = null): bool { $keys = explode('.', $settingName); $lastKey = array_pop($keys); diff --git a/src/Services/TelegramService.php b/src/Services/TelegramService.php index 9c09773..457f6e7 100644 --- a/src/Services/TelegramService.php +++ b/src/Services/TelegramService.php @@ -61,11 +61,7 @@ protected function sendCallbackResponse(string $callback = null): void } if ($callback === 'about') { - $this->telegram->answerCallbackQuery([ - 'callback_query_id' => $this->telegram->Callback_ID(), - 'text' => view('tools.about'), - 'show_alert' => true - ]); + $this->answerCallbackQuery(view('tools.about')); } elseif (str_contains($callback, Setting::SETTING_PREFIX)) { $this->settingService->settingCallbackHandler($callback); } From 920e16a9ebcf36cd6af85ae5658e04db6c2f96fd Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Sun, 6 Aug 2023 11:35:59 +0700 Subject: [PATCH 2/7] (#30) update method access level --- src/Http/Actions/SendNotifyAction.php | 4 ++-- src/Models/Event.php | 2 +- src/Models/Setting.php | 2 +- src/Services/NotificationService.php | 6 +++--- src/Services/SettingService.php | 4 ++-- src/Services/TelegramService.php | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Http/Actions/SendNotifyAction.php b/src/Http/Actions/SendNotifyAction.php index b4f6fdc..dfa4910 100644 --- a/src/Http/Actions/SendNotifyAction.php +++ b/src/Http/Actions/SendNotifyAction.php @@ -56,7 +56,7 @@ public function __invoke(): void * @param string $chatMessageId * @return void */ - public function handleEventInTelegram(string $chatMessageId): void + private function handleEventInTelegram(string $chatMessageId): void { // Send a result to only the bot owner if ($chatMessageId == config('telegram-bot.chat_id')) { @@ -73,7 +73,7 @@ public function handleEventInTelegram(string $chatMessageId): void /** * @return void */ - protected function sendNotification(): void + private function sendNotification(): void { $payload = $this->notificationService->setPayload($this->request); diff --git a/src/Models/Event.php b/src/Models/Event.php index 43195a2..25f735e 100644 --- a/src/Models/Event.php +++ b/src/Models/Event.php @@ -22,7 +22,7 @@ public function __construct() * * @return void */ - public function setEventConfig(): void + private function setEventConfig(): void { $json = file_get_contents(self::EVENT_FILE); $this->eventConfig = json_decode($json, true); diff --git a/src/Models/Setting.php b/src/Models/Setting.php index aed5a59..c1b03f6 100644 --- a/src/Models/Setting.php +++ b/src/Models/Setting.php @@ -25,7 +25,7 @@ public function __construct() * * @return void */ - public function setSettingConfig(): void + private function setSettingConfig(): void { $json = file_get_contents(self::SETTING_FILE); $this->settings = json_decode($json, true); diff --git a/src/Services/NotificationService.php b/src/Services/NotificationService.php index 3d8f63b..e9de10f 100644 --- a/src/Services/NotificationService.php +++ b/src/Services/NotificationService.php @@ -8,9 +8,9 @@ class NotificationService { - public mixed $payload; + protected mixed $payload; - public string $message = ""; + protected string $message = ""; /** * Notify access denied to other chat ids @@ -54,7 +54,7 @@ public function setPayload(Request $request) * @param string $typeEvent * @return void */ - public function setMessage(string $typeEvent): void + private function setMessage(string $typeEvent): void { if (isset($this->payload->action) && !empty($this->payload->action)) { $this->message = view( diff --git a/src/Services/SettingService.php b/src/Services/SettingService.php index 850eba9..a9b91a9 100644 --- a/src/Services/SettingService.php +++ b/src/Services/SettingService.php @@ -6,9 +6,9 @@ class SettingService extends AppService { - public Setting $setting; + protected Setting $setting; - public array $settingConfig = []; + protected array $settingConfig = []; public function __construct() { diff --git a/src/Services/TelegramService.php b/src/Services/TelegramService.php index 457f6e7..708f3ab 100644 --- a/src/Services/TelegramService.php +++ b/src/Services/TelegramService.php @@ -54,7 +54,7 @@ public function telegramToolHandler(string $text = null): void * @param string|null $callback * @return void */ - protected function sendCallbackResponse(string $callback = null): void + private function sendCallbackResponse(string $callback = null): void { if (empty($callback)) { return; @@ -84,7 +84,7 @@ public function checkCallback(): bool /** * @return array[] */ - public function menuMarkup(): array + private function menuMarkup(): array { return [ [ From 49955e56984695f4b80c7f1eeb24ad0acb7484b8 Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Tue, 8 Aug 2023 23:06:27 +0700 Subject: [PATCH 3/7] clean and update methods --- src/Http/Actions/SendNotifyAction.php | 4 ++-- src/Services/AppService.php | 11 +++++------ src/Services/NotificationService.php | 3 +-- src/Services/SettingService.php | 9 +++++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Http/Actions/SendNotifyAction.php b/src/Http/Actions/SendNotifyAction.php index dfa4910..33e9c4a 100644 --- a/src/Http/Actions/SendNotifyAction.php +++ b/src/Http/Actions/SendNotifyAction.php @@ -59,7 +59,7 @@ public function __invoke(): void private function handleEventInTelegram(string $chatMessageId): void { // Send a result to only the bot owner - if ($chatMessageId == config('telegram-bot.chat_id')) { + if ($chatMessageId == $this->telegramService->chatId) { $this->telegramService->telegramToolHandler($this->telegramService->messageData['message']['text']); return; } @@ -77,7 +77,7 @@ private function sendNotification(): void { $payload = $this->notificationService->setPayload($this->request); - if (!$this->eventSettingService->validateAccessEvent($this->request, $payload)) { + if (empty($payload) || !$this->eventSettingService->validateAccessEvent($this->request, $payload)) { return; } diff --git a/src/Services/AppService.php b/src/Services/AppService.php index e0bfc28..982f2a2 100644 --- a/src/Services/AppService.php +++ b/src/Services/AppService.php @@ -9,9 +9,12 @@ class AppService { public Telegram $telegram; + public string $chatId; + public function __construct() { $this->telegram = new Telegram(config('telegram-bot.token')); + $this->chatId = config('telegram-bot.chat_id'); } /** @@ -25,7 +28,7 @@ public function __construct() public function sendMessage(string $message = '', array $options = [], string $sendType = 'Message'): void { $content = array( - 'chat_id' => config('telegram-bot.chat_id'), + 'chat_id' => $this->chatId, 'disable_web_page_preview' => true, 'parse_mode' => 'HTML' ); @@ -38,11 +41,7 @@ public function sendMessage(string $message = '', array $options = [], string $s $content['caption'] = $message; } - if (!empty($options) && isset($options['reply_markup'])) { - $content['reply_markup'] = $this->telegram->buildInlineKeyBoard($options['reply_markup']); - } - - $this->telegram->{'send' . $sendType}($content); + $this->telegram->{'send' . $sendType}(array_merge($content, $options)); } catch (Exception $e) { error_log($e->getMessage()); } diff --git a/src/Services/NotificationService.php b/src/Services/NotificationService.php index e9de10f..fa7aa8f 100644 --- a/src/Services/NotificationService.php +++ b/src/Services/NotificationService.php @@ -38,8 +38,7 @@ public function accessDenied(TelegramService $telegramService, string $chatId = public function setPayload(Request $request) { if (is_null($request->server->get('HTTP_X_GITHUB_EVENT'))) { - echo 'invalid request'; - exit; + return null; } $this->payload = json_decode($request->request->get('payload')); diff --git a/src/Services/SettingService.php b/src/Services/SettingService.php index a9b91a9..58e26b3 100644 --- a/src/Services/SettingService.php +++ b/src/Services/SettingService.php @@ -22,12 +22,15 @@ public function __construct() */ public function settingHandle(): void { - $this->sendMessage(view('tools.settings'), $this->settingMarkup()); + $this->sendMessage( + view('tools.settings'), + ['reply_markup' => $this->settingMarkup()] + ); } public function settingMarkup(): array { - $keyboard = [ + return [ [ $this->telegram->buildInlineKeyBoardButton( $this->settingConfig['is_notified'] @@ -58,8 +61,6 @@ public function settingMarkup(): array ), ] ]; - - return ['reply_markup' => $keyboard]; } /** From 646168158a7867dac7fa050b8f5725e82dc5dbc6 Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Wed, 9 Aug 2023 11:33:43 +0700 Subject: [PATCH 4/7] (#30) create reply markup for events setting --- resources/tools/event.php | 2 ++ src/Services/AppService.php | 6 ++++- src/Services/EventService.php | 46 ++++++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 resources/tools/event.php diff --git a/resources/tools/event.php b/resources/tools/event.php new file mode 100644 index 0000000..aefb6f9 --- /dev/null +++ b/resources/tools/event.php @@ -0,0 +1,2 @@ +Please select an event to enable or disable notifications. +Click and configure child events if have the ⚙ icon diff --git a/src/Services/AppService.php b/src/Services/AppService.php index 982f2a2..941f524 100644 --- a/src/Services/AppService.php +++ b/src/Services/AppService.php @@ -41,7 +41,11 @@ public function sendMessage(string $message = '', array $options = [], string $s $content['caption'] = $message; } - $this->telegram->{'send' . $sendType}(array_merge($content, $options)); + if (!empty($options) && isset($options['reply_markup'])) { + $content['reply_markup'] = $this->telegram->buildInlineKeyBoard($options['reply_markup']); + } + + $this->telegram->{'send' . $sendType}($content); } catch (Exception $e) { error_log($e->getMessage()); } diff --git a/src/Services/EventService.php b/src/Services/EventService.php index e797524..aaefb9b 100644 --- a/src/Services/EventService.php +++ b/src/Services/EventService.php @@ -8,6 +8,8 @@ class EventService extends AppService { + public const LINE_ITEM_COUNT = 2; + protected Setting $setting; protected Event $event; @@ -53,7 +55,49 @@ public function validateAccessEvent(Request $request, $payload): bool return (bool)$eventConfig; } - public function eventHandle() + /** + * @return array + */ + public function eventMarkup(): array + { + $replyMarkup = $replyMarkupItem = []; + + foreach ($this->event->getEventConfig() as $event => $eventValue) { + if (count($replyMarkupItem) === self::LINE_ITEM_COUNT) { + $replyMarkup[] = $replyMarkupItem; + $replyMarkupItem = []; + } + + $callbackData = $this->event::EVENT_PREFIX . $event; + + if (is_array($eventValue)) { + $eventName = '⚙ ' . $event; + $callbackData .= '.child'; + } elseif ($eventValue) { + $eventName = '✅ ' . $event; + } else { + $eventName = '❌ ' . $event; + } + + $replyMarkupItem[] = $this->telegram->buildInlineKeyBoardButton($eventName, '', $callbackData); + } + + // add last item to a reply_markup array + if (count($replyMarkupItem) > 0) { + $replyMarkup[] = $replyMarkupItem; + } + + return $replyMarkup; + } + + /** + * @return void + */ + public function eventHandle(): void { + $this->sendMessage( + view('tools.event'), + ['reply_markup' => $this->eventMarkup()] + ); } } From 5c7f83b00ba3fb60570ae773dd14aaa2d1c0497f Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Wed, 9 Aug 2023 13:45:56 +0700 Subject: [PATCH 5/7] (#30) update event markup for multi events --- resources/tools/event.php | 4 +++- src/Services/EventService.php | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/resources/tools/event.php b/resources/tools/event.php index aefb6f9..a753ea8 100644 --- a/resources/tools/event.php +++ b/resources/tools/event.php @@ -1,2 +1,4 @@ Please select an event to enable or disable notifications. -Click and configure child events if have the ⚙ icon +Click and configure child events if the option has the ⚙ icon. +--- +Please check the GitHub documentation for more information about events. diff --git a/src/Services/EventService.php b/src/Services/EventService.php index aaefb9b..86394e7 100644 --- a/src/Services/EventService.php +++ b/src/Services/EventService.php @@ -56,13 +56,18 @@ public function validateAccessEvent(Request $request, $payload): bool } /** + * Create markup for select event + * + * @param string|null $event * @return array */ - public function eventMarkup(): array + public function eventMarkup(?string $event = null): array { $replyMarkup = $replyMarkupItem = []; - foreach ($this->event->getEventConfig() as $event => $eventValue) { + $events = $event === null ? $this->event->eventConfig : $this->event->eventConfig[$event]; + + foreach ($events as $event => $value) { if (count($replyMarkupItem) === self::LINE_ITEM_COUNT) { $replyMarkup[] = $replyMarkupItem; $replyMarkupItem = []; @@ -70,10 +75,10 @@ public function eventMarkup(): array $callbackData = $this->event::EVENT_PREFIX . $event; - if (is_array($eventValue)) { + if (is_array($value)) { $eventName = '⚙ ' . $event; $callbackData .= '.child'; - } elseif ($eventValue) { + } elseif ($value) { $eventName = '✅ ' . $event; } else { $eventName = '❌ ' . $event; @@ -87,6 +92,9 @@ public function eventMarkup(): array $replyMarkup[] = $replyMarkupItem; } + $replyMarkup[] = [$this->telegram->buildInlineKeyBoardButton('🔙 Back', '', 'back')]; + $replyMarkup[] = [$this->telegram->buildInlineKeyBoardButton('📚 Menu', '', $this->setting::SETTING_PREFIX . '.back.menu')]; + return $replyMarkup; } From 5ced730b0feb2997389ae82fba5755cbe8579a28 Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Wed, 9 Aug 2023 15:27:54 +0700 Subject: [PATCH 6/7] (#30) Edit message from telegram --- src/Services/AppService.php | 31 +++++++++++++++++++++++++++++++ src/Services/SettingService.php | 7 ++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/Services/AppService.php b/src/Services/AppService.php index 941f524..bfeff0e 100644 --- a/src/Services/AppService.php +++ b/src/Services/AppService.php @@ -69,4 +69,35 @@ public function answerCallbackQuery(string $text = null): void error_log($e->getMessage()); } } + + /** + * Edit message from telegram + * + * @param string|null $text + * @param array $options + * @return void + */ + public function editMessageText(?string $text = null, array $options = []): void + { + try { + $content = array( + 'chat_id' => $this->telegram->Callback_ChatID(), + 'message_id' => $this->telegram->MessageID(), + 'disable_web_page_preview' => true, + 'parse_mode' => 'HTML', + ); + + if (!empty($text)) { + $content['text'] = $text; + } + + if (!empty($options) && isset($options['reply_markup'])) { + $content['reply_markup'] = $this->telegram->buildInlineKeyBoard($options['reply_markup']); + } + + $this->telegram->editMessageText($content); + } catch (Exception $e) { + error_log($e->getMessage()); + } + } } diff --git a/src/Services/SettingService.php b/src/Services/SettingService.php index 58e26b3..6119805 100644 --- a/src/Services/SettingService.php +++ b/src/Services/SettingService.php @@ -28,6 +28,9 @@ public function settingHandle(): void ); } + /** + * @return array[] + */ public function settingMarkup(): array { return [ @@ -77,7 +80,9 @@ public function settingCallbackHandler(string $callback): void $callback = str_replace($this->setting::SETTING_PREFIX, '', $callback); if ($this->updateSettingItem($callback, !$this->settingConfig[$callback])) { - $this->settingHandle(); + $this->editMessageText(null, [ + 'reply_markup' => $this->settingMarkup(), + ]); } else { $this->answerCallbackQuery('Something went wrong!'); } From d6e307834bd29b8407f381a2b0059cbd8ffb117d Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Wed, 9 Aug 2023 15:49:11 +0700 Subject: [PATCH 7/7] (#30) Update logic to edit message from telegram --- src/Services/AppService.php | 65 ++++++++++++++++++++++++++------- src/Services/EventService.php | 2 +- src/Services/SettingService.php | 2 +- 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/src/Services/AppService.php b/src/Services/AppService.php index bfeff0e..24a173f 100644 --- a/src/Services/AppService.php +++ b/src/Services/AppService.php @@ -72,6 +72,7 @@ public function answerCallbackQuery(string $text = null): void /** * Edit message from telegram + * (Edit message text and reply markup) * * @param string|null $text * @param array $options @@ -80,24 +81,60 @@ public function answerCallbackQuery(string $text = null): void public function editMessageText(?string $text = null, array $options = []): void { try { - $content = array( - 'chat_id' => $this->telegram->Callback_ChatID(), - 'message_id' => $this->telegram->MessageID(), - 'disable_web_page_preview' => true, - 'parse_mode' => 'HTML', - ); - - if (!empty($text)) { - $content['text'] = $text; - } - - if (!empty($options) && isset($options['reply_markup'])) { - $content['reply_markup'] = $this->telegram->buildInlineKeyBoard($options['reply_markup']); - } + $content = [ + 'text' => $text ?? $this->Callback_Message_Text() + ]; + $content = array_merge($content, $this->setContentEditMessage($options)); $this->telegram->editMessageText($content); } catch (Exception $e) { error_log($e->getMessage()); } } + + /** + * Edit message reply markup from a telegram + * (Edit message reply markup only) + * + * @param array $options + * @return void + */ + public function editMessageReplyMarkup(array $options = []): void + { + try { + $this->telegram->editMessageReplyMarkup($this->setContentEditMessage($options)); + } catch (Exception $e) { + error_log($e->getMessage()); + } + } + + /** + * Get the text from callback message + * + * @return string + */ + public function Callback_Message_Text(): string + { + return $this->telegram->Callback_Message()['text']; + } + + /** + * @param array $options + * @return array + */ + public function setContentEditMessage(array $options = []): array + { + $content = array( + 'chat_id' => $this->telegram->Callback_ChatID(), + 'message_id' => $this->telegram->MessageID(), + 'disable_web_page_preview' => true, + 'parse_mode' => 'HTML', + ); + + if (!empty($options) && isset($options['reply_markup'])) { + $content['reply_markup'] = $this->telegram->buildInlineKeyBoard($options['reply_markup']); + } + + return $content; + } } diff --git a/src/Services/EventService.php b/src/Services/EventService.php index 86394e7..19e3c4c 100644 --- a/src/Services/EventService.php +++ b/src/Services/EventService.php @@ -103,7 +103,7 @@ public function eventMarkup(?string $event = null): array */ public function eventHandle(): void { - $this->sendMessage( + $this->editMessageText( view('tools.event'), ['reply_markup' => $this->eventMarkup()] ); diff --git a/src/Services/SettingService.php b/src/Services/SettingService.php index 6119805..cee797e 100644 --- a/src/Services/SettingService.php +++ b/src/Services/SettingService.php @@ -80,7 +80,7 @@ public function settingCallbackHandler(string $callback): void $callback = str_replace($this->setting::SETTING_PREFIX, '', $callback); if ($this->updateSettingItem($callback, !$this->settingConfig[$callback])) { - $this->editMessageText(null, [ + $this->editMessageReplyMarkup([ 'reply_markup' => $this->settingMarkup(), ]); } else {