From cea480019db9586fbc6a099ea7887214b6b4233b Mon Sep 17 00:00:00 2001 From: Andrey Prokopenko Date: Sun, 20 Oct 2024 14:41:17 +0200 Subject: [PATCH] Fix `inline_message_id` field --- telegram-bot-api/src/Telegram/Bot/API/Games.hs | 6 +++--- telegram-bot-api/src/Telegram/Bot/API/InlineMode.hs | 2 +- .../Telegram/Bot/API/Methods/EditMessageLiveLocation.hs | 3 +-- .../Telegram/Bot/API/Methods/StopMessageLiveLocation.hs | 2 +- .../src/Telegram/Bot/API/Types/CallbackQuery.hs | 2 +- telegram-bot-api/src/Telegram/Bot/API/Types/Common.hs | 3 +++ telegram-bot-api/src/Telegram/Bot/API/UpdatingMessages.hs | 8 ++++---- telegram-bot-api/src/Telegram/Bot/API/WebApps.hs | 4 ++-- telegram-bot-simple/src/Telegram/Bot/Simple/Reply.hs | 2 +- 9 files changed, 17 insertions(+), 15 deletions(-) diff --git a/telegram-bot-api/src/Telegram/Bot/API/Games.hs b/telegram-bot-api/src/Telegram/Bot/API/Games.hs index 0b0f3dd..2e92555 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Games.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Games.hs @@ -17,7 +17,7 @@ import Telegram.Bot.API.Internal.Utils (deriveJSON') import Telegram.Bot.API.MakingRequests (Response) import Telegram.Bot.API.Types ( BusinessConnectionId, ChatId, GameHighScore, InlineKeyboardMarkup - , Message, MessageId, MessageThreadId + , InlineMessageId, Message, MessageId, MessageThreadId , ReplyParameters, UserId ) import Telegram.Bot.API.Internal.TH @@ -49,7 +49,7 @@ data SetGameScoreRequest = SetGameScoreRequest , setGameScoreDisableEditMessage :: Maybe Bool -- ^ Pass 'True', if the game message should not be automatically edited to include the current scoreboard. , setGameScoreChatId :: Maybe ChatId -- ^ Required if @inline_message_id@ is not specified. Unique identifier for the target chat , setGameScoreMessageId :: Maybe MessageId -- ^ Required if @inline_message_id@ is not specified. Identifier of the sent message. - , setGameScoreInlineMessageId :: Maybe MessageId -- ^ Required if @chat_id@ and @message_id@ are not specified. Identifier of the inline message. + , setGameScoreInlineMessageId :: Maybe InlineMessageId -- ^ Required if @chat_id@ and @message_id@ are not specified. Identifier of the inline message. } deriving (Generic, Show) @@ -64,7 +64,7 @@ data GetGameHighScoresRequest = GetGameHighScoresRequest { getGameHighScoresUserId :: UserId -- ^ Target user id. , getGameHighScoresChatId :: Maybe ChatId -- ^ Required if @inline_message_id@ is not specified. Unique identifier for the target chat. , getGameHighScoresMessageId :: Maybe MessageId -- ^ Required if @inline_message_id@ is not specified. Identifier of the sent message. - , getGameHighScoresInlineMessageId :: Maybe MessageId -- ^ Required if @chat_id@ and @message_id@ are not specified. Identifier of the inline message. + , getGameHighScoresInlineMessageId :: Maybe InlineMessageId -- ^ Required if @chat_id@ and @message_id@ are not specified. Identifier of the inline message. } deriving (Generic, Show) diff --git a/telegram-bot-api/src/Telegram/Bot/API/InlineMode.hs b/telegram-bot-api/src/Telegram/Bot/API/InlineMode.hs index a952bd6..a7d2bae 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/InlineMode.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/InlineMode.hs @@ -67,7 +67,7 @@ data ChosenInlineResult = ChosenInlineResult { chosenInlineResultResultId :: InlineQueryResultId -- ^ The unique identifier for the result that was chosen. , chosenInlineResultFrom :: User -- ^ The user that chose the result. , chosenInlineResultLocation :: Maybe Location -- ^ Sender location, only for bots that require user location. - , chosenInlineResultInlineMessageId :: Maybe MessageId -- ^ Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. Will be also received in callback queries and can be used to edit the message. + , chosenInlineResultInlineMessageId :: Maybe InlineMessageId -- ^ Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. Will be also received in callback queries and can be used to edit the message. , chosenInlineResultQuery :: InlineQueryId -- ^ The query that was used to obtain the result. } deriving (Generic, Show) diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/EditMessageLiveLocation.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/EditMessageLiveLocation.hs index 201c485..fb6152a 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/EditMessageLiveLocation.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/EditMessageLiveLocation.hs @@ -6,7 +6,6 @@ module Telegram.Bot.API.Methods.EditMessageLiveLocation where import Data.Aeson (FromJSON (..), ToJSON (..)) import Data.Proxy -import Data.Text import GHC.Generics (Generic) import Servant.API import Servant.Client hiding (Response) @@ -22,7 +21,7 @@ import Telegram.Bot.API.Internal.TH data EditMessageLiveLocationRequest = EditMessageLiveLocationRequest { editMessageLiveLocationChatId :: Maybe SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format \@channelusername). , editMessageLiveLocationMessageId :: Maybe MessageId -- ^ Required if inline_message_id is not specified. Identifier of the message with live location to stop. - , editMessageLiveLocationInlineMessageId :: Maybe Text -- ^ Required if chat_id and message_id are not specified. Identifier of the inline message. + , editMessageLiveLocationInlineMessageId :: Maybe InlineMessageId -- ^ Required if chat_id and message_id are not specified. Identifier of the inline message. , editMessageLiveLocationLatitude :: Float -- ^ Latitude of new location. , editMessageLiveLocationLongitude :: Float -- ^ Longitude of new location. , editMessageLiveLocationLivePeriod :: Maybe Int -- ^ New period in seconds during which the location can be updated, starting from the message send date. If @0x7FFFFFFF@ is specified, then the location can be updated forever. Otherwise, the new value must not exceed the current @live_period@ by more than a day, and the live location expiration date must remain within the next 90 days. If not specified, then @live_period@ remains unchanged. diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/StopMessageLiveLocation.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/StopMessageLiveLocation.hs index 9172b56..4ff87b5 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/StopMessageLiveLocation.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/StopMessageLiveLocation.hs @@ -22,7 +22,7 @@ import Telegram.Bot.API.Internal.TH data StopMessageLiveLocationRequest = StopMessageLiveLocationRequest { stopMessageLiveLocationChatId :: Maybe SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername) , stopMessageLiveLocationMessageId :: Maybe MessageId -- ^ Required if inline_message_id is not specified. Identifier of the message with live location to stop - , stopMessageLiveLocationInlineMessageId :: Maybe Text -- ^ Required if chat_id and message_id are not specified. Identifier of the inline message + , stopMessageLiveLocationInlineMessageId :: Maybe InlineMessageId -- ^ Required if chat_id and message_id are not specified. Identifier of the inline message , stopMessageLiveLocationReplyMarkup :: Maybe InlineKeyboardMarkup -- ^ Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. } deriving Generic diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/CallbackQuery.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/CallbackQuery.hs index b04b648..7d6fe72 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/CallbackQuery.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/CallbackQuery.hs @@ -22,7 +22,7 @@ data CallbackQuery = CallbackQuery { callbackQueryId :: CallbackQueryId -- ^ Unique identifier for this query , callbackQueryFrom :: User -- ^ Sender , callbackQueryMessage :: Maybe Message -- ^ Message sent by the bot with the callback button that originated the query. Use 'isInaccessible' to understand whether a message was deleted or is otherwise inaccessible to the bot. - , callbackQueryInlineMessageId :: Maybe MessageId -- ^ Identifier of the message sent via the bot in inline mode, that originated the query. + , callbackQueryInlineMessageId :: Maybe InlineMessageId -- ^ Identifier of the message sent via the bot in inline mode, that originated the query. , callbackQueryChatInstance :: Text -- ^ Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games. , callbackQueryData :: Maybe Text -- ^ Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field. , callbackQueryGameShortName :: Maybe Text -- ^ Short name of a Game to be returned, serves as the unique identifier for the game diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/Common.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/Common.hs index a3cd1e1..d7749a0 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/Common.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/Common.hs @@ -58,6 +58,9 @@ newtype MessageThreadId = MessageThreadId Integer instance ToHttpApiData MessageThreadId where toUrlPiece a = pack . show @Integer $ coerce a +newtype InlineMessageId = InlineMessageId Text + deriving (Eq, Show, ToJSON, FromJSON, Hashable) + -- | The unique identifier of a media message group a message belongs to. newtype MediaGroupId = MediaGroupId Text deriving (Eq, Show, ToJSON, FromJSON) diff --git a/telegram-bot-api/src/Telegram/Bot/API/UpdatingMessages.hs b/telegram-bot-api/src/Telegram/Bot/API/UpdatingMessages.hs index 83c5a8a..a0d1337 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/UpdatingMessages.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/UpdatingMessages.hs @@ -34,7 +34,7 @@ instance FromJSON EditMessageResponse where data EditMessageTextRequest = EditMessageTextRequest { editMessageTextChatId :: Maybe SomeChatId -- ^ Required if 'editMessageTextInlineMessageId' is not specified. Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@). , editMessageTextMessageId :: Maybe MessageId -- ^ Required if 'editMessageTextInlineMessageId' is not specified. Identifier of the sent message. - , editMessageTextInlineMessageId :: Maybe MessageId -- ^ Required if 'editMessageTextChatId' and 'editMessageTextMessageId' are not specified. Identifier of the sent message. + , editMessageTextInlineMessageId :: Maybe InlineMessageId -- ^ Required if 'editMessageTextChatId' and 'editMessageTextMessageId' are not specified. Identifier of the sent message. , editMessageTextText :: Text -- ^ Text of the message to be sent. , editMessageTextParseMode :: Maybe ParseMode -- ^ Send 'MarkdownV2', 'HTML' or 'Markdown' (legacy), if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. , editMessageEntities :: Maybe [MessageEntity] -- ^ A JSON-serialized list of special entities that appear in message text, which can be specified instead of /parse_mode/. @@ -46,7 +46,7 @@ data EditMessageTextRequest = EditMessageTextRequest data EditMessageCaptionRequest = EditMessageCaptionRequest { editMessageCaptionChatId :: Maybe SomeChatId -- ^ Required if 'editMessageCaptionMessageId' is not specified. Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@). , editMessageCaptionMessageId :: Maybe MessageId -- ^ Required if 'editMessageCaptionInlineMessageId' is not specified. Identifier of the sent message. - , editMessageCaptionInlineMessageId :: Maybe MessageId -- ^ Required if 'editMessageCaptionChatId' and 'editMessageCaptionMessageId' are not specified. Identifier of the sent message. + , editMessageCaptionInlineMessageId :: Maybe InlineMessageId -- ^ Required if 'editMessageCaptionChatId' and 'editMessageCaptionMessageId' are not specified. Identifier of the sent message. , editMessageCaptionCaption :: Maybe Text -- ^ New caption of the message, 0-1024 characters after entities parsing , editMessageCaptionParseMode :: Maybe ParseMode -- ^ Mode for parsing entities in the message caption. See formatting options for more details. , editMessageCaptionCaptionEntities :: Maybe [MessageEntity] -- ^ A JSON-serialized list of special entities that appear in the caption, which can be specified instead of @parse_mode@. @@ -58,7 +58,7 @@ data EditMessageCaptionRequest = EditMessageCaptionRequest data EditMessageMediaRequest = EditMessageMediaRequest { editMessageMediaChatId :: Maybe SomeChatId -- ^ Required if 'editMessageMediaMessageId' is not specified. Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@). , editMessageMediaMessageId :: Maybe MessageId -- ^ Required if 'editMessageMediaInlineMessageId' is not specified. Identifier of the sent message. - , editMessageMediaInlineMessageId :: Maybe MessageId -- ^ Required if 'editMessageMediaChatId' and 'editMessageMediaMessageId' are not specified. Identifier of the sent message. + , editMessageMediaInlineMessageId :: Maybe InlineMessageId -- ^ Required if 'editMessageMediaChatId' and 'editMessageMediaMessageId' are not specified. Identifier of the sent message. , editMessageMediaMedia :: InputMedia -- ^ A JSON-serialized object for a new media content of the message , editMessageMediaReplyMarkup :: Maybe SomeReplyMarkup -- ^ Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. } deriving (Generic) @@ -69,7 +69,7 @@ instance ToJSON EditMessageMediaRequest where toJSON = gtoJSON data EditMessageReplyMarkupRequest = EditMessageReplyMarkupRequest { editMessageReplyMarkupChatId :: Maybe SomeChatId -- ^ Required if 'editMessageReplyMarkupMessageId' is not specified. Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@). , editMessageReplyMarkupMessageId :: Maybe MessageId -- ^ Required if 'editMessageReplyMarkupInlineMessageId' is not specified. Identifier of the sent message. - , editMessageReplyMarkupInlineMessageId :: Maybe MessageId -- ^ Required if 'editMessageReplyMarkupChatId' and 'editMessageReplyMarkupMessageId' are not specified. Identifier of the sent message. + , editMessageReplyMarkupInlineMessageId :: Maybe InlineMessageId -- ^ Required if 'editMessageReplyMarkupChatId' and 'editMessageReplyMarkupMessageId' are not specified. Identifier of the sent message. , editMessageReplyMarkupReplyMarkup :: Maybe SomeReplyMarkup -- ^ Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. } deriving (Generic) diff --git a/telegram-bot-api/src/Telegram/Bot/API/WebApps.hs b/telegram-bot-api/src/Telegram/Bot/API/WebApps.hs index 999800d..be035fb 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/WebApps.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/WebApps.hs @@ -15,7 +15,7 @@ import Servant.Client hiding (Response) import Telegram.Bot.API.Internal.Utils (deriveJSON') import Telegram.Bot.API.MakingRequests (Response) -import Telegram.Bot.API.InlineMode (InlineQueryId) +import Telegram.Bot.API.Types.Common (InlineMessageId) import Telegram.Bot.API.InlineMode.InlineQueryResult (InlineQueryResult) import Telegram.Bot.API.Internal.TH (makeDefault) @@ -33,7 +33,7 @@ data AnswerWebAppQueryRequest = AnswerWebAppQueryRequest -- | Contains information about an inline message sent by a Web App on behalf of a user. newtype SentWebAppMessage = SentWebAppMessage - { sentWebAppMessageInlineMessageId :: Maybe InlineQueryId + { sentWebAppMessageInlineMessageId :: Maybe InlineMessageId } deriving (Generic, Show) diff --git a/telegram-bot-simple/src/Telegram/Bot/Simple/Reply.hs b/telegram-bot-simple/src/Telegram/Bot/Simple/Reply.hs index cdacea3..6b4479a 100644 --- a/telegram-bot-simple/src/Telegram/Bot/Simple/Reply.hs +++ b/telegram-bot-simple/src/Telegram/Bot/Simple/Reply.hs @@ -104,7 +104,7 @@ instance IsString EditMessage where data EditMessageId = EditChatMessageId SomeChatId MessageId - | EditInlineMessageId MessageId + | EditInlineMessageId InlineMessageId toEditMessage :: Text -> EditMessage toEditMessage msg = EditMessage msg Nothing Nothing Nothing