From 4ace03c02d52d1716a611e994fa968e013a0543a Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 15 Nov 2024 15:41:59 -0500 Subject: [PATCH] Add AnswerWebAppQuery method --- src/TgBotLib/Enums/Methods.php | 5 +- src/TgBotLib/Methods/AnswerWebAppQuery.php | 53 ++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/TgBotLib/Methods/AnswerWebAppQuery.php diff --git a/src/TgBotLib/Enums/Methods.php b/src/TgBotLib/Enums/Methods.php index 69d7691..577a050 100644 --- a/src/TgBotLib/Enums/Methods.php +++ b/src/TgBotLib/Enums/Methods.php @@ -8,6 +8,7 @@ use TgBotLib\Methods\AddStickerToSet; use TgBotLib\Methods\AnswerCallbackQuery; use TgBotLib\Methods\AnswerInlineQuery; + use TgBotLib\Methods\AnswerWebAppQuery; use TgBotLib\Methods\ApproveChatJoinRequest; use TgBotLib\Methods\BanChatMember; use TgBotLib\Methods\BanChatSenderChat; @@ -235,6 +236,7 @@ case SET_CUSTOM_EMOJI_STICKER_SET_THUMBNAIL = 'setCustomEmojiStickerSetThumbnail'; case DELETE_STICKER_SET = 'deleteStickerSet'; case ANSWER_INLINE_QUERY = 'answerInlineQuery'; + case ANSWER_WEB_APP_QUERY = 'answerWebAppQuery'; /** * Executes a command on the provided bot with the given parameters. @@ -361,7 +363,8 @@ self::SET_STICKER_SET_THUMBNAIL => SetStickerSetThumbnail::execute($bot, $parameters), self::SET_CUSTOM_EMOJI_STICKER_SET_THUMBNAIL => SetCustomEmojiStickerSetThumbnail::execute($bot, $parameters), self::DELETE_STICKER_SET => DeleteStickerFromSet::execute($bot, $parameters), - self::ANSWER_INLINE_QUERY => AnswerInlineQuery::execute($bot, $parameters) + self::ANSWER_INLINE_QUERY => AnswerInlineQuery::execute($bot, $parameters), + self::ANSWER_WEB_APP_QUERY => AnswerWebAppQuery::execute($bot, $parameters), }; } } diff --git a/src/TgBotLib/Methods/AnswerWebAppQuery.php b/src/TgBotLib/Methods/AnswerWebAppQuery.php new file mode 100644 index 0000000..d7ece1f --- /dev/null +++ b/src/TgBotLib/Methods/AnswerWebAppQuery.php @@ -0,0 +1,53 @@ +toArray()); + } + + if(is_array($parameters['result'])) + { + $parameters['result'] = json_encode($parameters['result']); + } + } + + return SentWebAppMessage::fromArray(self::executeCurl(self::buildPost($bot, Methods::ANSWER_WEB_APP_QUERY->value, $parameters))); + } + + /** + * @inheritDoc + */ + public static function getRequiredParameters(): ?array + { + return [ + 'web_app_query_id', + 'result' + ]; + } + + /** + * @inheritDoc + */ + public static function getOptionalParameters(): ?array + { + return null; + } + } \ No newline at end of file