Safe Haskell | None |
---|---|
Language | Haskell2010 |
- getMe :: Token -> IO (Either ServantError GetMeResponse)
- sendMessage :: Token -> SendMessageRequest -> IO (Either ServantError MessageResponse)
- forwardMessage :: Token -> ForwardMessageRequest -> IO (Either ServantError MessageResponse)
- sendPhoto :: Token -> SendPhotoRequest -> IO (Either ServantError MessageResponse)
- sendAudio :: Token -> SendAudioRequest -> IO (Either ServantError MessageResponse)
- sendDocument :: Token -> SendDocumentRequest -> IO (Either ServantError MessageResponse)
- sendSticker :: Token -> SendStickerRequest -> IO (Either ServantError MessageResponse)
- sendVideo :: Token -> SendVideoRequest -> IO (Either ServantError MessageResponse)
- sendVoice :: Token -> SendVoiceRequest -> IO (Either ServantError MessageResponse)
- sendLocation :: Token -> SendLocationRequest -> IO (Either ServantError MessageResponse)
- sendChatAction :: Token -> SendChatActionRequest -> IO (Either ServantError ChatActionResponse)
- getUpdates :: Token -> Maybe Int -> Maybe Int -> Maybe Int -> IO (Either ServantError UpdatesResponse)
- getFile :: Token -> Text -> IO (Either ServantError FileResponse)
- getUserProfilePhotos :: Token -> Int -> Maybe Int -> Maybe Int -> IO (Either ServantError UserProfilePhotosResponse)
- setWebhook :: Token -> Maybe Text -> IO (Either ServantError SetWebhookResponse)
- type TelegramBotAPI = (TelegramToken :> ("getMe" :> Get `[JSON]` GetMeResponse)) :<|> ((TelegramToken :> ("sendMessage" :> (ReqBody `[JSON]` SendMessageRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("forwardMessage" :> (ReqBody `[JSON]` ForwardMessageRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendPhoto" :> (ReqBody `[JSON]` SendPhotoRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendAudio" :> (ReqBody `[JSON]` SendAudioRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendDocument" :> (ReqBody `[JSON]` SendDocumentRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendSticker" :> (ReqBody `[JSON]` SendStickerRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendVideo" :> (ReqBody `[JSON]` SendVideoRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendVoice" :> (ReqBody `[JSON]` SendVoiceRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendLocation" :> (ReqBody `[JSON]` SendLocationRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendChatAction" :> (ReqBody `[JSON]` SendChatActionRequest :> Post `[JSON]` ChatActionResponse))) :<|> ((TelegramToken :> ("getUpdates" :> (QueryParam "offset" Int :> (QueryParam "limit" Int :> (QueryParam "timeout" Int :> Get `[JSON]` UpdatesResponse))))) :<|> ((TelegramToken :> ("getFile" :> (QueryParam "file_id" Text :> Get `[JSON]` FileResponse))) :<|> ((TelegramToken :> ("getUserProfilePhotos" :> (QueryParam "user_id" Int :> (QueryParam "offset" Int :> (QueryParam "limit" Int :> Get `[JSON]` UserProfilePhotosResponse))))) :<|> (TelegramToken :> ("setWebhook" :> (QueryParam "url" Text :> Get `[JSON]` SetWebhookResponse))))))))))))))))
- api :: Proxy TelegramBotAPI
- newtype Token = Token Text
Functions
getMe :: Token -> IO (Either ServantError GetMeResponse) Source
A simple method for testing your bot's auth token. Requires no parameters.
Returns basic information about the bot in form of a User
object.
sendMessage :: Token -> SendMessageRequest -> IO (Either ServantError MessageResponse) Source
Use this method to send text messages. On success, the sent Message
is returned.
forwardMessage :: Token -> ForwardMessageRequest -> IO (Either ServantError MessageResponse) Source
Use this method to forward messages of any kind. On success, the sent Message
is returned.
sendPhoto :: Token -> SendPhotoRequest -> IO (Either ServantError MessageResponse) Source
Use this method to send photos. On success, the sent Message
is returned.
sendAudio :: Token -> SendAudioRequest -> IO (Either ServantError MessageResponse) Source
Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format. On success, the sent Message
is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
For backward compatibility, when the fields title and performer are both empty and the mime-type of the file to be sent is not _audio/mpeg_, the file will be sent as a playable voice message. For this to work, the audio must be in an .ogg file encoded with OPUS. This behavior will be phased out in the future. For sending voice messages, use the sendVoice
method instead.
sendDocument :: Token -> SendDocumentRequest -> IO (Either ServantError MessageResponse) Source
Use this method to send general files. On success, the sent Message
is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
sendSticker :: Token -> SendStickerRequest -> IO (Either ServantError MessageResponse) Source
Use this method to send .webp stickers. On success, the sent Message
is returned.
sendVideo :: Token -> SendVideoRequest -> IO (Either ServantError MessageResponse) Source
sendVoice :: Token -> SendVoiceRequest -> IO (Either ServantError MessageResponse) Source
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio
or Document
). On success, the sent Message
is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
sendLocation :: Token -> SendLocationRequest -> IO (Either ServantError MessageResponse) Source
Use this method to send point on the map. On success, the sent Message
is returned.
sendChatAction :: Token -> SendChatActionRequest -> IO (Either ServantError ChatActionResponse) Source
Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
getUpdates :: Token -> Maybe Int -> Maybe Int -> Maybe Int -> IO (Either ServantError UpdatesResponse) Source
Use this method to receive incoming updates using long polling. An Array of Update
objects is returned.
getFile :: Token -> Text -> IO (Either ServantError FileResponse) Source
getUserProfilePhotos :: Token -> Int -> Maybe Int -> Maybe Int -> IO (Either ServantError UserProfilePhotosResponse) Source
Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos
object.
:: Token | |
-> Maybe Text | HTTPS url to send updates to. Use an empty string to remove webhook integration |
-> IO (Either ServantError SetWebhookResponse) |
Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update
. In case of an unsuccessful request, we will give up after a reasonable amount of attempts.
If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. https://www.example.com/<token>
. Since nobody else knows your bot‘s token, you can be pretty sure it’s us.
API
type TelegramBotAPI = (TelegramToken :> ("getMe" :> Get `[JSON]` GetMeResponse)) :<|> ((TelegramToken :> ("sendMessage" :> (ReqBody `[JSON]` SendMessageRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("forwardMessage" :> (ReqBody `[JSON]` ForwardMessageRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendPhoto" :> (ReqBody `[JSON]` SendPhotoRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendAudio" :> (ReqBody `[JSON]` SendAudioRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendDocument" :> (ReqBody `[JSON]` SendDocumentRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendSticker" :> (ReqBody `[JSON]` SendStickerRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendVideo" :> (ReqBody `[JSON]` SendVideoRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendVoice" :> (ReqBody `[JSON]` SendVoiceRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendLocation" :> (ReqBody `[JSON]` SendLocationRequest :> Post `[JSON]` MessageResponse))) :<|> ((TelegramToken :> ("sendChatAction" :> (ReqBody `[JSON]` SendChatActionRequest :> Post `[JSON]` ChatActionResponse))) :<|> ((TelegramToken :> ("getUpdates" :> (QueryParam "offset" Int :> (QueryParam "limit" Int :> (QueryParam "timeout" Int :> Get `[JSON]` UpdatesResponse))))) :<|> ((TelegramToken :> ("getFile" :> (QueryParam "file_id" Text :> Get `[JSON]` FileResponse))) :<|> ((TelegramToken :> ("getUserProfilePhotos" :> (QueryParam "user_id" Int :> (QueryParam "offset" Int :> (QueryParam "limit" Int :> Get `[JSON]` UserProfilePhotosResponse))))) :<|> (TelegramToken :> ("setWebhook" :> (QueryParam "url" Text :> Get `[JSON]` SetWebhookResponse)))))))))))))))) Source
Telegram Bot API
api :: Proxy TelegramBotAPI Source
Proxy for Thelegram Bot API