Skip to content

Commit

Permalink
Merge pull request #85 from Player-205/master
Browse files Browse the repository at this point in the history
  • Loading branch information
swamp-agr committed Jan 19, 2022
2 parents d848ebe + df2b60e commit 0c9953a
Showing 1 changed file with 91 additions and 2 deletions.
93 changes: 91 additions & 2 deletions src/Telegram/Bot/API/UpdatingMessages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import GHC.Generics (Generic)
import Servant.API
import Servant.Client (ClientM, client)

import Telegram.Bot.API.Internal.Utils (gparseJSON, gtoJSON, deriveJSON' )
import Telegram.Bot.API.Internal.Utils (deriveJSON', gtoJSON)
import Telegram.Bot.API.MakingRequests
import Telegram.Bot.API.Methods
import Telegram.Bot.API.Types
Expand All @@ -29,7 +29,7 @@ type EditMessageText
editMessageText :: EditMessageTextRequest -> ClientM (Response Message)
editMessageText = client (Proxy @EditMessageText)

-- | Request parameters for 'sendMessage'.
-- | Request parameters for 'editMessageText'.
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.
Expand All @@ -40,7 +40,96 @@ data EditMessageTextRequest = EditMessageTextRequest
, editMessageTextReplyMarkup :: 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)

-- | Request parameters for 'editMessageCaption'.
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.
, 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
, editMessageCaptionReplyMarkup :: 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)

type EditMessageCaption = "editMessageCaption"
:> ReqBody '[JSON] EditMessageCaptionRequest
:> Post '[JSON] (Response Message)

-- | Use this method to edit captions of messages.
-- On success, if the edited message is not an
-- inline message, the edited Message is returned,
-- otherwise True is returned.
editMessageCaption :: EditMessageCaptionRequest -> ClientM (Response Message)
editMessageCaption = client (Proxy @EditMessageCaption)

-- | Request parameters for 'editMessageMedia'.
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.
, 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)

instance ToJSON EditMessageMediaRequest where toJSON = gtoJSON

type EditMessageMedia = "editMessageMedia"
:> ReqBody '[JSON] EditMessageMediaRequest
:> Post '[JSON] (Response Message)

-- | Use this method to edit animation, audio,
-- document, photo, or video messages. If a
-- message is part of a message album, then it
-- can be edited only to an audio for audio albums,
-- only to a document for document albums and to a
-- photo or a video otherwise. When an inline message
-- is edited, a new file can't be uploaded; use a
-- previously uploaded file via its file_id or specify a URL.
-- On success, if the edited message is not an inline
-- message, the edited Message is returned, otherwise True is returned.
editMessageMedia :: EditMessageMediaRequest -> ClientM (Response Message)
editMessageMedia = client (Proxy @EditMessageMedia)

-- | Request parameters for 'editMessageReplyMarkup'.
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.
, 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)


type EditMessageReplyMarkup = "editMessageReplyMarkup"
:> ReqBody '[JSON] EditMessageReplyMarkupRequest
:> Post '[JSON] (Response Message)

-- | Use this method to edit only the reply markup of messages.
-- On success, if the edited message is not an inline message,
-- the edited Message is returned, otherwise True is returned.
editMessageReplyMarkup :: EditMessageReplyMarkupRequest -> ClientM (Response Message)
editMessageReplyMarkup = client (Proxy @EditMessageReplyMarkup)

-- | Request parameters for 'stopPoll'.
data StopPollRequest = StopPollRequest
{ stopPollChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername)
, stopPollMessageId :: MessageId -- ^ Identifier of the original message with the poll
, stopPollReplyMarkup :: Maybe SomeReplyMarkup -- ^ A JSON-serialized object for a new message inline keyboard.
} deriving (Generic)


type StopPoll = "stopPoll"
:> ReqBody '[JSON] StopPollRequest
:> Post '[JSON] (Response Poll)

-- | Use this method to stop a poll which was sent by the bot.
-- On success, the stopped Poll is returned.
stopPoll :: StopPollRequest -> ClientM (Response Poll)
stopPoll = client (Proxy @StopPoll)


foldMap deriveJSON'
[ ''EditMessageTextRequest
, ''EditMessageCaptionRequest
, ''EditMessageReplyMarkupRequest
, ''StopPollRequest
]

0 comments on commit 0c9953a

Please sign in to comment.