From be210c5411d16fe7f063dd86f259d0378369fde0 Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 7 Nov 2024 00:58:58 -0500 Subject: [PATCH] Add AnswerCallbackQuery method to handle callback queries --- src/TgBotLib/Enums/Methods.php | 3 ++ src/TgBotLib/Methods/AnswerCallbackQuery.php | 42 ++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/TgBotLib/Methods/AnswerCallbackQuery.php diff --git a/src/TgBotLib/Enums/Methods.php b/src/TgBotLib/Enums/Methods.php index 8aa6d7f..e515a4f 100644 --- a/src/TgBotLib/Enums/Methods.php +++ b/src/TgBotLib/Enums/Methods.php @@ -5,6 +5,7 @@ use TgBotLib\Bot; use TgBotLib\Exceptions\TelegramException; use TgBotLib\Interfaces\ObjectTypeInterface; + use TgBotLib\Methods\AnswerCallbackQuery; use TgBotLib\Methods\ApproveChatJoinRequest; use TgBotLib\Methods\BanChatMember; use TgBotLib\Methods\BanChatSenderChat; @@ -154,6 +155,7 @@ case HIDE_GENERAL_FORUM_TOPIC = 'hideGeneralForumTopic'; case UNHIDE_GENERAL_FORUM_TOPIC = 'unhideGeneralForumTopic'; case UNPIN_ALL_GENERAL_FORUM_TOPIC_MESSAGES = 'unpinAllGeneralForumTopicMessages'; + case ANSWER_CALLBACK_QUERY = 'answerCallbackQuery'; /** * Executes a command on the provided bot with the given parameters. @@ -240,6 +242,7 @@ self::HIDE_GENERAL_FORUM_TOPIC => HideGeneralForumTopic::execute($bot, $parameters), self::UNHIDE_GENERAL_FORUM_TOPIC => UnhideGeneralForumTopic::execute($bot, $parameters), self::UNPIN_ALL_GENERAL_FORUM_TOPIC_MESSAGES => UnpinAllGeneralForumTopicMessages::execute($bot, $parameters), + self::ANSWER_CALLBACK_QUERY => AnswerCallbackQuery::execute($bot, $parameters), }; } } diff --git a/src/TgBotLib/Methods/AnswerCallbackQuery.php b/src/TgBotLib/Methods/AnswerCallbackQuery.php new file mode 100644 index 0000000..2e544f5 --- /dev/null +++ b/src/TgBotLib/Methods/AnswerCallbackQuery.php @@ -0,0 +1,42 @@ +value, $parameters))); + } + + /** + * @inheritDoc + */ + public static function getRequiredParameters(): ?array + { + return [ + 'callback_query_id' + ]; + } + + /** + * @inheritDoc + */ + public static function getOptionalParameters(): ?array + { + return [ + 'text', + 'show_alert', + 'url', + 'cache_time' + ]; + } + } \ No newline at end of file