Skip to content

Commit

Permalink
Merge pull request #180 from fizruk/173-missing-update-types
Browse files Browse the repository at this point in the history
Add missing update types
  • Loading branch information
swamp-agr authored May 20, 2024
2 parents 5db1673 + cb30980 commit 8adbe0b
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 9 deletions.
31 changes: 22 additions & 9 deletions telegram-bot-api/src/Telegram/Bot/API/GettingUpdates.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions telegram-bot-api/src/Telegram/Bot/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions telegram-bot-api/src/Telegram/Bot/API/Types/BusinessConnection.hs
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions telegram-bot-api/telegram-bot-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8adbe0b

Please sign in to comment.