From fccb461e34c56b12689c6d750317cc6357e8820c Mon Sep 17 00:00:00 2001 From: netkas Date: Thu, 14 Nov 2024 00:22:17 -0500 Subject: [PATCH] Add EditMessageLiveLocation method --- src/TgBotLib/Enums/Methods.php | 3 + .../Methods/EditMessageLiveLocation.php | 62 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/TgBotLib/Methods/EditMessageLiveLocation.php diff --git a/src/TgBotLib/Enums/Methods.php b/src/TgBotLib/Enums/Methods.php index f3098f9..feb5f58 100644 --- a/src/TgBotLib/Enums/Methods.php +++ b/src/TgBotLib/Enums/Methods.php @@ -28,6 +28,7 @@ use TgBotLib\Methods\EditForumTopic; use TgBotLib\Methods\EditGeneralForumTopic; use TgBotLib\Methods\EditMessageCaption; + use TgBotLib\Methods\EditMessageLiveLocation; use TgBotLib\Methods\EditMessageMedia; use TgBotLib\Methods\EditMessageText; use TgBotLib\Methods\ExportChatInviteLink; @@ -192,6 +193,7 @@ case EDIT_MESSAGE_TEXT = 'editMessageText'; case EDIT_MESSAGE_CAPTION = 'editMessageCaption'; case EDIT_MESSAGE_MEDIA = 'editMessageMedia'; + case EDIT_MESSAGE_LIVE_LOCATION = 'editMessageLiveLocation'; /** * Executes a command on the provided bot with the given parameters. @@ -297,6 +299,7 @@ self::EDIT_MESSAGE_TEXT => EditMessageText::execute($bot, $parameters), self::EDIT_MESSAGE_CAPTION => EditMessageCaption::execute($bot, $parameters), self::EDIT_MESSAGE_MEDIA => EditMessageMedia::execute($bot, $parameters), + self::EDIT_MESSAGE_LIVE_LOCATION => EditMessageLiveLocation::execute($bot, $parameters), }; } } diff --git a/src/TgBotLib/Methods/EditMessageLiveLocation.php b/src/TgBotLib/Methods/EditMessageLiveLocation.php new file mode 100644 index 0000000..5ee1339 --- /dev/null +++ b/src/TgBotLib/Methods/EditMessageLiveLocation.php @@ -0,0 +1,62 @@ +toArray()); + } + elseif (is_array($parameters['reply_markup'])) + { + $parameters['reply_markup'] = json_encode($parameters['reply_markup']); + } + } + + return Message::fromArray(self::executeCurl(self::buildPost($bot, Methods::EDIT_MESSAGE_LIVE_LOCATION->value, $parameters))); + } + + /** + * @inheritDoc + */ + public static function getRequiredParameters(): ?array + { + return [ + 'latitude', + 'longitude', + ]; + } + + /** + * @inheritDoc + */ + public static function getOptionalParameters(): ?array + { + return [ + 'business_connection_id', + 'chat_id', + 'message_id', + 'inline_message_id', + 'live_period', + 'horizontal_accuracy', + 'heading', + 'proximity_alert_radius', + 'reply_markup' + ]; + } + } \ No newline at end of file