~gdanix/telegram-bot-simple

9d8f65b173ff2b9b363cf478c55fc005177f97ae — Pavel Kalugin 3 years ago 4864d1a
Implement forwardMessage API method

Signed-off-by: Pavel Kalugin <paul.kalug@gmail.com>
1 files changed, 21 insertions(+), 1 deletions(-)

M src/Telegram/Bot/API/Methods.hs
M src/Telegram/Bot/API/Methods.hs => src/Telegram/Bot/API/Methods.hs +21 -1
@@ 60,6 60,16 @@ type SendMessage
sendMessage :: SendMessageRequest -> ClientM (Response Message)
sendMessage = client (Proxy @SendMessage)

-- ** 'forwardMessage'
type ForwardMessage
  = "forwardMessage" :> ReqBody '[JSON] ForwardMessageRequest :> Post '[JSON] (Response Message)

-- | Use this method to forward messages of any kind.
-- On success, the sent 'Message' is returned.

forwardMessage :: ForwardMessageRequest -> ClientM (Response Message)
forwardMessage = client (Proxy @ForwardMessage)

-- | Unique identifier for the target chat
-- or username of the target channel (in the format @\@channelusername@).
data SomeChatId


@@ 105,8 115,18 @@ data SendMessageRequest = SendMessageRequest
instance ToJSON   SendMessageRequest where toJSON = gtoJSON
instance FromJSON SendMessageRequest where parseJSON = gparseJSON

-- ** 'sendMessage'
-- | Request parameters for 'forwardMessage'.
data ForwardMessageRequest = ForwardMessageRequest
  { forwardMessageChatId              :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @\@channelusername).
  , forwardMessageFromChatId          :: SomeChatId -- ^ Unique identifier for the chat where the original message was sent (or channel username in the format @\@channelusername)
  , forwardMessageDisableNotification :: Maybe Bool -- ^ Sends the message silently. Users will receive a notification with no sound.
  , forwardMessageMessageId           :: MessageId -- ^ Message identifier in the chat specified in from_chat_id
  } deriving (Generic)

instance ToJSON   ForwardMessageRequest where toJSON = gtoJSON
instance FromJSON ForwardMessageRequest where parseJSON = gparseJSON

-- ** 'sendMessage'
type SendDocumentContent
  = "sendDocument"
  :> MultipartForm Tmp SendDocumentRequest