telegram-bot-api 7.4.4 → 7.4.5
raw patch · 15 files changed
+46/−34 lines, 15 files
Files
- CHANGELOG.md +6/−0
- src/Telegram/Bot/API/Internal/Utils.hs +10/−0
- src/Telegram/Bot/API/Methods/SendAnimation.hs +2/−3
- src/Telegram/Bot/API/Methods/SendAudio.hs +2/−3
- src/Telegram/Bot/API/Methods/SendDocument.hs +2/−2
- src/Telegram/Bot/API/Methods/SendPhoto.hs +2/−2
- src/Telegram/Bot/API/Methods/SendVideo.hs +2/−3
- src/Telegram/Bot/API/Methods/SendVideoNote.hs +2/−3
- src/Telegram/Bot/API/Methods/SendVoice.hs +2/−3
- src/Telegram/Bot/API/Methods/SetChatPhoto.hs +2/−3
- src/Telegram/Bot/API/Stickers.hs +5/−6
- src/Telegram/Bot/API/Types/Common.hs +5/−2
- src/Telegram/Bot/API/Types/UsersShared.hs +1/−1
- src/Telegram/Bot/API/Webhook.hs +2/−2
- telegram-bot-api.cabal +1/−1
CHANGELOG.md view
@@ -1,5 +1,11 @@ # telegram-bot-api +## 7.4.5 -- 2025-05-12++- Fix `UsersShared` data type (see [#200](https://github.com/fizruk/telegram-bot-simple/pull/200)).+- Fix `WebAppInfo` data type (see [#202](https://github.com/fizruk/telegram-bot-simple/pull/202)).+- Fix support of `text-2.1.2.0` (see [#203](https://github.com/fizruk/telegram-bot-simple/pull/203)).+ ## 7.4.4 -- 2024-11-24 - Fix `message_thread_id` for `copyMessage`, `copyMessages` (see [#198](https://github.com/fizruk/telegram-bot-simple/pull/198)).
src/Telegram/Bot/API/Internal/Utils.hs view
@@ -13,6 +13,7 @@ import Data.Aeson.Types (Options(..), defaultOptions, Parser, Pair) import Data.Char (isUpper, toUpper, toLower) import Data.List (intercalate)+import Data.Text (Text) import GHC.Generics import Language.Haskell.TH import Servant.Multipart.API (MultipartData(MultipartData), Input)@@ -23,6 +24,7 @@ #else import qualified Data.HashMap.Strict as Map #endif+import qualified Data.Text as T deriveJSON' :: Name -> Q [Dec] deriveJSON' name = deriveJSON (jsonOptions (nameBase name)) name@@ -115,3 +117,11 @@ addMultipartFields :: [Input] -> MultipartData tag -> MultipartData tag addMultipartFields newFields (MultipartData currenFields files) = MultipartData (newFields <> currenFields) files++showText :: Show a => a -> Text+#if MIN_VERSION_text(2,1,2)+showText = T.show+#else+showText = T.pack . show+#endif+{-# INLINE showText #-}
src/Telegram/Bot/API/Methods/SendAnimation.hs view
@@ -24,7 +24,6 @@ import Servant.Multipart.Client import Servant.Client hiding (Response) -import qualified Data.Text as T import qualified Data.Text.Lazy as TL import Telegram.Bot.API.Internal.Utils@@ -68,11 +67,11 @@ MultipartData fields [] where fields = [ Input "chat_id" $ case sendAnimationChatId of- SomeChatId (ChatId chat_id) -> T.pack $ show chat_id+ SomeChatId (ChatId chat_id) -> showText chat_id SomeChatUsername txt -> txt ] <> catMaybes [ sendAnimationMessageThreadId <&>- \t -> Input "message_thread_id" (T.pack $ show t)+ \t -> Input "message_thread_id" (showText t) , sendAnimationCaption <&> \t -> Input "caption" t , sendAnimationParseMode <&>
src/Telegram/Bot/API/Methods/SendAudio.hs view
@@ -24,7 +24,6 @@ import Servant.Multipart.Client import Servant.Client hiding (Response) -import qualified Data.Text as T import qualified Data.Text.Lazy as TL import Telegram.Bot.API.Internal.Utils@@ -66,11 +65,11 @@ MultipartData fields [] where fields = [ Input "chat_id" $ case sendAudioChatId of- SomeChatId (ChatId chat_id) -> T.pack $ show chat_id+ SomeChatId (ChatId chat_id) -> showText chat_id SomeChatUsername txt -> txt ] <> catMaybes [ sendAudioMessageThreadId <&>- \t -> Input "message_thread_id" (T.pack $ show t)+ \t -> Input "message_thread_id" (showText t) , sendAudioCaption <&> \t -> Input "caption" t , sendAudioParseMode <&>
src/Telegram/Bot/API/Methods/SendDocument.hs view
@@ -96,10 +96,10 @@ fields = [ Input "document" "attach://file" , Input "chat_id" $ case sendDocumentChatId of- SomeChatId (ChatId chat_id) -> T.pack $ show chat_id+ SomeChatId (ChatId chat_id) -> showText chat_id SomeChatUsername txt -> txt ] <>- maybe id (\t -> (Input "message_thread_id" (T.pack $ show t) :)) sendDocumentMessageThreadId+ maybe id (\t -> (Input "message_thread_id" (showText t) :)) sendDocumentMessageThreadId ( maybe id (const (Input "thumbnail" "attach://thumbnail" :)) sendDocumentThumbnail $ maybe id (\t -> (Input "caption" t :)) sendDocumentCaption $ maybe id (\t -> (Input "parse_mode" (TL.toStrict $ encodeToLazyText t) :)) sendDocumentParseMode
src/Telegram/Bot/API/Methods/SendPhoto.hs view
@@ -85,10 +85,10 @@ fields = [ Input "photo" "attach://file" , Input "chat_id" $ case sendPhotoChatId of- SomeChatId (ChatId chat_id) -> T.pack $ show chat_id+ SomeChatId (ChatId chat_id) -> showText chat_id SomeChatUsername txt -> txt ] <>- maybe id (\t -> (Input "message_thread_id" (T.pack $ show t) :)) sendPhotoMessageThreadId+ maybe id (\t -> (Input "message_thread_id" (showText t) :)) sendPhotoMessageThreadId ( maybe id (const (Input "thumb" "attach://thumb" :)) sendPhotoThumb $ maybe id (\t -> (Input "caption" t :)) sendPhotoCaption $ maybe id (\t -> (Input "parse_mode" (TL.toStrict . TL.replace "\"" "" $ encodeToLazyText t) :)) sendPhotoParseMode
src/Telegram/Bot/API/Methods/SendVideo.hs view
@@ -24,7 +24,6 @@ import Servant.Multipart.Client import Servant.Client hiding (Response) -import qualified Data.Text as T import qualified Data.Text.Lazy as TL import Telegram.Bot.API.Internal.Utils@@ -69,11 +68,11 @@ MultipartData fields [] where fields = [ Input "chat_id" $ case sendVideoChatId of- SomeChatId (ChatId chat_id) -> T.pack $ show chat_id+ SomeChatId (ChatId chat_id) -> showText chat_id SomeChatUsername txt -> txt ] <> catMaybes [ sendVideoMessageThreadId <&>- \t -> Input "message_thread_id" (T.pack $ show t)+ \t -> Input "message_thread_id" (showText t) , sendVideoCaption <&> \t -> Input "caption" t , sendVideoParseMode <&>
src/Telegram/Bot/API/Methods/SendVideoNote.hs view
@@ -24,7 +24,6 @@ import Servant.Multipart.Client import Servant.Client hiding (Response) -import qualified Data.Text as T import qualified Data.Text.Lazy as TL import Telegram.Bot.API.Internal.Utils@@ -61,11 +60,11 @@ MultipartData fields [] where fields = [ Input "chat_id" $ case sendVideoNoteChatId of- SomeChatId (ChatId chat_id) -> T.pack $ show chat_id+ SomeChatId (ChatId chat_id) -> showText chat_id SomeChatUsername txt -> txt ] <> catMaybes [ sendVideoNoteMessageThreadId <&>- \t -> Input "message_thread_id" (T.pack $ show t)+ \t -> Input "message_thread_id" (showText t) , sendVideoNoteDisableNotification <&> \t -> Input "disable_notification" (bool "false" "true" t) , sendVideoNoteProtectContent <&>
src/Telegram/Bot/API/Methods/SendVoice.hs view
@@ -24,7 +24,6 @@ import Servant.Multipart.Client import Servant.Client hiding (Response) -import qualified Data.Text as T import qualified Data.Text.Lazy as TL import Telegram.Bot.API.Internal.Utils@@ -62,11 +61,11 @@ MultipartData fields [] where fields = [ Input "chat_id" $ case sendVoiceChatId of- SomeChatId (ChatId chat_id) -> T.pack $ show chat_id+ SomeChatId (ChatId chat_id) -> showText chat_id SomeChatUsername txt -> txt ] <> catMaybes [ sendVoiceMessageThreadId <&>- \t -> Input "message_thread_id" (T.pack $ show t)+ \t -> Input "message_thread_id" (showText t) , sendVoiceCaption <&> \t -> Input "caption" t , sendVoiceParseMode <&>
src/Telegram/Bot/API/Methods/SetChatPhoto.hs view
@@ -14,11 +14,10 @@ import Servant.Multipart.Client import Servant.Client hiding (Response) -import qualified Data.Text as T- import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types import Telegram.Bot.API.Internal.TH+import Telegram.Bot.API.Internal.Utils (showText) -- ** 'setChatPhoto' @@ -33,7 +32,7 @@ makeFile "photo" setChatPhotoPhoto (MultipartData fields []) where fields = [ Input "chat_id" $ case setChatPhotoChatId of- SomeChatId (ChatId chat_id) -> T.pack $ show chat_id+ SomeChatId (ChatId chat_id) -> showText chat_id SomeChatUsername txt -> txt ]
src/Telegram/Bot/API/Stickers.hs view
@@ -13,6 +13,8 @@ import Data.Aeson import Data.Aeson.Text import Data.Bool+import Data.Functor+import Data.Maybe (catMaybes) import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.Lazy as TL@@ -23,14 +25,11 @@ import Servant.Multipart.API import Servant.Multipart.Client +import Telegram.Bot.API.Internal.TH (makeDefault) import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests (Response) import Telegram.Bot.API.Types-import Data.Maybe (catMaybes)-import Data.Functor-import Telegram.Bot.API.Internal.TH (makeDefault) - -- | Type of uploaded sticker file. Static or animated. data StickerType = PngSticker -- ^ 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. 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.@@ -66,11 +65,11 @@ makeFile "sticker" sendStickerSticker (MultipartData fields []) where fields = [ Input "chat_id" $ case sendStickerChatId of- SomeChatId (ChatId chat_id) -> T.pack $ show chat_id+ SomeChatId (ChatId chat_id) -> showText chat_id SomeChatUsername txt -> txt ] <> catMaybes [ sendStickerMessageThreadId <&>- \t -> Input "message_thread_id" (T.pack $ show t)+ \t -> Input "message_thread_id" (showText t) , sendStickerDisableNotification <&> \t -> Input "disable_notification" (bool "false" "true" t) , sendStickerProtectContent <&>
src/Telegram/Bot/API/Types/Common.hs view
@@ -75,8 +75,11 @@ newtype ShippingOptionId = ShippingOptionId Text deriving (Eq, Show, Generic, ToJSON, FromJSON) -newtype WebAppInfo = WebAppInfo { webAppInfoUrl :: Text }- deriving (Generic, Show, ToJSON, FromJSON)+data WebAppInfo = WebAppInfo { webAppInfoUrl :: Text }+ deriving (Generic, Show)++instance ToJSON WebAppInfo where toJSON = gtoJSON+instance FromJSON WebAppInfo where parseJSON = gparseJSON newtype CallbackQueryId = CallbackQueryId Text deriving (Eq, Show, Generic, ToJSON, FromJSON)
@@ -13,7 +13,7 @@ -- | This object contains information about the users whose identifiers were shared with the bot using a 'KeyboardButtonRequestUsers' button. data UsersShared = UsersShared { usersSharedRequestId :: RequestId -- ^ Identifier of the request.- , usersSharedUserId :: [SharedUser] -- ^ Information about users shared with the bot.+ , usersSharedUsers :: [SharedUser] -- ^ Information about users shared with the bot. } deriving (Generic, Show)
src/Telegram/Bot/API/Webhook.hs view
@@ -32,7 +32,7 @@ import Servant.Multipart.API import Servant.Multipart.Client (genBoundary) -import Telegram.Bot.API.Internal.Utils (gtoJSON)+import Telegram.Bot.API.Internal.Utils (gtoJSON, showText) import Telegram.Bot.API.MakingRequests (Response) import Telegram.Bot.API.Types (InputFile, makeFile) import Telegram.Bot.API.Internal.TH (makeDefault)@@ -67,7 +67,7 @@ <> catMaybes [ setWebhookSecretToken <&> \t -> Input "secret_token" $ Text.pack t, setWebhookIpAddress <&> \t -> Input "ip_address" $ Text.pack t,- setWebhookMaxConnections <&> \t -> Input "max_connections" $ Text.pack $ show t,+ setWebhookMaxConnections <&> \t -> Input "max_connections" $ showText t, setWebhookDropPendingUpdates <&> \t -> Input "drop_pending_updates" (bool "false" "true" t), setWebhookAllowedUpdates <&> \t -> Input "allowed_updates" (arrToJson t) ]
telegram-bot-api.cabal view
@@ -1,7 +1,7 @@ cabal-version: 1.12 name: telegram-bot-api-version: 7.4.4+version: 7.4.5 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> .