From 06b57feb9c6a666294ec406ef714d568c395b65c Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 14 Nov 2024 00:29:55 -0500 Subject: [PATCH] Add StopPoll method --- src/TgBotLib/Enums/Methods.php | 3 ++ src/TgBotLib/Methods/StopPoll.php | 55 +++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/TgBotLib/Methods/StopPoll.php diff --git a/src/TgBotLib/Enums/Methods.php b/src/TgBotLib/Enums/Methods.php index c71cdae..5864fc4 100644 --- a/src/TgBotLib/Enums/Methods.php +++ b/src/TgBotLib/Enums/Methods.php @@ -93,6 +93,7 @@ use TgBotLib\Methods\SetMyShortDescription; use TgBotLib\Methods\SetWebhook; use TgBotLib\Methods\StopMessageLiveLocation; + use TgBotLib\Methods\StopPoll; use TgBotLib\Methods\UnbanChatMember; use TgBotLib\Methods\UnbanChatSenderChat; use TgBotLib\Methods\UnhideGeneralForumTopic; @@ -198,6 +199,7 @@ case EDIT_MESSAGE_LIVE_LOCATION = 'editMessageLiveLocation'; case STOP_MESSAGE_LIVE_LOCATION = 'stopMessageLiveLocation'; case EDIT_MESSAGE_REPLY_MARKUP = 'editMessageReplyMarkup'; + case STOP_POLL = 'stopPoll'; /** * Executes a command on the provided bot with the given parameters. @@ -306,6 +308,7 @@ self::EDIT_MESSAGE_LIVE_LOCATION => EditMessageLiveLocation::execute($bot, $parameters), self::STOP_MESSAGE_LIVE_LOCATION => StopMessageLiveLocation::execute($bot, $parameters), self::EDIT_MESSAGE_REPLY_MARKUP => EditMessageReplyMarkup::execute($bot, $parameters), + self::STOP_POLL => StopPoll::execute($bot, $parameters), }; } } diff --git a/src/TgBotLib/Methods/StopPoll.php b/src/TgBotLib/Methods/StopPoll.php new file mode 100644 index 0000000..39287d5 --- /dev/null +++ b/src/TgBotLib/Methods/StopPoll.php @@ -0,0 +1,55 @@ +toArray()); + } + elseif (is_array($parameters['reply_markup'])) + { + $parameters['reply_markup'] = json_encode($parameters['reply_markup']); + } + } + + return Poll::fromArray(self::executeCurl(self::buildPost($bot, Methods::STOP_POLL->value, $parameters))); + } + + /** + * @inheritDoc + */ + public static function getRequiredParameters(): ?array + { + return [ + 'chat_id', + 'message_id' + ]; + } + + /** + * @inheritDoc + */ + public static function getOptionalParameters(): ?array + { + return [ + 'business_connection_id', + 'reply_markup' + ]; + } + } \ No newline at end of file