diff --git a/telegram-bot-api/src/Telegram/Bot/API/GettingUpdates.hs b/telegram-bot-api/src/Telegram/Bot/API/GettingUpdates.hs index 041365e..fa44e42 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/GettingUpdates.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/GettingUpdates.hs @@ -32,16 +32,16 @@ data Update = Update , updateMessage :: Maybe Message -- ^ New incoming message of any kind — text, photo, sticker, etc. , updateEditedMessage :: Maybe Message -- ^ New version of a message that is known to the bot and was edited , updateChannelPost :: Maybe Message -- ^ New incoming channel post of any kind — text, photo, sticker, etc. - , updateMessageReaction :: Maybe MessageReactionUpdated -- ^ A reaction to a message was changed by a user. The bot must be an administrator in the chat and must explicitly specify "message_reaction" in the list of allowed_updates to receive these updates. The update isn't received for reactions set by bots. - , updateMessageReactionCount :: Maybe MessageReactionCountUpdated -- ^ Reactions to a message with anonymous reactions were changed. The bot must be an administrator in the chat and must explicitly specify "message_reaction_count" in the list of allowed_updates to receive these updates. The updates are grouped and can be sent with delay up to a few minutes. - , updateEditedChannelPost :: Maybe Message -- ^ New version of a channel post that is known to the bot and was edited - - , updateInlineQuery :: Maybe InlineQuery -- ^ New incoming inline query - + , updateEditedChannelPost :: Maybe Message -- ^ New version of a channel post that is known to the bot and was edited. + , updateBusinessConnection :: Maybe BusinessConnection -- ^ The bot was connected to or disconnected from a business account, or a user edited an existing connection with the bot. + , updateBusinessMessage :: Maybe Message -- ^ New message from a connected business account. + , updateEditedBusinessMessage :: Maybe Message -- ^ New version of a message from a connected business account. + , updateDeletedBusinessMessages :: Maybe BusinessMessagesDeleted -- ^ Messages were deleted from a connected business account. + , updateMessageReaction :: Maybe MessageReactionUpdated -- ^ A reaction to a message was changed by a user. The bot must be an administrator in the chat and must explicitly specify @message_reaction@ in the list of /allowed_updates/ to receive these updates. The update isn't received for reactions set by bots. + , updateMessageReactionCount :: Maybe MessageReactionCountUpdated -- ^ Reactions to a message with anonymous reactions were changed. The bot must be an administrator in the chat and must explicitly specify @message_reaction_count@ in the list of /allowed_updates/ to receive these updates. The updates are grouped and can be sent with delay up to a few minutes. + , updateInlineQuery :: Maybe InlineQuery -- ^ New incoming inline query. , updateChosenInlineResult :: Maybe ChosenInlineResult -- ^ The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot. - - , updateCallbackQuery :: Maybe CallbackQuery -- ^ New incoming callback query - + , updateCallbackQuery :: Maybe CallbackQuery -- ^ New incoming callback query. , updateShippingQuery :: Maybe ShippingQuery -- ^ New incoming shipping query. Only for invoices with flexible price , updatePreCheckoutQuery :: Maybe PreCheckoutQuery -- ^ New incoming pre-checkout query. Contains full information about checkout , updatePoll :: Maybe Poll -- ^ New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot. @@ -108,11 +108,24 @@ data UpdateType | UpdateEditedMessage | UpdateChannelPost | UpdateEditedChannelPost + | UpdateBusinessConnection + | UpdateBusinessMessage + | UpdateEditedBusinessMessage + | UpdateDeletedBusinessMessages + | UpdateMessageReaction + | UpdateMessageReactionCount | UpdateInlineQuery | UpdateChosenInlineResult | UpdateCallbackQuery | UpdateShippingQuery | UpdatePreCheckoutQuery + | UpdatePoll + | UpdatePollAnswer + | UpdateMyChatMember + | UpdateChatMember + | UpdateChatJoinRequest + | UpdateChatBoost + | UpdateRemovedChatBoost deriving (Generic) instance ToJSON UpdateType where toJSON = gtoJSON diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types.hs b/telegram-bot-api/src/Telegram/Bot/API/Types.hs index e282f28..b13615b 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types.hs @@ -20,6 +20,8 @@ module Telegram.Bot.API.Types , module Telegram.Bot.API.Types.BotDescription , module Telegram.Bot.API.Types.BotName , module Telegram.Bot.API.Types.BotShortDescription + , module Telegram.Bot.API.Types.BusinessConnection + , module Telegram.Bot.API.Types.BusinessMessagesDeleted , module Telegram.Bot.API.Types.CallbackGame , module Telegram.Bot.API.Types.CallbackQuery , module Telegram.Bot.API.Types.Chat @@ -127,6 +129,8 @@ import Telegram.Bot.API.Types.BotCommandScope import Telegram.Bot.API.Types.BotDescription import Telegram.Bot.API.Types.BotName import Telegram.Bot.API.Types.BotShortDescription +import Telegram.Bot.API.Types.BusinessConnection +import Telegram.Bot.API.Types.BusinessMessagesDeleted import Telegram.Bot.API.Types.CallbackGame import Telegram.Bot.API.Types.CallbackQuery import Telegram.Bot.API.Types.Chat diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessConnection.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessConnection.hs new file mode 100644 index 0000000..f5bbdbd --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessConnection.hs @@ -0,0 +1,27 @@ +{-# LANGUAGE DeriveGeneric #-} +module Telegram.Bot.API.Types.BusinessConnection where + +import Data.Aeson (FromJSON (..), ToJSON (..)) +import Data.Text (Text) +import Data.Time.Clock.POSIX (POSIXTime) +import GHC.Generics (Generic) + +import Telegram.Bot.API.Types.Common +import Telegram.Bot.API.Types.User +import Telegram.Bot.API.Internal.Utils + +-- ** 'BusinessConnection' + +-- | Describes the connection of the bot with a business account. +data BusinessConnection = BusinessConnection + { businessConnectionId :: Text -- ^ Unique identifier of the business connection. + , businessConnectionUser :: User -- ^ Business account user that created the business connection. + , businessConnectionUserChatId :: ChatId -- ^ Identifier of a private chat with the user who created the business connection. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. + , businessConnectionDate :: POSIXTime -- ^ Date the connection was established in Unix time. + , businessConnectionCanReply :: Bool -- ^ 'True', if the bot can act on behalf of the business account in chats that were active in the last 24 hours. + , businessConnectionIsEnabled :: Bool -- ^ 'True', if the connection is active. + } + deriving (Generic, Show) + +instance ToJSON BusinessConnection where toJSON = gtoJSON +instance FromJSON BusinessConnection where parseJSON = gparseJSON diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessMessagesDeleted.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessMessagesDeleted.hs new file mode 100644 index 0000000..ea95b60 --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessMessagesDeleted.hs @@ -0,0 +1,23 @@ +{-# LANGUAGE DeriveGeneric #-} +module Telegram.Bot.API.Types.BusinessMessagesDeleted where + +import Data.Aeson (FromJSON (..), ToJSON (..)) +import Data.Text (Text) +import GHC.Generics (Generic) + +import Telegram.Bot.API.Types.Chat +import Telegram.Bot.API.Types.Common +import Telegram.Bot.API.Internal.Utils + +-- ** 'BusinessMessagesDeleted' + +-- | This object is received when messages are deleted from a connected business account. +data BusinessMessagesDeleted = BusinessMessagesDeleted + { businessMessagesDeletedBusinessConnectionId :: Text -- ^ Unique identifier of the business connection. + , businessMessagesDeletedChat :: Chat -- ^ Information about a chat in the business account. The bot may not have access to the chat or the corresponding user. + , businessMessagesDeletedMessageIds :: [MessageId] -- ^ The list of identifiers of deleted messages in the chat of the business account. + } + deriving (Generic, Show) + +instance ToJSON BusinessMessagesDeleted where toJSON = gtoJSON +instance FromJSON BusinessMessagesDeleted where parseJSON = gparseJSON diff --git a/telegram-bot-api/telegram-bot-api.cabal b/telegram-bot-api/telegram-bot-api.cabal index e5bda13..a7144c0 100644 --- a/telegram-bot-api/telegram-bot-api.cabal +++ b/telegram-bot-api/telegram-bot-api.cabal @@ -127,6 +127,8 @@ library Telegram.Bot.API.Types.BotDescription Telegram.Bot.API.Types.BotName Telegram.Bot.API.Types.BotShortDescription + Telegram.Bot.API.Types.BusinessConnection + Telegram.Bot.API.Types.BusinessMessagesDeleted Telegram.Bot.API.Types.CallbackGame Telegram.Bot.API.Types.CallbackQuery Telegram.Bot.API.Types.Chat