telegram-bot-api 6.5 → 6.5.1
raw patch · 72 files changed
+663/−168 lines, 72 files
Files
- CHANGELOG.md +5/−0
- src/Telegram/Bot/API.hs +21/−6
- src/Telegram/Bot/API/Forum.hs +15/−0
- src/Telegram/Bot/API/Games.hs +7/−3
- src/Telegram/Bot/API/GettingUpdates.hs +3/−0
- src/Telegram/Bot/API/InlineMode.hs +4/−1
- src/Telegram/Bot/API/InlineMode/InlineQueryResult.hs +4/−1
- src/Telegram/Bot/API/Internal/TH.hs +102/−0
- src/Telegram/Bot/API/Internal/Utils.hs +1/−13
- src/Telegram/Bot/API/Methods.hs +18/−0
- src/Telegram/Bot/API/Methods/AnswerCallbackQuery.hs +12/−9
- src/Telegram/Bot/API/Methods/BanChatMember.hs +3/−0
- src/Telegram/Bot/API/Methods/CopyMessage.hs +3/−0
- src/Telegram/Bot/API/Methods/CreateChatInviteLink.hs +8/−5
- src/Telegram/Bot/API/Methods/DeleteMyCommands.hs +8/−5
- src/Telegram/Bot/API/Methods/EditChatInviteLink.hs +7/−3
- src/Telegram/Bot/API/Methods/EditMessageLiveLocation.hs +3/−0
- src/Telegram/Bot/API/Methods/ForwardMessage.hs +3/−0
- src/Telegram/Bot/API/Methods/GetChat.hs +4/−4
- src/Telegram/Bot/API/Methods/GetChatAdministrators.hs +5/−5
- src/Telegram/Bot/API/Methods/GetChatMember.hs +1/−1
- src/Telegram/Bot/API/Methods/GetChatMemberCount.hs +1/−1
- src/Telegram/Bot/API/Methods/GetChatMenuButton.hs +3/−0
- src/Telegram/Bot/API/Methods/GetMyCommands.hs +7/−4
- src/Telegram/Bot/API/Methods/GetMyDefaultAdministratorRights.hs +4/−1
- src/Telegram/Bot/API/Methods/GetMyDescription.hs +38/−0
- src/Telegram/Bot/API/Methods/GetMyShortDescription.hs +38/−0
- src/Telegram/Bot/API/Methods/GetUserProfilePhotos.hs +3/−0
- src/Telegram/Bot/API/Methods/LeaveChat.hs +1/−1
- src/Telegram/Bot/API/Methods/PinChatMessage.hs +8/−5
- src/Telegram/Bot/API/Methods/PromoteChatMember.hs +3/−0
- src/Telegram/Bot/API/Methods/RestrictChatMember.hs +3/−0
- src/Telegram/Bot/API/Methods/RevokeChatInviteLink.hs +5/−5
- src/Telegram/Bot/API/Methods/SendAnimation.hs +3/−0
- src/Telegram/Bot/API/Methods/SendAudio.hs +3/−0
- src/Telegram/Bot/API/Methods/SendContact.hs +3/−0
- src/Telegram/Bot/API/Methods/SendDice.hs +3/−0
- src/Telegram/Bot/API/Methods/SendDocument.hs +5/−16
- src/Telegram/Bot/API/Methods/SendLocation.hs +3/−0
- src/Telegram/Bot/API/Methods/SendMediaGroup.hs +3/−0
- src/Telegram/Bot/API/Methods/SendMessage.hs +3/−0
- src/Telegram/Bot/API/Methods/SendPhoto.hs +4/−1
- src/Telegram/Bot/API/Methods/SendPoll.hs +3/−0
- src/Telegram/Bot/API/Methods/SendVenue.hs +3/−0
- src/Telegram/Bot/API/Methods/SendVideo.hs +3/−0
- src/Telegram/Bot/API/Methods/SendVideoNote.hs +3/−0
- src/Telegram/Bot/API/Methods/SendVoice.hs +3/−0
- src/Telegram/Bot/API/Methods/SetChatAdministratorCustomTitle.hs +3/−0
- src/Telegram/Bot/API/Methods/SetChatDescription.hs +5/−5
- src/Telegram/Bot/API/Methods/SetChatMenuButton.hs +3/−0
- src/Telegram/Bot/API/Methods/SetChatPermissions.hs +3/−0
- src/Telegram/Bot/API/Methods/SetChatPhoto.hs +7/−4
- src/Telegram/Bot/API/Methods/SetChatStickerSet.hs +6/−6
- src/Telegram/Bot/API/Methods/SetChatTitle.hs +3/−3
- src/Telegram/Bot/API/Methods/SetMyCommands.hs +6/−3
- src/Telegram/Bot/API/Methods/SetMyDefaultAdministratorRights.hs +3/−0
- src/Telegram/Bot/API/Methods/SetMyDescription.hs +39/−0
- src/Telegram/Bot/API/Methods/SetMyShortDescription.hs +40/−0
- src/Telegram/Bot/API/Methods/StopMessageLiveLocation.hs +3/−0
- src/Telegram/Bot/API/Methods/UnbanChatMember.hs +3/−0
- src/Telegram/Bot/API/Methods/UnpinAllChatMessages.hs +6/−6
- src/Telegram/Bot/API/Methods/UnpinChatMessage.hs +5/−5
- src/Telegram/Bot/API/Payments.hs +9/−2
- src/Telegram/Bot/API/Stickers.hs +48/−39
- src/Telegram/Bot/API/Types.hs +4/−0
- src/Telegram/Bot/API/Types/Audio.hs +1/−1
- src/Telegram/Bot/API/Types/BotDescription.hs +18/−0
- src/Telegram/Bot/API/Types/BotShortDescription.hs +18/−0
- src/Telegram/Bot/API/UpdatingMessages.hs +8/−1
- src/Telegram/Bot/API/WebApps.hs +8/−2
- src/Telegram/Bot/API/Webhook.hs +8/−0
- telegram-bot-api.cabal +10/−1
CHANGELOG.md view
@@ -1,5 +1,10 @@ # telegram-bot-api +## 6.5.1 -- 2023-03-21++- Add new methods `getMyDescription`, `getMyShortDescription`, `setMyDescription`, `setMyShortDescription` (see [#141](https://github.com/fizruk/telegram-bot-simple/pull/141)).+- Re-export Forum, Games, Payments and Stickers in `Telegram.Bot.API.Methods` (see [#143](https://github.com/fizruk/telegram-bot-simple/issues/143).+ ## 6.5 (Telegram Bot API 6.5) - Package was originated at 6.5.
src/Telegram/Bot/API.hs view
@@ -14,9 +14,19 @@ -- * Inline mode module Telegram.Bot.API.InlineMode, -- -- * Payments--- module Telegram.Bot.API.Payments,+ module Telegram.Bot.API.Payments, -- -- * Games--- module Telegram.Bot.API.Games,+ module Telegram.Bot.API.Games,+-- -- * Forum+ module Telegram.Bot.API.Forum,+-- -- * Passport+ module Telegram.Bot.API.Passport,+-- -- * Char+ module Telegram.Bot.API.Chat,+-- -- * Webhook+ module Telegram.Bot.API.Webhook,+-- -- * WebApps+ module Telegram.Bot.API.WebApps, ) where import Telegram.Bot.API.GettingUpdates@@ -24,7 +34,12 @@ import Telegram.Bot.API.Methods import Telegram.Bot.API.Types import Telegram.Bot.API.UpdatingMessages-import Telegram.Bot.API.Stickers-import Telegram.Bot.API.InlineMode--- import Telegram.Bot.API.Payments--- import Telegram.Bot.API.Games+import Telegram.Bot.API.Stickers+import Telegram.Bot.API.InlineMode+import Telegram.Bot.API.Payments+import Telegram.Bot.API.Games+import Telegram.Bot.API.Forum+import Telegram.Bot.API.Passport+import Telegram.Bot.API.Chat+import Telegram.Bot.API.Webhook+import Telegram.Bot.API.WebApps
src/Telegram/Bot/API/Forum.hs view
@@ -20,6 +20,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests (Response) import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'getForumTopicIconStickers' @@ -241,3 +242,17 @@ -- | Use this method to unhide the @General@ topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the @can_manage_topics@ administrator rights. Returns 'True' on success. unhideGeneralForumTopic :: UnhideGeneralForumTopicRequest -> ClientM (Response Bool) unhideGeneralForumTopic = client (Proxy @UnhideGeneralForumTopic)++foldMap makeDefault+ [ ''UnhideGeneralForumTopicRequest+ , ''HideGeneralForumTopicRequest+ , ''ReopenGeneralForumTopicRequest+ , ''CloseGeneralForumTopicRequest+ , ''EditGeneralForumTopicRequest+ , ''UnpinAllForumTopicMessagesRequest+ , ''DeleteForumTopicRequest+ , ''ReopenForumTopicRequest+ , ''CloseForumTopicRequest+ , ''EditForumTopicRequest+ , ''CreateForumTopicRequest+ ]
src/Telegram/Bot/API/Games.hs view
@@ -16,7 +16,7 @@ import Telegram.Bot.API.Internal.Utils (deriveJSON') import Telegram.Bot.API.MakingRequests (Response) import Telegram.Bot.API.Types (ChatId, GameHighScore, InlineKeyboardMarkup, Message, MessageId, MessageThreadId, UserId)-+import Telegram.Bot.API.Internal.TH -- * Types -- ** 'SendGameRequest'@@ -26,7 +26,7 @@ , sendGameMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendGameGameShortName :: Text -- ^ Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather. , sendGameDisableNotification :: Maybe Bool -- ^ Sends the message silently. Users will receive a notification with no sound.- , sendGameProtectContent :: Maybe Bool -- ^ Protects the contents of the sent message from forwarding and saving. + , sendGameProtectContent :: Maybe Bool -- ^ Protects the contents of the sent message from forwarding and saving. , sendGameReplyToMessageId :: Maybe MessageId -- ^ If the message is a reply, ID of the original message. , sendGameAllowSendingWithoutReply :: Maybe Bool -- ^ Pass 'True', if the message should be sent even if the specified replied-to message is not found , sendGameReplyMarkup :: Maybe InlineKeyboardMarkup -- ^ A JSON-serialized object for an inline keyboard. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game.@@ -92,4 +92,8 @@ type GetGameHighScores = "getGameHighScores" :> ReqBody '[JSON] GetGameHighScoresRequest :> Post '[JSON] (Response [GameHighScore]) -+foldMap makeDefault+ [ ''SendGameRequest+ , ''SetGameScoreRequest+ , ''GetGameHighScoresRequest+ ]
src/Telegram/Bot/API/GettingUpdates.hs view
@@ -18,6 +18,7 @@ import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types import Telegram.Bot.API.InlineMode+import Telegram.Bot.API.Internal.TH (makeDefault) -- ** 'Update' @@ -102,3 +103,5 @@ instance ToJSON UpdateType where toJSON = gtoJSON instance FromJSON UpdateType where parseJSON = gparseJSON++makeDefault ''GetUpdatesRequest
src/Telegram/Bot/API/InlineMode.hs view
@@ -20,6 +20,7 @@ import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types import Telegram.Bot.API.InlineMode.InlineQueryResult+import Telegram.Bot.API.Internal.TH (makeDefault) -- * Available types -- ** User@@ -58,7 +59,7 @@ , answerInlineQueryNextOffset :: Maybe Text -- ^ Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes. , answerInlineQuerySwitchPmText :: Maybe Text -- ^ If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter. , answerInlineQuerySwitchPmParameter :: Maybe Text -- ^ Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.--- +-- -- Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities. } deriving (Generic) @@ -77,3 +78,5 @@ instance FromJSON ChosenInlineResult where parseJSON = gparseJSON deriveJSON' ''InlineQuery++makeDefault ''AnswerInlineQueryRequest
src/Telegram/Bot/API/InlineMode/InlineQueryResult.hs view
@@ -11,10 +11,11 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.Types (Contact) import Telegram.Bot.API.InlineMode.InputMessageContent+import Telegram.Bot.API.Internal.TH (makeDefault) -- | This object represents one result of an inline query data InlineQueryResult = InlineQueryResult- { inlineQueryResultType :: InlineQueryResultType -- ^ Type of the result+ { inlineQueryResultType :: InlineQueryResultType -- ^ Type of the result , inlineQueryResultId :: InlineQueryResultId -- ^ Unique identifier for this result, 1-64 Bytes , inlineQueryResultTitle :: Maybe Text -- ^ Title of the result (only valid for "Article", "Photo", "Gif", "Mpeg4Gif", "Video", "Audio", "Voice", "Document", "Location", "Venue", "CachedPhoto", "CachedGif", "CachedMpeg4Gif", "CachedDocument", "CachedVideo", "CachedVoice" types of results) , inlineQueryResultInputMessageContent :: Maybe InputMessageContent@@ -77,3 +78,5 @@ toJSON = String . getType instance FromJSON InlineQueryResultType where parseJSON = gparseJSON++makeDefault ''InlineQueryResult
+ src/Telegram/Bot/API/Internal/TH.hs view
@@ -0,0 +1,102 @@+{-# LANGUAGE BlockArguments #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE CPP #-}+{-# OPTIONS_GHC -Wno-unused-imports #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}++module Telegram.Bot.API.Internal.TH (makeDefault) where++import Language.Haskell.TH+import Control.Monad.State+import Data.Maybe (catMaybes)+import Control.Applicative(liftA2)++makeDefault :: Name -> Q [Dec]+makeDefault typeN = do+ info <- reify typeN+ case info of+ TyConI dec -> case dec of+ -- no sence to handle other declarations+ DataD _ _ _ _ [con] _ | Just x <- getConInfo con -> makeDefaultFromCon x+ NewtypeD _ _ _ _ con _ | Just x <- getConInfo con -> makeDefaultFromCon x+ _ -> error "declaration not supported"+ _ -> error "not a type constructor name"+ where+ defName = constructDefName typeN+ defNameP = varP defName++ makeDefaultFromCon (conN, tys) = let+ type' = constructType typeN tys+ expr = construcExpr conN tys+ -- ghc disallows quote of form [d| $name :: some type |]+ sig = pure <$> sigD defName type'++ in sig <> [d|+ $defNameP = $expr+ |]++constructDefName :: Name -> Name+constructDefName typeN = mkName ("def" <> trimReq typeStr)+ where+ typeStr = nameBase typeN++ trimReq "Request" = []+ trimReq (x:xs) = x : trimReq xs+ trimReq [] = []+++construcExpr :: Name -> [Type] -> Q Exp+construcExpr conN tys = let+ mVars = flip evalState 0 $ traverse+ (\ty -> if isMaybeTy ty then pure Nothing else Just <$> newNameI)+ tys++ vars = catMaybes mVars++ argExps = map (\case+ Nothing -> conE 'Nothing+ Just na -> varE na) mVars++ in lamE (map varP vars) (foldl appE (conE conN) argExps)++constructType :: Name -> [Type] -> Q Type+constructType typeN tys = foldr arrAp baseTy (filter (not . isMaybeTy) tys)+ where+ baseTy = conT typeN+ arrAp a b = appT (appT arrowT (pure a)) b+++-- Predicates over TH++getConInfo :: Con -> Maybe (Name, [Type])+getConInfo (NormalC name tys) = Just (name, map snd tys)+getConInfo (RecC name tys) = Just (name, map (\(_,_,x) -> x) tys)+getConInfo _= Nothing++isMaybeTy :: Type -> Bool+isMaybeTy (AppT (ConT m) _) = m == ''Maybe+isMaybeTy _ = False++-- State heplers++newInd :: State Int Int+newInd = do+ x <- get+ modify (+1)+ pure x++newNameI :: State Int Name+newNameI = do+ i <- newInd+ pure $ mkName ("a" <> show i)++-- Instance Monoid for TH of ghc < 8.6+#if !MIN_VERSION_template_haskell(2,17,0)++instance Semigroup a => Semigroup (Q a) where+ (<>) = liftA2 (<>)++instance Monoid a => Monoid (Q a) where+ mempty = pure mempty++#endif
src/Telegram/Bot/API/Internal/Utils.hs view
@@ -6,7 +6,6 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE CPP #-}-{-# OPTIONS_GHC -fno-warn-orphans #-} module Telegram.Bot.API.Internal.Utils where import Control.Applicative ((<|>))@@ -17,8 +16,8 @@ import Data.List (intercalate) import GHC.Generics import Language.Haskell.TH-import Control.Applicative (liftA2) import Servant.Multipart.API (MultipartData(MultipartData), Input)+import Telegram.Bot.API.Internal.TH () #if MIN_VERSION_aeson(2,0,0) import qualified Data.Aeson.KeyMap as Map@@ -113,14 +112,3 @@ addMultipartFields :: [Input] -> MultipartData tag -> MultipartData tag addMultipartFields newFields (MultipartData currenFields files) = MultipartData (newFields <> currenFields) files---- Instance Monoid for TH of ghc < 8.6-#if !MIN_VERSION_template_haskell(2,17,0)--instance Semigroup a => Semigroup (Q a) where- (<>) = liftA2 (<>)--instance Monoid a => Monoid (Q a) where- mempty = pure mempty--#endif
src/Telegram/Bot/API/Methods.hs view
@@ -37,6 +37,8 @@ , module Telegram.Bot.API.Methods.GetMe , module Telegram.Bot.API.Methods.GetMyCommands , module Telegram.Bot.API.Methods.GetMyDefaultAdministratorRights+ , module Telegram.Bot.API.Methods.GetMyDescription+ , module Telegram.Bot.API.Methods.GetMyShortDescription , module Telegram.Bot.API.Methods.GetUserProfilePhotos , module Telegram.Bot.API.Methods.LeaveChat , module Telegram.Bot.API.Methods.PinChatMessage@@ -67,11 +69,18 @@ , module Telegram.Bot.API.Methods.SetChatTitle , module Telegram.Bot.API.Methods.SetMyCommands , module Telegram.Bot.API.Methods.SetMyDefaultAdministratorRights+ , module Telegram.Bot.API.Methods.SetMyDescription+ , module Telegram.Bot.API.Methods.SetMyShortDescription , module Telegram.Bot.API.Methods.StopMessageLiveLocation , module Telegram.Bot.API.Methods.UnbanChatMember , module Telegram.Bot.API.Methods.UnbanChatSenderChat , module Telegram.Bot.API.Methods.UnpinAllChatMessages , module Telegram.Bot.API.Methods.UnpinChatMessage++ , module Telegram.Bot.API.Forum+ , module Telegram.Bot.API.Games+ , module Telegram.Bot.API.Payments+ , module Telegram.Bot.API.WebApps ) where import Telegram.Bot.API.Types.ParseMode@@ -101,6 +110,8 @@ import Telegram.Bot.API.Methods.GetMe import Telegram.Bot.API.Methods.GetMyCommands import Telegram.Bot.API.Methods.GetMyDefaultAdministratorRights+import Telegram.Bot.API.Methods.GetMyDescription+import Telegram.Bot.API.Methods.GetMyShortDescription import Telegram.Bot.API.Methods.GetUserProfilePhotos import Telegram.Bot.API.Methods.LeaveChat import Telegram.Bot.API.Methods.PinChatMessage@@ -131,8 +142,15 @@ import Telegram.Bot.API.Methods.SetChatTitle import Telegram.Bot.API.Methods.SetMyCommands import Telegram.Bot.API.Methods.SetMyDefaultAdministratorRights+import Telegram.Bot.API.Methods.SetMyDescription+import Telegram.Bot.API.Methods.SetMyShortDescription import Telegram.Bot.API.Methods.StopMessageLiveLocation import Telegram.Bot.API.Methods.UnbanChatMember import Telegram.Bot.API.Methods.UnbanChatSenderChat import Telegram.Bot.API.Methods.UnpinAllChatMessages import Telegram.Bot.API.Methods.UnpinChatMessage++import Telegram.Bot.API.Forum+import Telegram.Bot.API.Games+import Telegram.Bot.API.Payments+import Telegram.Bot.API.WebApps
src/Telegram/Bot/API/Methods/AnswerCallbackQuery.hs view
@@ -12,6 +12,7 @@ import Servant.Client hiding (Response) import Telegram.Bot.API.Internal.Utils+import Telegram.Bot.API.Internal.TH import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types @@ -37,17 +38,19 @@ :> ReqBody '[JSON] AnswerCallbackQueryRequest :> Post '[JSON] (Response Bool) --- | Use this method to send answers to callback --- queries sent from inline keyboards. The answer --- will be displayed to the user as a notification --- at the top of the chat screen or as an alert. +-- | Use this method to send answers to callback+-- queries sent from inline keyboards. The answer+-- will be displayed to the user as a notification+-- at the top of the chat screen or as an alert. -- On success, True is returned. ----- Alternatively, the user can be redirected to --- the specified Game URL. For this option to work, --- you must first create a game for your bot via --- @Botfather and accept the terms. Otherwise, you --- may use links like t.me/your_bot?start=XXXX that +-- Alternatively, the user can be redirected to+-- the specified Game URL. For this option to work,+-- you must first create a game for your bot via+-- @Botfather and accept the terms. Otherwise, you+-- may use links like t.me/your_bot?start=XXXX that -- open your bot with a parameter. answerCallbackQuery :: AnswerCallbackQueryRequest -> ClientM (Response Bool) answerCallbackQuery = client (Proxy @AnswerCallbackQuery)++makeDefault ''AnswerCallbackQueryRequest
src/Telegram/Bot/API/Methods/BanChatMember.hs view
@@ -13,6 +13,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'banChatMember' @@ -44,3 +45,5 @@ -- Returns True on success. banChatMember :: BanChatMemberRequest -> ClientM (Response Bool) banChatMember = client (Proxy @BanChatMember)++makeDefault ''BanChatMemberRequest
src/Telegram/Bot/API/Methods/CopyMessage.hs view
@@ -15,6 +15,7 @@ import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types import Telegram.Bot.API.Types.ParseMode+import Telegram.Bot.API.Internal.TH -- ** 'copyMessage' @@ -51,3 +52,5 @@ instance ToJSON CopyMessageRequest where toJSON = gtoJSON instance FromJSON CopyMessageRequest where parseJSON = gparseJSON++makeDefault ''CopyMessageRequest
src/Telegram/Bot/API/Methods/CreateChatInviteLink.hs view
@@ -14,6 +14,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'createChatInviteLink' @@ -35,11 +36,13 @@ :> Post '[JSON] (Response ChatInviteLink) -- | Use this method to create an additional--- invite link for a chat. The bot must be --- an administrator in the chat for this to --- work and must have the appropriate administrator --- rights. The link can be revoked using the --- method revokeChatInviteLink. +-- invite link for a chat. The bot must be+-- an administrator in the chat for this to+-- work and must have the appropriate administrator+-- rights. The link can be revoked using the+-- method revokeChatInviteLink. -- Returns the new invite link as ChatInviteLink object. createChatInviteLink :: CreateChatInviteLinkRequest -> ClientM (Response ChatInviteLink) createChatInviteLink = client (Proxy @CreateChatInviteLink)++makeDefault ''CreateChatInviteLinkRequest
src/Telegram/Bot/API/Methods/DeleteMyCommands.hs view
@@ -14,12 +14,13 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'deleteMyCommands' -- | Request parameters for 'deleteMyCommands'. data DeleteMyCommandsRequest = DeleteMyCommandsRequest- { deleteMyCommandsScope :: Maybe BotCommandScope -- ^ A JSON-serialized object, describing scope of users. Defaults to BotCommandScopeDefault. + { deleteMyCommandsScope :: Maybe BotCommandScope -- ^ A JSON-serialized object, describing scope of users. Defaults to BotCommandScopeDefault. , deleteMyCommandsLanguageCode :: Maybe Text -- ^ A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands } deriving Generic@@ -31,10 +32,12 @@ :> ReqBody '[JSON] DeleteMyCommandsRequest :> Post '[JSON] (Response Bool) --- | Use this method to delete the list of --- the bot's commands for the given scope --- and user language. After deletion, higher --- level commands will be shown to affected users. +-- | Use this method to delete the list of+-- the bot's commands for the given scope+-- and user language. After deletion, higher+-- level commands will be shown to affected users. -- Returns True on success. deleteMyCommands :: DeleteMyCommandsRequest -> ClientM (Response Bool) deleteMyCommands = client (Proxy @DeleteMyCommands)++makeDefault ''DeleteMyCommandsRequest
src/Telegram/Bot/API/Methods/EditChatInviteLink.hs view
@@ -14,6 +14,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'editChatInviteLink' @@ -36,10 +37,13 @@ :> Post '[JSON] (Response ChatInviteLink) -- | Use this method to edit a non-primary--- invite link created by the bot. The --- bot must be an administrator in the --- chat for this to work and must have +-- invite link created by the bot. The+-- bot must be an administrator in the+-- chat for this to work and must have -- the appropriate administrator rights. -- Returns the edited invite link as a ChatInviteLink object. editChatInviteLink :: EditChatInviteLinkRequest -> ClientM (Response ChatInviteLink) editChatInviteLink = client (Proxy @EditChatInviteLink)+++makeDefault ''EditChatInviteLinkRequest
src/Telegram/Bot/API/Methods/EditMessageLiveLocation.hs view
@@ -14,6 +14,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'editMessageLiveLocation' @@ -46,3 +47,5 @@ -- edited Message is returned, otherwise True is returned. editMessageLiveLocation :: EditMessageLiveLocationRequest -> ClientM (Response (Either Bool Message)) editMessageLiveLocation = client (Proxy @EditMessageLiveLocation)++makeDefault ''EditMessageLiveLocationRequest
src/Telegram/Bot/API/Methods/ForwardMessage.hs view
@@ -13,6 +13,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'forwardMessage' @@ -38,3 +39,5 @@ instance ToJSON ForwardMessageRequest where toJSON = gtoJSON instance FromJSON ForwardMessageRequest where parseJSON = gparseJSON++makeDefault ''ForwardMessageRequest
src/Telegram/Bot/API/Methods/GetChat.hs view
@@ -16,10 +16,10 @@ :> RequiredQueryParam "chat_id" SomeChatId :> Post '[JSON] (Response Chat) --- | Use this method to get up to date information --- about the chat (current name of the user for --- one-on-one conversations, current username of --- a user, group or channel, etc.). +-- | Use this method to get up to date information+-- about the chat (current name of the user for+-- one-on-one conversations, current username of+-- a user, group or channel, etc.). -- Returns a Chat object on success. getChat :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) -> ClientM (Response Chat)
src/Telegram/Bot/API/Methods/GetChatAdministrators.hs view
@@ -18,11 +18,11 @@ :> Post '[JSON] (Response [ChatMember]) -- | Use this method to get a list of administrators--- in a chat. On success, returns an Array of --- ChatMember objects that contains information --- about all chat administrators except other bots. --- If the chat is a group or a supergroup and no --- administrators were appointed, only the creator +-- in a chat. On success, returns an Array of+-- ChatMember objects that contains information+-- about all chat administrators except other bots.+-- If the chat is a group or a supergroup and no+-- administrators were appointed, only the creator -- will be returned. getChatAdministrators :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) -> ClientM (Response [ChatMember])
src/Telegram/Bot/API/Methods/GetChatMember.hs view
@@ -17,7 +17,7 @@ :> RequiredQueryParam "user_id" UserId :> Post '[JSON] (Response ChatMember) --- | Use this method to get information about a member of a chat. +-- | Use this method to get information about a member of a chat. -- Returns a ChatMember object on success. getChatMember :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) -> UserId -- ^ Unique identifier of the target user
src/Telegram/Bot/API/Methods/GetChatMemberCount.hs view
@@ -16,7 +16,7 @@ :> RequiredQueryParam "chat_id" SomeChatId :> Post '[JSON] (Response Integer) --- | Use this method to get the number of members in a chat. +-- | Use this method to get the number of members in a chat. -- Returns Int on success. getChatMemberCount :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) -> ClientM (Response Integer)
src/Telegram/Bot/API/Methods/GetChatMenuButton.hs view
@@ -13,6 +13,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'getChatMenuButton' @@ -34,3 +35,5 @@ -- Returns @MenuButton@ on success. getChatMenuButton :: GetChatMenuButtonRequest -> ClientM (Response MenuButton) getChatMenuButton = client (Proxy @GetChatMenuButton)++makeDefault ''GetChatMenuButtonRequest
src/Telegram/Bot/API/Methods/GetMyCommands.hs view
@@ -14,12 +14,13 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'getMyCommands' -- | Request parameters for 'getMyCommands'. data GetMyCommandsRequest = GetMyCommandsRequest- { getMyCommandsScope :: Maybe BotCommandScope -- ^ A JSON-serialized object, describing scope of users. Defaults to BotCommandScopeDefault. + { getMyCommandsScope :: Maybe BotCommandScope -- ^ A JSON-serialized object, describing scope of users. Defaults to BotCommandScopeDefault. , getMyCommandsLanguageCode :: Maybe Text -- ^ A two-letter ISO 639-1 language code or an empty string } deriving Generic@@ -32,9 +33,11 @@ :> Post '[JSON] (Response [BotCommand]) -- | Use this method to get the current list--- of the bot's commands for the given scope --- and user language. Returns Array of BotCommand --- on success. If commands aren't set, an empty list +-- of the bot's commands for the given scope+-- and user language. Returns Array of BotCommand+-- on success. If commands aren't set, an empty list -- is returned. getMyCommands :: GetMyCommandsRequest -> ClientM (Response [BotCommand]) getMyCommands = client (Proxy @GetMyCommands)++makeDefault ''GetMyCommandsRequest
src/Telegram/Bot/API/Methods/GetMyDefaultAdministratorRights.hs view
@@ -13,11 +13,12 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'getMyDefaultAdministratorRights' -- | Request parameters for 'getMyDefaultAdministratorRights'.-data GetMyDefaultAdministratorRightsRequest = GetMyDefaultAdministratorRightsRequest+newtype GetMyDefaultAdministratorRightsRequest = GetMyDefaultAdministratorRightsRequest { getMyDefaultAdministratorRightsRequestForChannels :: Maybe Bool -- ^ Pass 'True' to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned. } deriving Generic@@ -34,3 +35,5 @@ getMyDefaultAdministratorRights :: GetMyDefaultAdministratorRightsRequest -> ClientM (Response ChatAdministratorRights) getMyDefaultAdministratorRights = client (Proxy @GetMyDefaultAdministratorRights)++makeDefault ''GetMyDefaultAdministratorRightsRequest
+ src/Telegram/Bot/API/Methods/GetMyDescription.hs view
@@ -0,0 +1,38 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeOperators #-}+module Telegram.Bot.API.Methods.GetMyDescription where++import Data.Aeson (FromJSON (..), ToJSON (..))+import Data.Proxy+import GHC.Generics (Generic)+import Data.Text (Text)+import Servant.API+import Servant.Client hiding (Response)++import Telegram.Bot.API.Internal.Utils+import Telegram.Bot.API.MakingRequests+import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH++-- ** 'GetMyDescription'++newtype GetMyDescriptionRequest = GetMyDescriptionRequest+ { getMyDescriptionLanguageCode :: Maybe Text -- ^ A two-letter ISO 639-1 language code or an empty string.+ }+ deriving Generic++instance ToJSON GetMyDescriptionRequest where toJSON = gtoJSON+instance FromJSON GetMyDescriptionRequest where parseJSON = gparseJSON++type GetMyDescription = "getMyDescription"+ :> ReqBody '[JSON] GetMyDescriptionRequest+ :> Post '[JSON] (Response BotDescription)++-- | Use this method to get the current bot description for the given user language.+-- Returns 'BotDescription' on success.+getMyDescription :: GetMyDescriptionRequest -> ClientM (Response BotDescription)+getMyDescription = client (Proxy @GetMyDescription)++makeDefault ''GetMyDescriptionRequest
+ src/Telegram/Bot/API/Methods/GetMyShortDescription.hs view
@@ -0,0 +1,38 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeOperators #-}+module Telegram.Bot.API.Methods.GetMyShortDescription where++import Data.Aeson (FromJSON (..), ToJSON (..))+import Data.Proxy+import GHC.Generics (Generic)+import Data.Text (Text)+import Servant.API+import Servant.Client hiding (Response)++import Telegram.Bot.API.Internal.Utils+import Telegram.Bot.API.MakingRequests+import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH++-- ** 'GetMyShortDescription'++newtype GetMyShortDescriptionRequest = GetMyShortDescriptionRequest+ { getMyShortDescriptionLanguageCode :: Maybe Text -- ^ A two-letter ISO 639-1 language code or an empty string.+ }+ deriving Generic++instance ToJSON GetMyShortDescriptionRequest where toJSON = gtoJSON+instance FromJSON GetMyShortDescriptionRequest where parseJSON = gparseJSON++type GetMyShortDescription = "getMyShortDescription"+ :> ReqBody '[JSON] GetMyShortDescriptionRequest+ :> Post '[JSON] (Response BotShortDescription)++-- | Use this method to get the current bot short description for the given user language.+-- Returns 'BotShortDescription' on success.+getMyShortDescription :: GetMyShortDescriptionRequest -> ClientM (Response BotShortDescription)+getMyShortDescription = client (Proxy @GetMyShortDescription)++makeDefault ''GetMyShortDescriptionRequest
src/Telegram/Bot/API/Methods/GetUserProfilePhotos.hs view
@@ -13,6 +13,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'getUserProfilePhotos' @@ -35,3 +36,5 @@ -- Returns a UserProfilePhotos object. getUserProfilePhotos :: GetUserProfilePhotosRequest -> ClientM (Response UserProfilePhotos) getUserProfilePhotos = client (Proxy @GetUserProfilePhotos)++makeDefault ''GetUserProfilePhotosRequest
src/Telegram/Bot/API/Methods/LeaveChat.hs view
@@ -16,7 +16,7 @@ :> RequiredQueryParam "chat_id" SomeChatId :> Post '[JSON] (Response Bool) --- | Use this method for your bot to leave a group, supergroup or channel. +-- | Use this method for your bot to leave a group, supergroup or channel. -- Returns True on success. leaveChat :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) -> ClientM (Response Bool)
src/Telegram/Bot/API/Methods/PinChatMessage.hs view
@@ -13,6 +13,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'pinChatMessage' @@ -31,12 +32,14 @@ :> ReqBody '[JSON] PinChatMessageRequest :> Post '[JSON] (Response Bool) --- | Use this method to add a message to the list --- of pinned messages in a chat. If the chat is --- not a private chat, the bot must be an administrator --- in the chat for this to work and must have the +-- | Use this method to add a message to the list+-- of pinned messages in a chat. If the chat is+-- not a private chat, the bot must be an administrator+-- in the chat for this to work and must have the -- 'can_pin_messages' administrator right in a supergroup--- or 'can_edit_messages' administrator right in a channel. +-- or 'can_edit_messages' administrator right in a channel. -- Returns True on success. pinChatMessage :: PinChatMessageRequest -> ClientM (Response Bool) pinChatMessage = client (Proxy @PinChatMessage)++makeDefault ''PinChatMessageRequest
src/Telegram/Bot/API/Methods/PromoteChatMember.hs view
@@ -13,6 +13,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'promoteChatMember' @@ -52,3 +53,5 @@ -- Returns True on success. promoteChatMember ::PromoteChatMemberRequest -> ClientM (Response Bool) promoteChatMember = client (Proxy @PromoteChatMember)++makeDefault ''PromoteChatMemberRequest
src/Telegram/Bot/API/Methods/RestrictChatMember.hs view
@@ -13,6 +13,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'restrictChatMember' @@ -43,3 +44,5 @@ -- Returns True on success. restrictChatMember :: RestrictChatMemberRequest -> ClientM (Response Bool) restrictChatMember = client (Proxy @RestrictChatMember)++makeDefault ''RestrictChatMemberRequest
src/Telegram/Bot/API/Methods/RevokeChatInviteLink.hs view
@@ -19,11 +19,11 @@ :> Post '[JSON] (Response ChatInviteLink) -- | Use this method to revoke an invite--- link created by the bot. If the primary --- link is revoked, a new link is automatically --- generated. The bot must be an administrator --- in the chat for this to work and must have --- the appropriate administrator rights. +-- link created by the bot. If the primary+-- link is revoked, a new link is automatically+-- generated. The bot must be an administrator+-- in the chat for this to work and must have+-- the appropriate administrator rights. -- Returns the revoked invite link as ChatInviteLink object. revokeChatInviteLink :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) -> Text -- ^ The invite link to revoke
src/Telegram/Bot/API/Methods/SendAnimation.hs view
@@ -31,6 +31,7 @@ import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types import Telegram.Bot.API.Types.ParseMode+import Telegram.Bot.API.Internal.TH -- ** 'sendAnimation' @@ -120,3 +121,5 @@ boundary <- liftIO genBoundary client (Proxy @SendAnimationContent) (boundary, r) _ -> client (Proxy @SendAnimationLink) r++makeDefault ''SendAnimationRequest
src/Telegram/Bot/API/Methods/SendAudio.hs view
@@ -31,6 +31,7 @@ import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types import Telegram.Bot.API.Types.ParseMode+import Telegram.Bot.API.Internal.TH -- ** 'sendAudio' @@ -120,3 +121,5 @@ boundary <- liftIO genBoundary client (Proxy @SendAudioContent) (boundary, r) _ -> client (Proxy @SendAudioLink) r++makeDefault ''SendAudioRequest
src/Telegram/Bot/API/Methods/SendContact.hs view
@@ -14,6 +14,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'sendContact' @@ -44,3 +45,5 @@ -- On success, the sent Message is returned. sendContact :: SendContactRequest -> ClientM (Response Message) sendContact = client (Proxy @SendContact)++makeDefault ''SendContactRequest
src/Telegram/Bot/API/Methods/SendDice.hs view
@@ -14,6 +14,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'sendDice' @@ -42,3 +43,5 @@ -- On success, the sent Message is returned. sendDice :: SendDiceRequest -> ClientM (Response Message) sendDice = client (Proxy @SendDice)++makeDefault ''SendDiceRequest
src/Telegram/Bot/API/Methods/SendDocument.hs view
@@ -31,6 +31,7 @@ import Telegram.Bot.API.Types import Telegram.Bot.API.Types.ParseMode import Telegram.Bot.API.Types.SomeReplyMarkup+import Telegram.Bot.API.Internal.TH -- ** 'sendDocument' @@ -67,7 +68,7 @@ , sendDocumentCaptionEntities :: Maybe [MessageEntity] -- ^ A JSON-serialized list of special entities that appear in the caption, which can be specified instead of /parse_mode/. , sendDocumentDisableContentTypeDetection :: Maybe Bool -- ^ Disables automatic server-side content type detection for files uploaded using @multipart/form-data@. , sendDocumentDisableNotification :: Maybe Bool -- ^ Sends the message silently. Users will receive a notification with no sound.- , sendDocumentProtectContent :: Maybe Bool -- ^ Protects the contents of the sent message from forwarding and saving. + , sendDocumentProtectContent :: Maybe Bool -- ^ Protects the contents of the sent message from forwarding and saving. , sendDocumentReplyToMessageId :: Maybe MessageId -- ^ If the message is a reply, ID of the original message. , sendDocumentAllowSendingWithoutReply :: Maybe Bool -- ^ Pass 'True', if the message should be sent even if the specified replied-to message is not found. , sendDocumentReplyMarkup :: 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.@@ -117,20 +118,8 @@ instance ToJSON SendDocumentRequest where toJSON = gtoJSON +makeDefault ''SendDocumentRequest+ -- | Generate send document structure. toSendDocument :: SomeChatId -> DocumentFile -> SendDocumentRequest-toSendDocument ch df = SendDocumentRequest- { sendDocumentChatId = ch- , sendDocumentMessageThreadId = Nothing- , sendDocumentDocument = df- , sendDocumentThumb = Nothing- , sendDocumentCaption = Nothing- , sendDocumentParseMode = Nothing- , sendDocumentCaptionEntities = Nothing- , sendDocumentDisableContentTypeDetection = Nothing- , sendDocumentDisableNotification = Nothing- , sendDocumentProtectContent = Nothing- , sendDocumentReplyToMessageId = Nothing- , sendDocumentAllowSendingWithoutReply = Nothing- , sendDocumentReplyMarkup = Nothing- }+toSendDocument = defSendDocument
src/Telegram/Bot/API/Methods/SendLocation.hs view
@@ -13,6 +13,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'sendLocation' @@ -46,3 +47,5 @@ -- On success, the sent Message is returned. sendLocation :: SendLocationRequest -> ClientM (Response Message) sendLocation = client (Proxy @SendLocation)++makeDefault ''SendLocationRequest
src/Telegram/Bot/API/Methods/SendMediaGroup.hs view
@@ -13,6 +13,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'sendMediaGroup' @@ -42,3 +43,5 @@ -- On success, an array of Messages that were sent is returned. sendMediaGroup :: SendMediaGroupRequest -> ClientM (Response [Message]) sendMediaGroup = client (Proxy @SendMediaGroup)++makeDefault ''SendMediaGroupRequest
src/Telegram/Bot/API/Methods/SendMessage.hs view
@@ -16,6 +16,7 @@ import Telegram.Bot.API.Types import Telegram.Bot.API.Types.ParseMode import Telegram.Bot.API.Types.SomeReplyMarkup+import Telegram.Bot.API.Internal.TH -- ** 'sendMessage' @@ -44,3 +45,5 @@ instance ToJSON SendMessageRequest where toJSON = gtoJSON instance FromJSON SendMessageRequest where parseJSON = gparseJSON++makeDefault ''SendMessageRequest
src/Telegram/Bot/API/Methods/SendPhoto.hs view
@@ -31,6 +31,7 @@ import Telegram.Bot.API.Types import Telegram.Bot.API.Types.ParseMode import Telegram.Bot.API.Types.SomeReplyMarkup+import Telegram.Bot.API.Internal.TH -- * Available methods @@ -69,7 +70,7 @@ , sendPhotoCaptionEntities :: Maybe [MessageEntity] -- ^ A JSON-serialized list of special entities that appear in the caption, which can be specified instead of /parse_mode/. , sendPhotoHasSpoiler :: Maybe Bool -- ^ Pass 'True' if the photo needs to be covered with a spoiler animation. , sendPhotoDisableNotification :: Maybe Bool -- ^ Sends the message silently. Users will receive a notification with no sound.- , sendPhotoProtectContent :: Maybe Bool -- ^ Protects the contents of the sent message from forwarding and saving. + , sendPhotoProtectContent :: Maybe Bool -- ^ Protects the contents of the sent message from forwarding and saving. , sendPhotoReplyToMessageId :: Maybe MessageId -- ^ If the message is a reply, ID of the original message. , sendPhotoAllowSendingWithoutReply :: Maybe Bool -- ^ Pass 'True', if the message should be sent even if the specified replied-to message is not found. , sendPhotoReplyMarkup :: 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.@@ -115,3 +116,5 @@ boundary <- liftIO genBoundary client (Proxy @SendPhotoContent) (boundary, r) _ -> client (Proxy @SendPhotoLink) r++makeDefault ''SendPhotoRequest
src/Telegram/Bot/API/Methods/SendPoll.hs view
@@ -15,6 +15,7 @@ import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types import Telegram.Bot.API.Types.ParseMode+import Telegram.Bot.API.Internal.TH -- ** 'sendPoll' @@ -53,3 +54,5 @@ -- On success, the sent Message is returned. sendPoll :: SendPollRequest -> ClientM (Response Message) sendPoll = client (Proxy @SendPoll)++makeDefault ''SendPollRequest
src/Telegram/Bot/API/Methods/SendVenue.hs view
@@ -14,6 +14,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'sendVenue' @@ -48,3 +49,5 @@ -- On success, the sent Message is returned. sendVenue :: SendVenueRequest -> ClientM (Response Message) sendVenue = client (Proxy @SendVenue)++makeDefault ''SendVenueRequest
src/Telegram/Bot/API/Methods/SendVideo.hs view
@@ -31,6 +31,7 @@ import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types import Telegram.Bot.API.Types.ParseMode+import Telegram.Bot.API.Internal.TH -- ** 'sendVideo' @@ -123,3 +124,5 @@ boundary <- liftIO genBoundary client (Proxy @SendVideoContent) (boundary, r) _ -> client (Proxy @SendVideoLink) r++makeDefault ''SendVideoRequest
src/Telegram/Bot/API/Methods/SendVideoNote.hs view
@@ -29,6 +29,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'sendVideoNote' @@ -97,3 +98,5 @@ boundary <- liftIO genBoundary client (Proxy @SendVideoNoteContent) (boundary, r) _ -> client (Proxy @SendVideoNoteLink) r++makeDefault ''SendVideoNoteRequest
src/Telegram/Bot/API/Methods/SendVoice.hs view
@@ -31,6 +31,7 @@ import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types import Telegram.Bot.API.Types.ParseMode+import Telegram.Bot.API.Internal.TH -- ** 'sendVoice' @@ -109,3 +110,5 @@ boundary <- liftIO genBoundary client (Proxy @SendVoiceContent) (boundary, r) _ -> client (Proxy @SendVoiceLink) r++makeDefault ''SendVoiceRequest
src/Telegram/Bot/API/Methods/SetChatAdministratorCustomTitle.hs view
@@ -14,6 +14,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'setChatAdministratorCustomTitle' @@ -38,3 +39,5 @@ -- Returns True on success. setChatAdministratorCustomTitle :: SetChatAdministratorCustomTitleRequest -> ClientM (Response Bool) setChatAdministratorCustomTitle = client (Proxy @SetChatAdministratorCustomTitle)++makeDefault ''SetChatAdministratorCustomTitleRequest
src/Telegram/Bot/API/Methods/SetChatDescription.hs view
@@ -18,11 +18,11 @@ :> QueryParam "description" Text :> Post '[JSON] (Response Bool) --- | Use this method to change the description --- of a group, a supergroup or a channel. The --- bot must be an administrator in the chat --- for this to work and must have the appropriate --- administrator rights. +-- | Use this method to change the description+-- of a group, a supergroup or a channel. The+-- bot must be an administrator in the chat+-- for this to work and must have the appropriate+-- administrator rights. -- Returns True on success. setChatDescription :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) -> Maybe Text -- ^ New chat description, 0-255 characters
src/Telegram/Bot/API/Methods/SetChatMenuButton.hs view
@@ -13,6 +13,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'setChatMenuButton' @@ -34,3 +35,5 @@ -- or the default menu button. Returns True on success. setChatMenuButton :: SetChatMenuButtonRequest -> ClientM (Response Bool) setChatMenuButton = client (Proxy @SetChatMenuButton)++makeDefault ''SetChatMenuButtonRequest
src/Telegram/Bot/API/Methods/SetChatPermissions.hs view
@@ -14,6 +14,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'setChatPermissions' @@ -40,3 +41,5 @@ -- Returns True on success. setChatPermissions :: SetChatPermissionsRequest -> ClientM (Response Bool) setChatPermissions = client (Proxy @SetChatPermissions)++makeDefault ''SetChatPermissionsRequest
src/Telegram/Bot/API/Methods/SetChatPhoto.hs view
@@ -18,6 +18,7 @@ import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'setChatPhoto' @@ -40,11 +41,11 @@ :> MultipartForm Tmp SetChatPhotoRequest :> Post '[JSON] (Response Bool) --- | Use this method to set a new profile +-- | Use this method to set a new profile -- photo for the chat. Photos can't be changed--- for private chats. The bot must be an --- administrator in the chat for this to work --- and must have the appropriate administrator rights. +-- for private chats. The bot must be an+-- administrator in the chat for this to work+-- and must have the appropriate administrator rights. -- Returns True on success. -- -- *Note*: Only 'InputFile' case might be used in 'SetChatPhotoRequest'.@@ -53,3 +54,5 @@ setChatPhoto r =do boundary <- liftIO genBoundary client (Proxy @SetChatPhoto) (boundary, r)++makeDefault ''SetChatPhotoRequest
src/Telegram/Bot/API/Methods/SetChatStickerSet.hs view
@@ -19,12 +19,12 @@ :> Post '[JSON] (Response Bool) -- | Use this method to set a new group sticker--- set for a supergroup. The bot must be an --- administrator in the chat for this to work --- and must have the appropriate administrator --- rights. Use the field can_set_sticker_set --- optionally returned in getChat requests to --- check if the bot can use this method. +-- set for a supergroup. The bot must be an+-- administrator in the chat for this to work+-- and must have the appropriate administrator+-- rights. Use the field can_set_sticker_set+-- optionally returned in getChat requests to+-- check if the bot can use this method. -- Returns True on success. setChatStickerSet :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) -> Text -- ^ Name of the sticker set to be set as the group sticker set
src/Telegram/Bot/API/Methods/SetChatTitle.hs view
@@ -20,9 +20,9 @@ -- | Use this method to change the title of -- a chat. Titles can't be changed for private--- chats. The bot must be an administrator in --- the chat for this to work and must have the --- appropriate administrator rights. +-- chats. The bot must be an administrator in+-- the chat for this to work and must have the+-- appropriate administrator rights. -- Returns True on success. setChatTitle :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) -> Text -- ^ New chat title, 0-255 characters
src/Telegram/Bot/API/Methods/SetMyCommands.hs view
@@ -14,6 +14,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'setMyCommands' @@ -32,9 +33,11 @@ :> ReqBody '[JSON] SetMyCommandsRequest :> Post '[JSON] (Response Bool) --- | Use this method to change the list of --- the bot's commands. See <https:\/\/core.telegram.org\/bots#commands> --- for more details about bot commands. +-- | Use this method to change the list of+-- the bot's commands. See <https:\/\/core.telegram.org\/bots#commands>+-- for more details about bot commands. -- Returns True on success. setMyCommands :: SetMyCommandsRequest -> ClientM (Response Bool) setMyCommands = client (Proxy @SetMyCommands)++makeDefault ''SetMyCommandsRequest
src/Telegram/Bot/API/Methods/SetMyDefaultAdministratorRights.hs view
@@ -13,6 +13,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'setMyDefaultAdministratorRights' @@ -34,3 +35,5 @@ setMyDefaultAdministratorRights :: SetMyDefaultAdministratorRightsRequest -> ClientM (Response Bool) setMyDefaultAdministratorRights = client (Proxy @SetMyDefaultAdministratorRights)++makeDefault ''SetMyDefaultAdministratorRightsRequest
+ src/Telegram/Bot/API/Methods/SetMyDescription.hs view
@@ -0,0 +1,39 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeOperators #-}+module Telegram.Bot.API.Methods.SetMyDescription where++import Data.Aeson (FromJSON (..), ToJSON (..))+import Data.Proxy+import GHC.Generics (Generic)+import Data.Text (Text)+import Servant.API+import Servant.Client hiding (Response)++import Telegram.Bot.API.Internal.Utils+import Telegram.Bot.API.MakingRequests+import Telegram.Bot.API.Internal.TH++-- ** 'setMyDescription'++data SetMyDescriptionRequest = SetMyDescriptionRequest+ { setMyDescriptionDescription :: Maybe Text -- ^ New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.+ , setMyDescriptionLanguageCode :: Maybe Text -- ^ A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.+ }+ deriving Generic++instance ToJSON SetMyDescriptionRequest where toJSON = gtoJSON+instance FromJSON SetMyDescriptionRequest where parseJSON = gparseJSON++type SetMyDescription = "setMyDescription"+ :> ReqBody '[JSON] SetMyDescriptionRequest+ :> Post '[JSON] (Response Bool)++-- | Use this method to change the bot's description,+-- which is shown in the chat with the bot if the chat is empty.+-- Returns 'True' on success.+setMyDescription :: SetMyDescriptionRequest -> ClientM (Response Bool)+setMyDescription = client (Proxy @SetMyDescription)++makeDefault ''SetMyDescriptionRequest
+ src/Telegram/Bot/API/Methods/SetMyShortDescription.hs view
@@ -0,0 +1,40 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeOperators #-}+module Telegram.Bot.API.Methods.SetMyShortDescription where++import Data.Aeson (FromJSON (..), ToJSON (..))+import Data.Proxy+import GHC.Generics (Generic)+import Data.Text (Text)+import Servant.API+import Servant.Client hiding (Response)++import Telegram.Bot.API.Internal.Utils+import Telegram.Bot.API.MakingRequests+import Telegram.Bot.API.Internal.TH++-- ** 'setMyShortDescription'++data SetMyShortDescriptionRequest = SetMyShortDescriptionRequest+ { setMyShortDescriptionDescription :: Maybe Text -- ^ New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.+ , setMyShortDescriptionLanguageCode :: Maybe Text -- ^ A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description.+ }+ deriving Generic++instance ToJSON SetMyShortDescriptionRequest where toJSON = gtoJSON+instance FromJSON SetMyShortDescriptionRequest where parseJSON = gparseJSON++type SetMyShortDescription = "setMyShortDescription"+ :> ReqBody '[JSON] SetMyShortDescriptionRequest+ :> Post '[JSON] (Response Bool)++-- | Use this method to change the bot's short description,+-- which is shown on the bot's profile page and+-- is sent together with the link when users share the bot.+-- Returns 'True' on success.+setMyShortDescription :: SetMyShortDescriptionRequest -> ClientM (Response Bool)+setMyShortDescription = client (Proxy @SetMyShortDescription)++makeDefault ''SetMyShortDescriptionRequest
src/Telegram/Bot/API/Methods/StopMessageLiveLocation.hs view
@@ -14,6 +14,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- ** 'stopMessageLiveLocation' @@ -40,3 +41,5 @@ -- is returned, otherwise True is returned. stopMessageLiveLocation :: StopMessageLiveLocationRequest -> ClientM (Response (Either Bool Message)) stopMessageLiveLocation = client (Proxy @StopMessageLiveLocation)++makeDefault ''StopMessageLiveLocationRequest
src/Telegram/Bot/API/Methods/UnbanChatMember.hs view
@@ -13,6 +13,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH -- | Request parameters for 'unbanChatMember'. data UnbanChatMemberRequest = UnbanChatMemberRequest@@ -44,3 +45,5 @@ -- Returns True on success. unbanChatMember :: UnbanChatMemberRequest -> ClientM (Response Bool) unbanChatMember = client (Proxy @UnbanChatMember)++makeDefault ''UnbanChatMemberRequest
src/Telegram/Bot/API/Methods/UnpinAllChatMessages.hs view
@@ -16,12 +16,12 @@ :> RequiredQueryParam "chat_id" SomeChatId :> Post '[JSON] (Response Bool) --- | Use this method to clear the list of pinned --- messages in a chat. If the chat is not a private --- chat, the bot must be an administrator in the --- chat for this to work and must have the 'can_pin_messages' --- administrator right in a supergroup or 'can_edit_messages' --- administrator right in a channel. +-- | Use this method to clear the list of pinned+-- messages in a chat. If the chat is not a private+-- chat, the bot must be an administrator in the+-- chat for this to work and must have the 'can_pin_messages'+-- administrator right in a supergroup or 'can_edit_messages'+-- administrator right in a channel. -- Returns True on success. unpinAllChatMessages :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) -> ClientM (Response Bool)
src/Telegram/Bot/API/Methods/UnpinChatMessage.hs view
@@ -18,12 +18,12 @@ :> Post '[JSON] (Response Bool) -- | Use this method to remove a message from the--- list of pinned messages in a chat. If the chat +-- list of pinned messages in a chat. If the chat -- is not a private chat, the bot must be an administrator--- in the chat for this to work and must have the --- 'can_pin_messages' administrator right in a supergroup --- or 'can_edit_messages' administrator right in a --- channel. +-- in the chat for this to work and must have the+-- 'can_pin_messages' administrator right in a supergroup+-- or 'can_edit_messages' administrator right in a+-- channel. -- Returns True on success. unpinChatMessage :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) -> Maybe MessageId -- ^ Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned.
src/Telegram/Bot/API/Payments.hs view
@@ -14,6 +14,7 @@ import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.Types import Telegram.Bot.API.MakingRequests+import Telegram.Bot.API.Internal.TH (makeDefault) -- * Methods @@ -29,7 +30,7 @@ , sendInvoiceCurrency :: Text -- ^ Three-letter ISO 4217 currency code, see more on currencies. , sendInvoicePrices :: [LabeledPrice] -- ^ Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). , sendInvoiceMaxTipAmount :: Maybe Integer -- ^ The maximum accepted amount for tips in the smallest units of the currency (integer, not float\/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0.- , sendInvoiceequestSuggestedTipAmounts :: Maybe [Integer] -- ^ A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.+ , sendInvoiceequestSuggestedTipAmounts :: Maybe [Integer] -- ^ A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. , sendInvoiceStartParameter :: Maybe Text -- ^ Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter. , sendInvoiceProviderData :: Maybe Text -- ^ A JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider. , sendInvoicePhotoUrl :: Maybe Text -- ^ URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.@@ -58,7 +59,7 @@ = "sendInvoice" :> ReqBody '[JSON] SendInvoiceRequest :> Post '[JSON] (Response Message)- + -- | Use this method to send invoices. On success, the sent 'Message' is returned. sendInvoice :: SendInvoiceRequest -> ClientM (Response Message) sendInvoice = client (Proxy @SendInvoice)@@ -144,3 +145,9 @@ answerPreCheckoutQuery :: AnswerPreCheckoutQueryRequest -> ClientM (Response Bool) answerPreCheckoutQuery = client (Proxy @AnswerPreCheckoutQuery) +foldMap makeDefault+ [ ''SendInvoiceRequest+ , ''CreateInvoiceLinkRequest+ , ''AnswerShippingQueryRequest+ , ''AnswerPreCheckoutQueryRequest+ ]
src/Telegram/Bot/API/Stickers.hs view
@@ -32,6 +32,7 @@ import Telegram.Bot.API.Types import Data.Maybe (catMaybes, maybeToList) import Data.Functor+import Telegram.Bot.API.Internal.TH (makeDefault) -- | Type of uploaded sticker file. Static or animated.@@ -55,7 +56,7 @@ data SendStickerRequest = SendStickerRequest { sendStickerChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). , sendStickerMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.- , sendStickerSticker :: InputFile -- ^ Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP file from the Internet, or upload a new one using multipart/form-data. + , sendStickerSticker :: InputFile -- ^ Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP file from the Internet, or upload a new one using multipart/form-data. , sendStickerDisableNotification :: Maybe Bool -- ^ Sends the message silently. Users will receive a notification with no sound. , sendStickerProtectContent :: Maybe Bool -- ^ Protects the contents of the sent message from forwarding and saving. , sendStickerReplyToMessageId :: Maybe MessageId -- ^ If the message is a reply, ID of the original message@@ -67,7 +68,7 @@ instance ToJSON SendStickerRequest where toJSON = gtoJSON instance ToMultipart Tmp SendStickerRequest where- toMultipart SendStickerRequest{..} = + toMultipart SendStickerRequest{..} = makeFile "sticker" sendStickerSticker (MultipartData fields []) where fields = [ Input "chat_id" $ case sendStickerChatId of@@ -98,7 +99,7 @@ :> ReqBody '[JSON] SendStickerRequest :> Post '[JSON] (Response Message) --- | Use this method to send static .WEBP or animated .TGS stickers. +-- | Use this method to send static .WEBP or animated .TGS stickers. -- On success, the sent Message is returned. sendSticker :: SendStickerRequest -> ClientM (Response Message) sendSticker r =@@ -127,14 +128,14 @@ -- | Request parameters for 'uploadStickerFile'. data UploadStickerFileRequest = UploadStickerFileRequest- { uploadStickerFileUserId :: UserId -- ^ User identifier of sticker file owner- , uploadStickerFilePngSticker :: InputFile -- ^ PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. + { uploadStickerFileUserId :: UserId -- ^ User identifier of sticker file owner+ , uploadStickerFilePngSticker :: InputFile -- ^ PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. } deriving Generic instance ToJSON UploadStickerFileRequest where toJSON = gtoJSON instance ToMultipart Tmp UploadStickerFileRequest where- toMultipart UploadStickerFileRequest{..} = + toMultipart UploadStickerFileRequest{..} = makeFile "png_sticker" uploadStickerFilePngSticker (MultipartData fields []) where fields = [ Input "user_id" $ T.pack . show $ uploadStickerFileUserId ] @@ -148,9 +149,9 @@ :> ReqBody '[JSON] UploadStickerFileRequest :> Post '[JSON] (Response File) --- | Use this method to upload a .PNG file --- with a sticker for later use in createNewStickerSet --- and addStickerToSet methods (can be used multiple times). +-- | Use this method to upload a .PNG file+-- with a sticker for later use in createNewStickerSet+-- and addStickerToSet methods (can be used multiple times). -- Returns the uploaded File on success. uploadStickerFile :: UploadStickerFileRequest -> ClientM (Response File) uploadStickerFile r =@@ -165,16 +166,16 @@ -- | Request parameters for 'createNewStickerSet'. data CreateNewStickerSetRequest = CreateNewStickerSetRequest- { createNewStickerSetUserId :: UserId -- ^ User identifier of created sticker set owner- , createNewStickerSetName :: T.Text -- ^ Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters.- , createNewStickerSetTitle :: T.Text -- ^ Sticker set title, 1-64 characters- , createNewStickerSetSticker :: StickerFile -- ^ Sticker file to upload- , createNewStickerSetEmojis :: T.Text -- ^ One or more emoji corresponding to the sticker+ { createNewStickerSetUserId :: UserId -- ^ User identifier of created sticker set owner+ , createNewStickerSetName :: T.Text -- ^ Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters.+ , createNewStickerSetTitle :: T.Text -- ^ Sticker set title, 1-64 characters+ , createNewStickerSetSticker :: StickerFile -- ^ Sticker file to upload+ , createNewStickerSetEmojis :: T.Text -- ^ One or more emoji corresponding to the sticker , createNewStickerSetContainsMasks :: Maybe Bool -- ^ Pass True, if a set of mask stickers should be created- , createNewStickerSetMaskPosition :: Maybe MaskPosition -- ^ A JSON-serialized object for position where the mask should be placed on faces+ , createNewStickerSetMaskPosition :: Maybe MaskPosition -- ^ A JSON-serialized object for position where the mask should be placed on faces } deriving Generic -instance ToJSON CreateNewStickerSetRequest where +instance ToJSON CreateNewStickerSetRequest where toJSON CreateNewStickerSetRequest{..} = object [ "user_id" .= createNewStickerSetUserId , "name" .= createNewStickerSetName@@ -192,7 +193,7 @@ StickerFile{..} = createNewStickerSetSticker instance ToMultipart Tmp CreateNewStickerSetRequest where- toMultipart CreateNewStickerSetRequest{..} = + toMultipart CreateNewStickerSetRequest{..} = makeFile (stickerLabel stickerFileLabel) stickerFileSticker (MultipartData fields []) where fields = [ Input "user_id" $ T.pack . show $ createNewStickerSetUserId@@ -217,10 +218,10 @@ :> ReqBody '[JSON] CreateNewStickerSetRequest :> Post '[JSON] (Response Bool) --- | Use this method to create a new sticker --- set owned by a user. The bot will be able --- to edit the sticker set thus created. You --- must use exactly one of the fields png_sticker or tgs_sticker. +-- | Use this method to create a new sticker+-- set owned by a user. The bot will be able+-- to edit the sticker set thus created. You+-- must use exactly one of the fields png_sticker or tgs_sticker. -- Returns True on success. createNewStickerSet :: CreateNewStickerSetRequest -> ClientM (Response Bool) createNewStickerSet r =@@ -234,10 +235,10 @@ -- | Request parameters for 'addStickerToSet'. data AddStickerToSetRequest = AddStickerToSetRequest- { addStickerToSetUserId :: UserId -- ^ User identifier of sticker set owner- , addStickerToSetName :: T.Text -- ^ Sticker set name- , addStickerToSetSticker :: StickerFile -- ^ Sticker file to upload - , addStickerToSetEmojis :: T.Text -- ^ One or more emoji corresponding to the sticker+ { addStickerToSetUserId :: UserId -- ^ User identifier of sticker set owner+ , addStickerToSetName :: T.Text -- ^ Sticker set name+ , addStickerToSetSticker :: StickerFile -- ^ Sticker file to upload+ , addStickerToSetEmojis :: T.Text -- ^ One or more emoji corresponding to the sticker , addStickerToSetMaskPosition :: Maybe MaskPosition -- ^ A JSON-serialized object for position where the mask should be placed on faces } deriving Generic @@ -257,7 +258,7 @@ StickerFile{..} = addStickerToSetSticker instance ToMultipart Tmp AddStickerToSetRequest where- toMultipart AddStickerToSetRequest{..} = + toMultipart AddStickerToSetRequest{..} = makeFile (stickerLabel stickerFileLabel) stickerFileSticker (MultipartData fields []) where fields = [ Input "user_id" $ T.pack . show $ addStickerToSetUserId@@ -279,12 +280,12 @@ :> ReqBody '[JSON] AddStickerToSetRequest :> Post '[JSON] (Response Bool) --- | Use this method to add a new sticker to a set --- created by the bot. You must use exactly one of --- the fields png_sticker or tgs_sticker. Animated --- stickers can be added to animated sticker sets and --- only to them. Animated sticker sets can have up to 50 --- stickers. Static sticker sets can have up to 120 stickers. +-- | Use this method to add a new sticker to a set+-- created by the bot. You must use exactly one of+-- the fields png_sticker or tgs_sticker. Animated+-- stickers can be added to animated sticker sets and+-- only to them. Animated sticker sets can have up to 50+-- stickers. Static sticker sets can have up to 120 stickers. -- Returns True on success. addStickerToSet :: AddStickerToSetRequest -> ClientM (Response Bool) addStickerToSet r =@@ -315,7 +316,7 @@ :> RequiredQueryParam "position" Integer :> Post '[JSON] (Response Bool) --- | Use this method to move a sticker in a set created by the bot to a specific position. +-- | Use this method to move a sticker in a set created by the bot to a specific position. -- Returns True on success. setStickerPositionInSet :: T.Text -- ^ File identifier of the sticker -> Integer -- ^ New sticker position in the set, zero-based@@ -330,7 +331,7 @@ :> RequiredQueryParam "sticker" T.Text :> Post '[JSON] (Response Bool) --- | Use this method to delete a sticker from a set created by the bot. +-- | Use this method to delete a sticker from a set created by the bot. -- Returns True on success. deleteStickerFromSet :: T.Text -- ^ File identifier of the sticker -> ClientM (Response Bool)@@ -340,15 +341,15 @@ -- | Request parameters for 'setStickerSetThumb'. data SetStickerSetThumbRequest = SetStickerSetThumbRequest- { setStickerSetThumbName :: T.Text -- ^ Sticker set name+ { setStickerSetThumbName :: T.Text -- ^ Sticker set name , setStickerSetThumbUserId :: UserId -- ^ User identifier of the sticker set owner- , setStickerSetThumbThumb :: InputFile -- ^ A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see <https:\/\/core.telegram.org\/animated_stickers#technical-requirements> for animated sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. Animated sticker set thumbnail can't be uploaded via HTTP URL.+ , setStickerSetThumbThumb :: InputFile -- ^ A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see <https:\/\/core.telegram.org\/animated_stickers#technical-requirements> for animated sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. Animated sticker set thumbnail can't be uploaded via HTTP URL. } deriving Generic instance ToJSON SetStickerSetThumbRequest where toJSON = gtoJSON instance ToMultipart Tmp SetStickerSetThumbRequest where- toMultipart SetStickerSetThumbRequest{..} = + toMultipart SetStickerSetThumbRequest{..} = makeFile "png_sticker" setStickerSetThumbThumb (MultipartData fields []) where fields = [ Input "user_id" $ T.pack . show $ setStickerSetThumbUserId@@ -365,8 +366,8 @@ :> ReqBody '[JSON] SetStickerSetThumbRequest :> Post '[JSON] (Response Bool) --- | Use this method to set the thumbnail of a sticker set. --- Animated thumbnails can be set for animated sticker sets only. +-- | Use this method to set the thumbnail of a sticker set.+-- Animated thumbnails can be set for animated sticker sets only. -- Returns True on success. setStickerSetThumb :: SetStickerSetThumbRequest -> ClientM (Response Bool) setStickerSetThumb r =@@ -376,3 +377,11 @@ client (Proxy @SetStickerSetThumbContent) (boundary, r) _ -> client (Proxy @SetStickerSetThumbLink) r +foldMap makeDefault+ [ ''SendStickerRequest+ , ''GetCustomEmojiStickersRequest+ , ''UploadStickerFileRequest+ , ''CreateNewStickerSetRequest+ , ''AddStickerToSetRequest+ , ''SetStickerSetThumbRequest+ ]
src/Telegram/Bot/API/Types.hs view
@@ -17,6 +17,8 @@ , module Telegram.Bot.API.Types.Audio , module Telegram.Bot.API.Types.BotCommand , module Telegram.Bot.API.Types.BotCommandScope+ , module Telegram.Bot.API.Types.BotDescription+ , module Telegram.Bot.API.Types.BotShortDescription , module Telegram.Bot.API.Types.CallbackGame , module Telegram.Bot.API.Types.CallbackQuery , module Telegram.Bot.API.Types.Chat@@ -102,6 +104,8 @@ import Telegram.Bot.API.Types.Audio import Telegram.Bot.API.Types.BotCommand import Telegram.Bot.API.Types.BotCommandScope+import Telegram.Bot.API.Types.BotDescription+import Telegram.Bot.API.Types.BotShortDescription import Telegram.Bot.API.Types.CallbackGame import Telegram.Bot.API.Types.CallbackQuery import Telegram.Bot.API.Types.Chat
src/Telegram/Bot/API/Types/Audio.hs view
@@ -5,7 +5,7 @@ import Data.Text (Text) import GHC.Generics (Generic) -import Telegram.Bot.API.Types.Common +import Telegram.Bot.API.Types.Common import Telegram.Bot.API.Types.PhotoSize import Telegram.Bot.API.Internal.Utils
+ src/Telegram/Bot/API/Types/BotDescription.hs view
@@ -0,0 +1,18 @@+{-# LANGUAGE DeriveGeneric #-}+module Telegram.Bot.API.Types.BotDescription where++import Data.Aeson (FromJSON (..), ToJSON (..))+import Data.Text (Text)+import GHC.Generics (Generic)+import Telegram.Bot.API.Internal.Utils++-- ** 'BotDescription'++-- | This object represents the bot's description.+data BotDescription = BotDescription+ { botDescriptionDescription :: Text -- ^ The bot's description.+ }+ deriving (Generic, Show)++instance ToJSON BotDescription where toJSON = gtoJSON+instance FromJSON BotDescription where parseJSON = gparseJSON
+ src/Telegram/Bot/API/Types/BotShortDescription.hs view
@@ -0,0 +1,18 @@+{-# LANGUAGE DeriveGeneric #-}+module Telegram.Bot.API.Types.BotShortDescription where++import Data.Aeson (FromJSON (..), ToJSON (..))+import Data.Text (Text)+import GHC.Generics (Generic)+import Telegram.Bot.API.Internal.Utils++-- ** 'BotShortDescription'++-- | This object represents the bot's short description.+data BotShortDescription = BotShortDescription+ { botShortDescriptionShortDescription :: Text -- ^ The bot's short description.+ }+ deriving (Generic, Show)++instance ToJSON BotShortDescription where toJSON = gtoJSON+instance FromJSON BotShortDescription where parseJSON = gparseJSON
src/Telegram/Bot/API/UpdatingMessages.hs view
@@ -16,6 +16,7 @@ import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Methods import Telegram.Bot.API.Types+import Telegram.Bot.API.Internal.TH (makeDefault) data EditMessageResponse = EditedInlineMessage Bool@@ -78,7 +79,7 @@ , stopPollReplyMarkup :: Maybe SomeReplyMarkup -- ^ A JSON-serialized object for a new message inline keyboard. } deriving (Generic) -foldMap deriveJSON' +foldMap deriveJSON' [ ''EditMessageTextRequest , ''EditMessageCaptionRequest , ''EditMessageReplyMarkupRequest@@ -144,3 +145,9 @@ stopPoll = client (Proxy @StopPoll) +foldMap makeDefault+ [ ''EditMessageTextRequest+ , ''EditMessageCaptionRequest+ , ''EditMessageReplyMarkupRequest+ , ''StopPollRequest+ ]
src/Telegram/Bot/API/WebApps.hs view
@@ -17,6 +17,7 @@ import Telegram.Bot.API.MakingRequests (Response) import Telegram.Bot.API.InlineMode (InlineQueryId) import Telegram.Bot.API.InlineMode.InlineQueryResult (InlineQueryResult)+import Telegram.Bot.API.Internal.TH (makeDefault) -- * Types @@ -35,7 +36,7 @@ { sentWebAppMessageInlineMessageId :: Maybe InlineQueryId } deriving (Generic, Show)- + foldMap deriveJSON' [ ''SentWebAppMessage , ''AnswerWebAppQueryRequest@@ -51,7 +52,12 @@ -- | Use this method to set the result of an interaction with a Web App -- and send a corresponding message on behalf of the user -- to the chat from which the query originated.--- +-- -- On success, a 'SentWebAppMessage' object is returned. answerWebAppQuery :: AnswerWebAppQueryRequest -> ClientM (Response SentWebAppMessage) answerWebAppQuery = client (Proxy @AnswerWebAppQuery)++foldMap makeDefault+ [ ''SentWebAppMessage+ , ''AnswerWebAppQueryRequest+ ]
src/Telegram/Bot/API/Webhook.hs view
@@ -13,6 +13,8 @@ ( setUpWebhook, deleteWebhook, SetWebhookRequest (..),+ defSetWebhook,+ defDeleteWebhook ) where @@ -33,6 +35,7 @@ import Telegram.Bot.API.Internal.Utils (gtoJSON) import Telegram.Bot.API.MakingRequests (Response) import Telegram.Bot.API.Types (InputFile, makeFile)+import Telegram.Bot.API.Internal.TH (makeDefault) data SetWebhookRequest = SetWebhookRequest@@ -95,3 +98,8 @@ requestData = DeleteWebhookRequest {deleteWebhookDropPendingUpdates = Nothing} deleteWebhookRequest = client (Proxy @DeleteWebhook) requestData ++foldMap makeDefault+ [ ''SetWebhookRequest+ , ''DeleteWebhookRequest+ ]
telegram-bot-api.cabal view
@@ -1,7 +1,7 @@ cabal-version: 1.12 name: telegram-bot-api-version: 6.5+version: 6.5.1 synopsis: Easy to use library for building Telegram bots. Exports Telegram Bot API. description: Please see the README on Github at <https://github.com/fizruk/telegram-bot-simple#readme> .@@ -34,6 +34,7 @@ Telegram.Bot.API.InlineMode.InlineQueryResult Telegram.Bot.API.InlineMode.InputMessageContent Telegram.Bot.API.Internal.Utils+ Telegram.Bot.API.Internal.TH Telegram.Bot.API.MakingRequests -- Methods Telegram.Bot.API.Methods@@ -61,6 +62,8 @@ Telegram.Bot.API.Methods.GetMe Telegram.Bot.API.Methods.GetMyCommands Telegram.Bot.API.Methods.GetMyDefaultAdministratorRights+ Telegram.Bot.API.Methods.GetMyDescription+ Telegram.Bot.API.Methods.GetMyShortDescription Telegram.Bot.API.Methods.GetUserProfilePhotos Telegram.Bot.API.Methods.LeaveChat Telegram.Bot.API.Methods.PinChatMessage@@ -91,6 +94,8 @@ Telegram.Bot.API.Methods.SetChatTitle Telegram.Bot.API.Methods.SetMyCommands Telegram.Bot.API.Methods.SetMyDefaultAdministratorRights+ Telegram.Bot.API.Methods.SetMyDescription+ Telegram.Bot.API.Methods.SetMyShortDescription Telegram.Bot.API.Methods.StopMessageLiveLocation Telegram.Bot.API.Methods.UnbanChatMember Telegram.Bot.API.Methods.UnbanChatSenderChat@@ -106,6 +111,8 @@ Telegram.Bot.API.Types.Audio Telegram.Bot.API.Types.BotCommand Telegram.Bot.API.Types.BotCommandScope+ Telegram.Bot.API.Types.BotDescription+ Telegram.Bot.API.Types.BotShortDescription Telegram.Bot.API.Types.CallbackGame Telegram.Bot.API.Types.CallbackQuery Telegram.Bot.API.Types.Chat@@ -222,3 +229,5 @@ , warp , warp-tls default-language: Haskell2010+ default-extensions:+ TemplateHaskell