telegram-api 0.6.1.0 → 0.6.1.1
raw patch · 6 files changed
+37/−14 lines, 6 files
Files
- CHANGELOG.md +15/−0
- src/Web/Telegram/API/Bot/Data.hs +14/−8
- src/Web/Telegram/API/Bot/Requests.hs +3/−2
- src/Web/Telegram/API/Bot/Responses.hs +3/−2
- telegram-api.cabal +1/−1
- test/MainSpec.hs +1/−1
CHANGELOG.md view
@@ -1,3 +1,18 @@+## 0.6.1.1++Bugfixes:++* Migration to `Int64` to represent chat id and fix integer overflow issue++## 0.6.1.0++* Added `ChatId` data type since it can be integer or string starting from `@`, f.e. `@channelusername`+* Changes in `getUpdates` and `getUpdateM` function++## 0.6.0.1++* Bump aeson upper bound to include 1.1.*+ ## 0.6.0.0 * Added `TelegramClient`, see example of usage in README.md
src/Web/Telegram/API/Bot/Data.hs view
@@ -1,5 +1,5 @@-{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveAnyClass #-}+{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} -- | This module contains objects which represent data of Telegram Bot API responses@@ -65,12 +65,13 @@ import Prelude hiding (id) import Data.Aeson-import Data.Maybe() import Data.Aeson.Types-import Data.Text (Text) import qualified Data.Char as Char-import GHC.Generics+import Data.Int (Int64) import Data.List+import Data.Text (Text)+import GHC.Generics+ import Web.Telegram.API.Bot.JsonExt -- | This object represents a Telegram user or bot.@@ -105,8 +106,13 @@ -- | This object represents a chat. data Chat = Chat- {- chat_id :: Int -- ^ Unique identifier for this chat, not exceeding 1e13 by absolute value+ { chat_id :: Int64+ -- ^ Unique identifier for this chat.+ -- This number may be greater than 32 bits and some programming languages+ -- may have difficulty/silent defects in interpreting it.+ -- But it is smaller than 52 bits,+ -- so a signed 64 bit integer or double-precision float type are safe for+ -- storing this identifier. , chat_type :: ChatType -- ^ Type of chat, can be either 'Private', 'Group', 'Supergroup' or 'Channel' , chat_title :: Maybe Text -- ^ Title, for channels and group chats , chat_username :: Maybe Text -- ^ Username, for private chats and channels if available@@ -811,8 +817,8 @@ , group_chat_created :: Maybe Bool -- ^ Service message: the group has been created , supergroup_chat_created :: Maybe Bool -- ^ Service message: the supergroup has been created , channel_chat_created :: Maybe Bool -- ^ Service message: the channel has been created- , migrate_to_chat_id :: Maybe Int -- ^ The group has been migrated to a supergroup with the specified identifier, not exceeding 1e13 by absolute value- , migrate_from_chat_id :: Maybe Int -- ^ The supergroup has been migrated from a group with the specified identifier, not exceeding 1e13 by absolute value+ , migrate_to_chat_id :: Maybe Int64 -- ^ The group has been migrated to a supergroup with the specified identifier, not exceeding 1e13 by absolute value+ , migrate_from_chat_id :: Maybe Int64 -- ^ The supergroup has been migrated from a group with the specified identifier, not exceeding 1e13 by absolute value , pinned_message :: Maybe Message -- ^ Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply. } deriving (FromJSON, ToJSON, Show, Generic)
src/Web/Telegram/API/Bot/Requests.hs view
@@ -73,6 +73,7 @@ import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as LBS import Data.Maybe+import Data.Int (Int64) import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.Encoding as T@@ -174,7 +175,7 @@ getUpdatesRequest = GetUpdatesRequest Nothing Nothing Nothing Nothing -- | Unique identifier for the target chat or username of the target channel (in the format @@channelusername@)-data ChatId = ChatId Integer | ChatChannel Text+data ChatId = ChatId Int64 | ChatChannel Text deriving (Show) instance ToJSON ChatId where@@ -184,7 +185,7 @@ instance FromJSON ChatId where parseJSON value@Number{} = ChatId <$> parseJSON value parseJSON (String text) = pure $ ChatChannel text- parseJSON wat = typeMismatch "Integer or String" wat+ parseJSON wat = typeMismatch "Int64 or String" wat chatIdToPart :: ChatId -> Text chatIdToPart (ChatId integer) = tshow integer
src/Web/Telegram/API/Bot/Responses.hs view
@@ -28,6 +28,7 @@ import Data.Aeson import GHC.Generics+import Data.Int (Int64) import Web.Telegram.API.Bot.Data import Web.Telegram.API.Bot.JsonExt @@ -39,8 +40,8 @@ data ResponseParameters = ResponseParameters {- res_migrate_to_chat_id :: Maybe Int -- ^ The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.- , res_retry_after :: Maybe Int -- ^ In case of exceeding flood control, the number of seconds left to wait before the request can be repeated+ res_migrate_to_chat_id :: Maybe Int64 -- ^ The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.+ , res_retry_after :: Maybe Int -- ^ In case of exceeding flood control, the number of seconds left to wait before the request can be repeated } deriving (Show, Generic) instance FromJSON ResponseParameters where
telegram-api.cabal view
@@ -1,5 +1,5 @@ name: telegram-api-version: 0.6.1.0+version: 0.6.1.1 synopsis: Telegram Bot API bindings description: High-level bindings to the Telegram Bot API homepage: http://github.com/klappvisor/haskell-telegram-api#readme
test/MainSpec.hs view
@@ -264,7 +264,7 @@ it "should get user profile photos" $ do Right Response { result = photos } <- do let ChatId userId = chatId- getUserProfilePhotos token userId Nothing Nothing manager+ getUserProfilePhotos token (fromIntegral userId) Nothing Nothing manager total_count photos `shouldSatisfy` (>= 0) describe "/setWebhook and /getWebhookInfo" $ do