From 032540d87ef811fc1477896d0d4033ce3ea0af47 Mon Sep 17 00:00:00 2001 From: Andrey Prokopenko Date: Fri, 24 May 2024 21:38:10 +0200 Subject: [PATCH] Bot API 7.3 --- .../API/Methods/EditMessageLiveLocation.hs | 13 +-- .../src/Telegram/Bot/API/Methods/GetChat.hs | 4 +- .../src/Telegram/Bot/API/Methods/SendPoll.hs | 26 ++--- .../src/Telegram/Bot/API/Types.hs | 10 +- .../Telegram/Bot/API/Types/BackgroundFill.hs | 71 ++++++++++++++ .../Telegram/Bot/API/Types/BackgroundType.hs | 97 +++++++++++++++++++ .../src/Telegram/Bot/API/Types/Chat.hs | 86 +++------------- .../Telegram/Bot/API/Types/ChatBackground.hs | 19 ++++ .../Telegram/Bot/API/Types/ChatFullInfo.hs | 77 +++++++++++++++ .../Bot/API/Types/ChatMemberUpdated.hs | 1 + .../src/Telegram/Bot/API/Types/ChatType.hs | 24 +++++ .../Telegram/Bot/API/Types/GiveawayWinners.hs | 2 +- .../Bot/API/Types/InlineKeyboardButton.hs | 6 +- .../Telegram/Bot/API/Types/InputPollOption.hs | 23 +++++ .../src/Telegram/Bot/API/Types/Message.hs | 14 +-- .../src/Telegram/Bot/API/Types/Poll.hs | 3 +- .../src/Telegram/Bot/API/Types/PollOption.hs | 2 + telegram-bot-api/telegram-bot-api.cabal | 8 +- 18 files changed, 379 insertions(+), 107 deletions(-) create mode 100644 telegram-bot-api/src/Telegram/Bot/API/Types/BackgroundFill.hs create mode 100644 telegram-bot-api/src/Telegram/Bot/API/Types/BackgroundType.hs create mode 100644 telegram-bot-api/src/Telegram/Bot/API/Types/ChatBackground.hs create mode 100644 telegram-bot-api/src/Telegram/Bot/API/Types/ChatFullInfo.hs create mode 100644 telegram-bot-api/src/Telegram/Bot/API/Types/ChatType.hs create mode 100644 telegram-bot-api/src/Telegram/Bot/API/Types/InputPollOption.hs diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/EditMessageLiveLocation.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/EditMessageLiveLocation.hs index 52cc2f0..201c485 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/EditMessageLiveLocation.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/EditMessageLiveLocation.hs @@ -20,12 +20,13 @@ import Telegram.Bot.API.Internal.TH -- | Request parameters for 'editMessageLiveLocation'. data EditMessageLiveLocationRequest = EditMessageLiveLocationRequest - { editMessageLiveLocationChatId :: Maybe SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername) - , editMessageLiveLocationMessageId :: Maybe MessageId -- ^ Required if inline_message_id is not specified. Identifier of the message with live location to stop - , editMessageLiveLocationInlineMessageId :: Maybe Text -- ^ Required if chat_id and message_id are not specified. Identifier of the inline message - , editMessageLiveLocationLatitude :: Float -- ^ Latitude of new location - , editMessageLiveLocationLongitude :: Float -- ^ Longitude of new location - , editMessageLiveLocationHorizontalAccuracy :: Maybe Float -- ^ The radius of uncertainty for the location, measured in meters; 0-1500 + { editMessageLiveLocationChatId :: Maybe SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format \@channelusername). + , editMessageLiveLocationMessageId :: Maybe MessageId -- ^ Required if inline_message_id is not specified. Identifier of the message with live location to stop. + , editMessageLiveLocationInlineMessageId :: Maybe Text -- ^ Required if chat_id and message_id are not specified. Identifier of the inline message. + , editMessageLiveLocationLatitude :: Float -- ^ Latitude of new location. + , editMessageLiveLocationLongitude :: Float -- ^ Longitude of new location. + , editMessageLiveLocationLivePeriod :: Maybe Int -- ^ New period in seconds during which the location can be updated, starting from the message send date. If @0x7FFFFFFF@ is specified, then the location can be updated forever. Otherwise, the new value must not exceed the current @live_period@ by more than a day, and the live location expiration date must remain within the next 90 days. If not specified, then @live_period@ remains unchanged. + , editMessageLiveLocationHorizontalAccuracy :: Maybe Float -- ^ The radius of uncertainty for the location, measured in meters; 0-1500. , editMessageLiveLocationHeading :: Maybe Int -- ^ Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. , editMessageLiveLocationProximityAlertRadius :: Maybe Int -- ^ Maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified. , editMessageLiveLocationReplyMarkup :: Maybe InlineKeyboardMarkup -- ^ 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. diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/GetChat.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/GetChat.hs index 257c32a..e023a17 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/GetChat.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/GetChat.hs @@ -14,7 +14,7 @@ import Telegram.Bot.API.Types type GetChat = "getChat" :> RequiredQueryParam "chat_id" SomeChatId - :> Post '[JSON] (Response Chat) + :> Post '[JSON] (Response ChatFullInfo) -- | Use this method to get up to date information -- about the chat (current name of the user for @@ -22,5 +22,5 @@ type GetChat = "getChat" -- 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) + -> ClientM (Response ChatFullInfo) getChat = client (Proxy @GetChat) diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendPoll.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendPoll.hs index 2576116..813dd2e 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendPoll.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendPoll.hs @@ -24,21 +24,23 @@ data SendPollRequest = SendPollRequest { sendPollBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. , sendPollChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). , sendPollMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. - , sendPollQuestion :: Text -- ^ Poll question, 1-300 characters - , sendPollOptions :: [Text] -- ^ A JSON-serialized list of answer options, 2-10 strings 1-100 characters each - , sendPollIsAnonymous :: Maybe Bool -- ^ True, if the poll needs to be anonymous, defaults to True - , sendPollType :: Maybe Text -- ^ Poll type, “quiz” or “regular”, defaults to “regular” - , sendPollAllowsMultipleAnswers :: Maybe Bool -- ^ True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False - , sendPollCorrectOptionId :: Maybe Int -- ^ 0-based identifier of the correct answer option, required for polls in quiz mode - , sendPollExplanation :: Maybe Text -- ^ Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing + , sendPollQuestion :: Text -- ^ Poll question, 1-300 characters. + , sendPollQuestionParseMode :: Maybe ParseMode -- ^ Mode for parsing entities in the question. See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details. Currently, only custom emoji entities are allowed. + , sendPollQuestionEntities :: Maybe [MessageEntity] -- ^ A JSON-serialized list of special entities that appear in the poll question. It can be specified instead of @question_parse_mode@. + , sendPollOptions :: [InputPollOption] -- ^ A JSON-serialized list of answer options, 2-10 strings 1-100 characters each. + , sendPollIsAnonymous :: Maybe Bool -- ^ True, if the poll needs to be anonymous, defaults to 'True'. + , sendPollType :: Maybe Text -- ^ Poll type, “quiz” or “regular”, defaults to “regular”. + , sendPollAllowsMultipleAnswers :: Maybe Bool -- ^ True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to 'False'. + , sendPollCorrectOptionId :: Maybe Int -- ^ 0-based identifier of the correct answer option, required for polls in quiz mode. + , sendPollExplanation :: Maybe Text -- ^ Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing. , sendPollExplanationParseMode :: Maybe ParseMode -- ^ Send 'MarkdownV2', 'HTML' or 'Markdown' (legacy), if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. - , sendPollExplanationEntities :: Maybe [MessageEntity] -- ^ A JSON-serialized list of special entities that appear in the poll explanation, which can be specified instead of parse_mode - , sendPollOpenPeriod :: Maybe Int -- ^ Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date. - , sendPollCloseDate :: Maybe Int -- ^ Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with open_period. + , sendPollExplanationEntities :: Maybe [MessageEntity] -- ^ A JSON-serialized list of special entities that appear in the poll explanation, which can be specified instead of @parse_mode@. + , sendPollOpenPeriod :: Maybe Int -- ^ Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with @close_date@. + , sendPollCloseDate :: Maybe Int -- ^ Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with @open_period@. , sendPollIsClosed :: Maybe Bool -- ^ Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. , sendPollDisableNotification :: Maybe Bool -- ^ Sends the message silently. Users will receive a notification with no sound. - , sendPollProtectContent :: Maybe Bool -- ^ Protects the contents of the sent message from forwarding and saving - , sendPollReplyToMessageId :: Maybe MessageId -- ^ If the message is a reply, ID of the original message + , sendPollProtectContent :: Maybe Bool -- ^ Protects the contents of the sent message from forwarding and saving. + , sendPollReplyToMessageId :: Maybe MessageId -- ^ If the message is a reply, ID of the original message. , sendPollReplyParameters :: Maybe ReplyParameters -- ^ Description of the message to reply to. , sendPollReplyMarkup :: Maybe InlineKeyboardMarkup -- ^ 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. } diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types.hs b/telegram-bot-api/src/Telegram/Bot/API/Types.hs index 87a7bcc..9419ee0 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types.hs @@ -30,12 +30,13 @@ module Telegram.Bot.API.Types , module Telegram.Bot.API.Types.CallbackGame , module Telegram.Bot.API.Types.CallbackQuery , module Telegram.Bot.API.Types.Chat + , module Telegram.Bot.API.Types.ChatAdministratorRights , module Telegram.Bot.API.Types.ChatBoost , module Telegram.Bot.API.Types.ChatBoostAdded , module Telegram.Bot.API.Types.ChatBoostRemoved , module Telegram.Bot.API.Types.ChatBoostSource , module Telegram.Bot.API.Types.ChatBoostUpdated - , module Telegram.Bot.API.Types.ChatAdministratorRights + , module Telegram.Bot.API.Types.ChatFullInfo , module Telegram.Bot.API.Types.ChatInviteLink , module Telegram.Bot.API.Types.ChatJoinRequest , module Telegram.Bot.API.Types.ChatLocation @@ -44,6 +45,7 @@ module Telegram.Bot.API.Types , module Telegram.Bot.API.Types.ChatPermissions , module Telegram.Bot.API.Types.ChatPhoto , module Telegram.Bot.API.Types.ChatShared + , module Telegram.Bot.API.Types.ChatType , module Telegram.Bot.API.Types.Common , module Telegram.Bot.API.Types.Contact , module Telegram.Bot.API.Types.CopyMessageId @@ -70,6 +72,7 @@ module Telegram.Bot.API.Types , module Telegram.Bot.API.Types.InlineKeyboardButton , module Telegram.Bot.API.Types.InlineKeyboardMarkup , module Telegram.Bot.API.Types.InputMedia + , module Telegram.Bot.API.Types.InputPollOption , module Telegram.Bot.API.Types.Invoice , module Telegram.Bot.API.Types.KeyboardButton , module Telegram.Bot.API.Types.KeyboardButtonRequestChat @@ -146,12 +149,13 @@ import Telegram.Bot.API.Types.BusinessOpeningHoursInterval import Telegram.Bot.API.Types.CallbackGame import Telegram.Bot.API.Types.CallbackQuery import Telegram.Bot.API.Types.Chat +import Telegram.Bot.API.Types.ChatAdministratorRights import Telegram.Bot.API.Types.ChatBoost import Telegram.Bot.API.Types.ChatBoostAdded import Telegram.Bot.API.Types.ChatBoostRemoved import Telegram.Bot.API.Types.ChatBoostSource import Telegram.Bot.API.Types.ChatBoostUpdated -import Telegram.Bot.API.Types.ChatAdministratorRights +import Telegram.Bot.API.Types.ChatFullInfo import Telegram.Bot.API.Types.ChatInviteLink import Telegram.Bot.API.Types.ChatJoinRequest import Telegram.Bot.API.Types.ChatLocation @@ -160,6 +164,7 @@ import Telegram.Bot.API.Types.ChatMemberUpdated import Telegram.Bot.API.Types.ChatPermissions import Telegram.Bot.API.Types.ChatPhoto import Telegram.Bot.API.Types.ChatShared +import Telegram.Bot.API.Types.ChatType import Telegram.Bot.API.Types.Common import Telegram.Bot.API.Types.Contact import Telegram.Bot.API.Types.CopyMessageId @@ -186,6 +191,7 @@ import Telegram.Bot.API.Types.GeneralForumTopicUnhidden import Telegram.Bot.API.Types.InlineKeyboardButton import Telegram.Bot.API.Types.InlineKeyboardMarkup import Telegram.Bot.API.Types.InputMedia +import Telegram.Bot.API.Types.InputPollOption import Telegram.Bot.API.Types.Invoice import Telegram.Bot.API.Types.KeyboardButton import Telegram.Bot.API.Types.KeyboardButtonRequestChat diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/BackgroundFill.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/BackgroundFill.hs new file mode 100644 index 0000000..c166b96 --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/BackgroundFill.hs @@ -0,0 +1,71 @@ +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE OverloadedStrings #-} +module Telegram.Bot.API.Types.BackgroundFill where + +import Data.Aeson (FromJSON (..), ToJSON (..), Value (..), (.=), (.:), withObject) +import Data.Aeson.Types (Parser) +import Data.Text +import GHC.Generics (Generic) + +import qualified Data.Text as Text + +import Telegram.Bot.API.Types.Common +import Telegram.Bot.API.Internal.Utils + +-- ** 'BackgroundFill' + +-- | This object describes the way a background is filled based on the selected colors. Currently, it can be one of +-- +-- * BackgroundFillSolid +-- * BackgroundFillGradient +-- * BackgroundFillFreeformGradient +-- +data BackgroundFill + -- | The background is filled using the selected color. + = BackgroundFillSolid + { backgroundFillSolidType :: Text -- ^ Type of the background fill, always “solid”. + , backgroundFillSolidColor :: Int -- ^ The color of the background fill in the RGB24 format. + } + -- | The background is a gradient fill. + | BackgroundFillGradient + { backgroundFillGradientType :: Text -- ^ Type of the background fill, always “gradient”. + , backgroundFillGradientTopColor :: Int -- ^ Top color of the gradient in the RGB24 format. + , backgroundFillGradientBottomColor :: Int -- ^ Bottom color of the gradient in the RGB24 format. + , backgroundFillGradientRotationAngle :: Int -- ^ Clockwise rotation angle of the background fill in degrees; @0-359@. + } + -- | The background is a freeform gradient that rotates after every message in the chat. + | BackgroundFillFreeformGradient + { backgroundFillFreeformGradientType :: Text -- ^ Type of the background fill, always “freeform_gradient”. + , backgroundFillFreeformGradientColors :: [Int] -- ^ A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format. + } + deriving (Generic, Show) + +instance ToJSON BackgroundFill where + toJSON = \case + BackgroundFillSolid _t c -> addJsonFields + (Object mempty) + (addType "solid" ["color" .= c]) + BackgroundFillGradient _t tc bc ra -> addJsonFields + (Object mempty) + (addType "gradient" ["top_color" .= tc, "bottom_color" .= bc, "rotation_angle" .= ra]) + BackgroundFillFreeformGradient _t cs -> addJsonFields + (Object mempty) + (addType "freeform_gradient" ["colors" .= cs]) + +instance FromJSON BackgroundFill where + parseJSON = withObject "BackgroundFill" \o -> + (o .: "type" :: Parser Text) >>= \case + "solid" -> BackgroundFillSolid + <$> o .: "type" + <*> o .: "color" + "gradient" ->BackgroundFillGradient + <$> o .: "type" + <*> o .: "top_color" + <*> o .: "bottom_color" + <*> o .: "rotation_angle" + "freeform_gradient" -> BackgroundFillFreeformGradient + <$> o .: "type" + <*> o .: "colors" + t -> fail $ Text.unpack ("Unknown type: " <> t) diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/BackgroundType.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/BackgroundType.hs new file mode 100644 index 0000000..a5b50b0 --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/BackgroundType.hs @@ -0,0 +1,97 @@ +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE OverloadedStrings #-} +module Telegram.Bot.API.Types.BackgroundType where + +import Data.Aeson (FromJSON (..), ToJSON (..), Value (..), (.=), (.:), withObject) +import Data.Aeson.Types (Parser) +import Data.Text (Text) +import GHC.Generics (Generic) + +import qualified Data.Text as Text + +import Telegram.Bot.API.Types.BackgroundFill +import Telegram.Bot.API.Types.Common +import Telegram.Bot.API.Types.Document +import Telegram.Bot.API.Internal.Utils + +-- ** 'BackgroundType' + +-- | This object describes the type of a background. Currently, it can be one of +-- +-- * BackgroundTypeFill +-- * BackgroundTypeWallpaper +-- * BackgroundTypePattern +-- * BackgroundTypeChatTheme +-- +data BackgroundType + -- | The background is automatically filled based on the selected colors. + = BackgroundTypeFill + { backgroundTypeFillType :: Text -- ^ Type of the background, always “fill”. + , backgroundTypeFillFill :: BackgroundFill -- ^ The background fill. + , backgroundTypeFillDarkThemeDimming :: Int -- ^ Dimming of the background in dark themes, as a percentage; @0-100@. + } + -- | The background is a wallpaper in the JPEG format. + | BackgroundTypeWallpaper + { backgroundTypeWallpaperType :: Text -- ^ Type of the background, always “wallpaper”. + , backgroundTypeWallpaperDocument :: Document -- ^ Document with the wallpaper. + , backgroundTypeWallpaperDarkThemeDimming :: Int -- ^ Dimming of the background in dark themes, as a percentage; @0-100@. + , backgroundTypeWallpaperIsBlurred :: Maybe Bool -- ^ 'True', if the wallpaper is downscaled to fit in a @450x450@ square and then box-blurred with radius 12. + , backgroundTypeWallpaperIsMoving :: Maybe Bool -- ^ 'True', if the background moves slightly when the device is tilted. + } + -- | The background is a PNG or TGV (gzipped subset of SVG with MIME type “application/x-tgwallpattern”) pattern to be combined with the background fill chosen by the user. + | BackgroundTypePattern + { backgroundTypePatternType :: Text -- ^ Type of the background, always “pattern”. + , backgroundTypePatternDocument :: Document -- ^ Document with the pattern. + , backgroundTypePatternFill :: BackgroundFill -- ^ The background fill that is combined with the pattern. + , backgroundTypePatternIntensity :: Int -- ^ Intensity of the pattern when it is shown above the filled background; @0-100@. + , backgroundTypePatternIsInverted :: Maybe Bool -- ^ 'True', if the background fill must be applied only to the pattern itself. All other pixels are black in this case. For dark themes only. + , backgroundTypePatternIsMoving :: Maybe Bool -- ^ 'True', if the background moves slightly when the device is tilted. + } + -- | The background is taken directly from a built-in chat theme. + | BackgroundTypeChatTheme + { backgroundTypeChatThemeType :: Text -- ^ Type of the background, always “chat_theme”. + , backgroundTypeChatThemeThemeName :: Text -- ^ Name of the chat theme, which is usually an emoji. + } + deriving (Generic, Show) + +instance ToJSON BackgroundType where + toJSON = \case + BackgroundTypeFill _t f dtd -> addJsonFields + (Object mempty) + (addType "fill" ["fill" .= f, "dark_theme_dimming" .= dtd]) + BackgroundTypeWallpaper _t d dtd ib im -> addJsonFields + (Object mempty) + (addType "wallpaper" ["document" .= d, "dark_theme_dimming" .= dtd, "is_blurred" .= ib, "is_moving" .= im]) + BackgroundTypePattern _t d f i ii im -> addJsonFields + (Object mempty) + (addType "pattern" ["document" .= d, "fill" .= f, "intensity" .= i, "is_inverted" .= ii, "is_moving" .= im]) + BackgroundTypeChatTheme _t tn -> addJsonFields + (Object mempty) + (addType "chat_theme" ["theme_name" .= tn]) + +instance FromJSON BackgroundType where + parseJSON = withObject "BackgroundType" \o -> + (o .: "type" :: Parser Text) >>= \case + "fill" -> BackgroundTypeFill + <$> o .: "type" + <*> o .: "fill" + <*> o .: "dark_theme_dimming" + "wallpaper" -> BackgroundTypeWallpaper + <$> o .: "type" + <*> o .: "document" + <*> o .: "dark_theme_dimming" + <*> o .: "is_blurred" + <*> o .: "is_moving" + "pattern" -> BackgroundTypePattern + <$> o .: "type" + <*> o .: "document" + <*> o .: "fill" + <*> o .: "intensity" + <*> o .: "is_inverted" + <*> o .: "is_moving" + "chat_theme" -> BackgroundTypeChatTheme + <$> o .: "type" + <*> o .: "theme_name" + t -> fail $ Text.unpack ("Unknown type: " <> t) diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/Chat.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/Chat.hs index dcdc33a..876c090 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/Chat.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/Chat.hs @@ -1,89 +1,27 @@ {-# LANGUAGE DeriveGeneric #-} module Telegram.Bot.API.Types.Chat where -import Data.Aeson (ToJSON(..), FromJSON(..)) -import Data.Time.Clock.POSIX (POSIXTime) -import Data.Text (Text) +import Data.Aeson (FromJSON (..), ToJSON (..)) +import Data.Text import GHC.Generics (Generic) -import Telegram.Bot.API.Types.Birthdate -import Telegram.Bot.API.Types.BusinessIntro -import Telegram.Bot.API.Types.BusinessLocation -import Telegram.Bot.API.Types.BusinessOpeningHours -import Telegram.Bot.API.Types.ChatLocation -import Telegram.Bot.API.Types.ChatPhoto -import Telegram.Bot.API.Types.ChatPermissions -import Telegram.Bot.API.Types.Common -import Telegram.Bot.API.Types.Message -import Telegram.Bot.API.Types.ReactionType import Telegram.Bot.API.Internal.Utils +import Telegram.Bot.API.Types.ChatType +import Telegram.Bot.API.Types.Common --- ** Chat +-- ** 'Chat' -- | This object represents a chat. --- --- data Chat = Chat - { chatId :: ChatId -- ^ 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. - , chatIsBot :: Maybe Bool -- ^ 'True', if this user is a bot. - , chatType :: ChatType -- ^ Type of chat. - , chatTitle :: Maybe Text -- ^ Title, for supergroups, channels and group chats - , chatUsername :: Maybe Text -- ^ Username, for private chats, supergroups and channels if available - , chatFirstName :: Maybe Text -- ^ First name of the other party in a private chat - , chatLastName :: Maybe Text -- ^ Last name of the other party in a private chat - , chatIsForum :: Maybe Bool -- ^ 'True', if the supergroup chat is a forum (has topics enabled). - , chatAccentColorId :: Maybe Int -- ^ Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See [accent colors](https://core.telegram.org/bots/api#accent-colors) for more details. Returned only in 'getChat'. Always returned in 'getChat'. - , chatMaxReactionCount :: Int -- ^ The maximum number of reactions that can be set on a message in the chat. - , chatPhoto :: Maybe ChatPhoto -- ^ Chat photo. Returned only in getChat. - , chatActiveUsernames :: Maybe Text -- ^ If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in 'getChat'. - , chatBirthdate :: Maybe Birthdate -- ^ For private chats, the date of birth of the user. - , chatBusinessIntro :: Maybe BusinessIntro -- ^ For private chats with business accounts, the intro of the business. - , chatBusinessLocation :: Maybe BusinessLocation -- ^ For private chats with business accounts, the location of the business. - , chatBusinessOpeningHours :: Maybe BusinessOpeningHours -- ^ For private chats with business accounts, the opening hours of the business. - , chatPersonalChat :: Maybe Chat -- ^ For private chats, the personal channel of the user. - , chatAvailableReactions :: Maybe [ReactionType] -- ^ List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. Returned only in 'getChat'. - , chatBackgroundCustomEmojiId :: Maybe Text -- ^ Custom emoji identifier of emoji chosen by the chat for the reply header and link preview background. Returned only in 'getChat'. - , chatProfileAccentColorId :: Maybe Int -- ^ Identifier of the accent color for the chat's profile background. See [profile accent colors](https://core.telegram.org/bots/api#profile-accent-colors) for more details. Returned only in getChat. - , chatProfileBackgroundCustomEmojiId :: Maybe Text -- ^ Custom emoji identifier of the emoji chosen by the chat for its profile background. Returned only in 'getChat'. - , chatEmojiStatusCustomEmojiId :: Maybe Text -- ^ Custom emoji identifier of emoji status of the other party in a private chat. Returned only in 'getChat'. - , chatEmojiStatusExpirationDate :: Maybe POSIXTime -- ^ Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any. Returned only in 'getChat'. - , chatBio :: Maybe Text -- ^ Bio of the other party in a private chat. Returned only in `getChat`. - , chatHasPrivateForwards :: Maybe Bool -- ^ 'True', if privacy settings of the other party in the private chat allows to use `tg://user?id=` links only in chats with the user. Returned only in getChat. - , chatHasRestrictedVoiceAndVideoMessages :: Maybe Bool -- ^ 'True', if the privacy settings of the other party restrict sending voice and video note messages in the private chat. Returned only in 'getChat'. - , chatJoinToSendMessages :: Maybe Bool -- ^ 'True', if users need to join the supergroup before they can send messages. Returned only in 'getChat'. - , chatJoinByRequest :: Maybe Bool -- ^ 'True', if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in 'getChat'. - , chatDescription :: Maybe Text -- ^ Description, for supergroups and channel chats. Returned only in getChat. - , chatInviteLink :: Maybe Text -- ^ Chat invite link, for supergroups and channel chats. Returned only in getChat. - , chatPinnedMessage :: Maybe Message -- ^ Pinned message, for supergroups. Returned only in getChat. - , chatPermissions :: Maybe ChatPermissions -- ^ Default chat member permissions, for groups and supergroups. - , chatSlowModeDelay :: Maybe Int -- ^ For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds. - , chatUnrestrictBootCount :: Maybe Int -- ^ For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions. - , chatMessageAutoDeleteTime :: Maybe POSIXTime -- ^ The time after which all messages sent to the chat will be automatically deleted; in seconds. - , chatHasAggressiveAntiSpamEnabled :: Maybe Bool -- ^ 'True', if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. Returned only in 'getChat'. - , chatHasHiddenMembers :: Maybe Bool -- ^ 'True', if non-administrators can only get the list of bots and administrators in the chat. Returned only in 'getChat'. - , chatHasProtectedContent :: Maybe Bool -- ^ 'True', if messages from the chat can't be forwarded to other chats. - , chatHasVisibleHistory :: Maybe Bool -- ^ 'True', if new chat members will have access to old messages; available only to chat administrators. Returned only in 'getChat'. - , chatStickerSetName :: Maybe Text -- ^ For supergroups, name of group sticker set. Returned only in getChat. - , chatCanSetStickerSet :: Maybe Bool -- ^ True, if the bot can change the group sticker set. Returned only in `getChat`. - , chatCustomEmojiStickerSet :: Maybe Text -- ^ For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. - , chatLinkedChatId :: Maybe ChatId -- ^ Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier 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. - , chatLocation :: Maybe ChatLocation -- ^ For supergroups, the location to which the supergroup is connected. Returned only in getChat. + { chatId :: ChatId -- ^ 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. + , chatType :: ChatType -- ^ Type of the chat, can be either “private”, “group”, “supergroup” or “channel” + , chatTitle :: Maybe Text -- ^ Title, for supergroups, channels and group chats. + , chatUsername :: Maybe Text -- ^ Username, for private chats, supergroups and channels if available. + , chatFirstName :: Maybe Text -- ^ First name of the other party in a private chat. + , chatLastName :: Maybe Text -- ^ Last name of the other party in a private chat. + , chatIsForum :: Maybe Bool -- ^ 'True', if the supergroup chat is a forum (has topics enabled). } deriving (Generic, Show) instance ToJSON Chat where toJSON = gtoJSON instance FromJSON Chat where parseJSON = gparseJSON - --- | Type of chat. -data ChatType - = ChatTypePrivate - | ChatTypeGroup - | ChatTypeSupergroup - | ChatTypeChannel - | ChatTypeSender - deriving (Generic, Show) - -instance ToJSON ChatType where - toJSON = gtoJSON -instance FromJSON ChatType where - parseJSON = gparseJSON diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/ChatBackground.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/ChatBackground.hs new file mode 100644 index 0000000..053e163 --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/ChatBackground.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE DeriveGeneric #-} +module Telegram.Bot.API.Types.ChatBackground where + +import Data.Aeson (FromJSON (..), ToJSON (..)) +import GHC.Generics (Generic) + +import Telegram.Bot.API.Internal.Utils +import Telegram.Bot.API.Types.BackgroundType + +-- ** 'ChatBackground' + +-- | This object represents a chat background. +data ChatBackground = ChatBackground + { chatBackgroundType :: BackgroundType -- ^ Type of the background. + } + deriving (Generic, Show) + +instance ToJSON ChatBackground where toJSON = gtoJSON +instance FromJSON ChatBackground where parseJSON = gparseJSON diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/ChatFullInfo.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/ChatFullInfo.hs new file mode 100644 index 0000000..d2c259d --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/ChatFullInfo.hs @@ -0,0 +1,77 @@ +{-# LANGUAGE DeriveGeneric #-} +module Telegram.Bot.API.Types.ChatFullInfo where + +import Data.Aeson (ToJSON(..), FromJSON(..)) +import Data.Time.Clock.POSIX (POSIXTime) +import Data.Text (Text) +import GHC.Generics (Generic) + +import Telegram.Bot.API.Types.Birthdate +import Telegram.Bot.API.Types.BusinessIntro +import Telegram.Bot.API.Types.BusinessLocation +import Telegram.Bot.API.Types.BusinessOpeningHours +import Telegram.Bot.API.Types.Chat +import Telegram.Bot.API.Types.ChatLocation +import Telegram.Bot.API.Types.ChatPhoto +import Telegram.Bot.API.Types.ChatPermissions +import Telegram.Bot.API.Types.ChatType +import Telegram.Bot.API.Types.Common +import Telegram.Bot.API.Types.Message +import Telegram.Bot.API.Types.ReactionType +import Telegram.Bot.API.Internal.Utils + +-- ** Chat + +-- | This object contains full information about a chat. +-- +-- +data ChatFullInfo = ChatFullInfo + { chatFullInfoId :: ChatId -- ^ 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. + , chatFullInfoIsBot :: Maybe Bool -- ^ 'True', if this user is a bot. + , chatFullInfoType :: ChatType -- ^ Type of chat. + , chatFullInfoTitle :: Maybe Text -- ^ Title, for supergroups, channels and group chats. + , chatFullInfoUsername :: Maybe Text -- ^ Username, for private chats, supergroups and channels if available. + , chatFullInfoFirstName :: Maybe Text -- ^ First name of the other party in a private chat. + , chatFullInfoLastName :: Maybe Text -- ^ Last name of the other party in a private chat. + , chatFullInfoIsForum :: Maybe Bool -- ^ 'True', if the supergroup chat is a forum (has topics enabled). + , chatFullInfoAccentColorId :: Maybe Int -- ^ Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See [accent colors](https://core.telegram.org/bots/api#accent-colors) for more details. Returned only in 'getChat'. Always returned in 'getChat'. + , chatFullInfoMaxReactionCount :: Int -- ^ The maximum number of reactions that can be set on a message in the chat. + , chatFullInfoPhoto :: Maybe ChatPhoto -- ^ Chat photo. Returned only in getChat. + , chatFullInfoActiveUsernames :: Maybe Text -- ^ If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in 'getChat'. + , chatFullInfoBirthdate :: Maybe Birthdate -- ^ For private chats, the date of birth of the user. + , chatFullInfoBusinessIntro :: Maybe BusinessIntro -- ^ For private chats with business accounts, the intro of the business. + , chatFullInfoBusinessLocation :: Maybe BusinessLocation -- ^ For private chats with business accounts, the location of the business. + , chatFullInfoBusinessOpeningHours :: Maybe BusinessOpeningHours -- ^ For private chats with business accounts, the opening hours of the business. + , chatFullInfoPersonalChat :: Maybe Chat -- ^ For private chats, the personal channel of the user. + , chatFullInfoAvailableReactions :: Maybe [ReactionType] -- ^ List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. Returned only in 'getChat'. + , chatFullInfoBackgroundCustomEmojiId :: Maybe Text -- ^ Custom emoji identifier of emoji chosen by the chat for the reply header and link preview background. Returned only in 'getChat'. + , chatFullInfoProfileAccentColorId :: Maybe Int -- ^ Identifier of the accent color for the chat's profile background. See [profile accent colors](https://core.telegram.org/bots/api#profile-accent-colors) for more details. Returned only in getChat. + , chatFullInfoProfileBackgroundCustomEmojiId :: Maybe Text -- ^ Custom emoji identifier of the emoji chosen by the chat for its profile background. Returned only in 'getChat'. + , chatFullInfoEmojiStatusCustomEmojiId :: Maybe Text -- ^ Custom emoji identifier of emoji status of the other party in a private chat. Returned only in 'getChat'. + , chatFullInfoEmojiStatusExpirationDate :: Maybe POSIXTime -- ^ Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any. Returned only in 'getChat'. + , chatFullInfoBio :: Maybe Text -- ^ Bio of the other party in a private chat. Returned only in `getChat`. + , chatFullInfoHasPrivateForwards :: Maybe Bool -- ^ 'True', if privacy settings of the other party in the private chat allows to use `tg://user?id=` links only in chats with the user. Returned only in getChat. + , chatFullInfoHasRestrictedVoiceAndVideoMessages :: Maybe Bool -- ^ 'True', if the privacy settings of the other party restrict sending voice and video note messages in the private chat. Returned only in 'getChat'. + , chatFullInfoJoinToSendMessages :: Maybe Bool -- ^ 'True', if users need to join the supergroup before they can send messages. Returned only in 'getChat'. + , chatFullInfoJoinByRequest :: Maybe Bool -- ^ 'True', if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in 'getChat'. + , chatFullInfoDescription :: Maybe Text -- ^ Description, for supergroups and channel chats. Returned only in getChat. + , chatFullInfoInviteLink :: Maybe Text -- ^ Chat invite link, for supergroups and channel chats. Returned only in getChat. + , chatFullInfoPinnedMessage :: Maybe Message -- ^ Pinned message, for supergroups. Returned only in getChat. + , chatFullInfoPermissions :: Maybe ChatPermissions -- ^ Default chat member permissions, for groups and supergroups. + , chatFullInfoSlowModeDelay :: Maybe Int -- ^ For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds. + , chatFullInfoUnrestrictBootCount :: Maybe Int -- ^ For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions. + , chatFullInfoMessageAutoDeleteTime :: Maybe POSIXTime -- ^ The time after which all messages sent to the chat will be automatically deleted; in seconds. + , chatFullInfoHasAggressiveAntiSpamEnabled :: Maybe Bool -- ^ 'True', if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. Returned only in 'getChat'. + , chatFullInfoHasHiddenMembers :: Maybe Bool -- ^ 'True', if non-administrators can only get the list of bots and administrators in the chat. Returned only in 'getChat'. + , chatFullInfoHasProtectedContent :: Maybe Bool -- ^ 'True', if messages from the chat can't be forwarded to other chats. + , chatFullInfoHasVisibleHistory :: Maybe Bool -- ^ 'True', if new chat members will have access to old messages; available only to chat administrators. Returned only in 'getChat'. + , chatFullInfoStickerSetName :: Maybe Text -- ^ For supergroups, name of group sticker set. Returned only in getChat. + , chatFullInfoCanSetStickerSet :: Maybe Bool -- ^ True, if the bot can change the group sticker set. Returned only in `getChat`. + , chatFullInfoCustomEmojiStickerSet :: Maybe Text -- ^ For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. + , chatFullInfoLinkedChatId :: Maybe ChatId -- ^ Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier 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. + , chatFullInfoLocation :: Maybe ChatLocation -- ^ For supergroups, the location to which the supergroup is connected. Returned only in getChat. + } + deriving (Generic, Show) + +instance ToJSON ChatFullInfo where toJSON = gtoJSON +instance FromJSON ChatFullInfo where parseJSON = gparseJSON diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/ChatMemberUpdated.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/ChatMemberUpdated.hs index 9e19bcf..f6cccb5 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/ChatMemberUpdated.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/ChatMemberUpdated.hs @@ -21,6 +21,7 @@ data ChatMemberUpdated = ChatMemberUpdated , chatMemberUpdatedOldChatMember :: ChatMember -- ^ Previous information about the chat member. , chatMemberUpdatedNewChatMember :: ChatMember -- ^ New information about the chat member. , chatMemberUpdatedInviteLink :: Maybe ChatInviteLink -- ^ Chat invite link, which was used by the user to join the chat; for joining by invite link events only. + , chatMemberUpdatedViaJoinRequest :: Maybe Bool -- ^ 'True', if the user joined the chat after sending a direct join request without using an invite link and being approved by an administrator. , chatMemberUpdatedViaChatFolderInviteLink :: Maybe Bool -- ^ 'True', if the user joined the chat via a chat folder invite link. } deriving (Generic, Show) diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/ChatType.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/ChatType.hs new file mode 100644 index 0000000..158d9be --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/ChatType.hs @@ -0,0 +1,24 @@ +{-# LANGUAGE DeriveGeneric #-} +module Telegram.Bot.API.Types.ChatType where + +import Data.Aeson (FromJSON (..), ToJSON (..)) +import GHC.Generics (Generic) + +import Telegram.Bot.API.Internal.Utils + +-- ** 'ChatType' + +-- | Type of the chat, can be either “private”, “group”, “supergroup” or “channel”. + +data ChatType + = ChatTypePrivate + | ChatTypeGroup + | ChatTypeSupergroup + | ChatTypeChannel + | ChatTypeSender + deriving (Generic, Show) + +instance ToJSON ChatType where + toJSON = gtoJSON +instance FromJSON ChatType where + parseJSON = gparseJSON diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/GiveawayWinners.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/GiveawayWinners.hs index 8977dd9..2b855f8 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/GiveawayWinners.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/GiveawayWinners.hs @@ -7,7 +7,7 @@ import Data.Time.Clock.POSIX (POSIXTime) import GHC.Generics (Generic) import Telegram.Bot.API.Internal.Utils -import {-# SOURCE #-} Telegram.Bot.API.Types.Chat +import Telegram.Bot.API.Types.Chat import Telegram.Bot.API.Types.Common import Telegram.Bot.API.Types.User diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/InlineKeyboardButton.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/InlineKeyboardButton.hs index 59ad0e5..f52860c 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/InlineKeyboardButton.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/InlineKeyboardButton.hs @@ -7,6 +7,7 @@ import GHC.Generics (Generic) import Telegram.Bot.API.Types.CallbackGame import Telegram.Bot.API.Types.Common +import Telegram.Bot.API.Types.LoginUrl import Telegram.Bot.API.Types.SwitchInlineQueryChosenChat import Telegram.Bot.API.Internal.Utils @@ -18,6 +19,7 @@ data InlineKeyboardButton = InlineKeyboardButton , inlineKeyboardButtonUrl :: Maybe Text -- ^ HTTP url to be opened when button is pressed , inlineKeyboardButtonCallbackData :: Maybe Text -- ^ Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes , inlineKeyboardButtonWebApp :: Maybe WebAppInfo -- ^ Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method @answerWebAppQuery@. Available only in private chats between a user and the bot. + , inlineKeyboardButtonLoginUrl :: Maybe LoginUrl -- ^ An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the [Telegram Login Widget](https://core.telegram.org/widgets/login). , inlineKeyboardButtonSwitchInlineQuery :: Maybe Text -- ^ If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot‘s username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted. , inlineKeyboardButtonSwitchInlineQueryCurrentChat :: Maybe Text -- ^ If set, pressing the button will insert the bot‘s username and the specified inline query in the current chat's input field. Can be empty, in which case only the bot’s username will be inserted. , inlineKeyboardButtonSwitchInlineQueryChosenChat :: Maybe SwitchInlineQueryChosenChat -- ^ If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field. @@ -28,7 +30,7 @@ data InlineKeyboardButton = InlineKeyboardButton deriving (Generic, Show) labeledInlineKeyboardButton :: Text -> InlineKeyboardButton -labeledInlineKeyboardButton label = InlineKeyboardButton label Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing - +labeledInlineKeyboardButton label = InlineKeyboardButton label Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing + instance ToJSON InlineKeyboardButton where toJSON = gtoJSON instance FromJSON InlineKeyboardButton where parseJSON = gparseJSON diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/InputPollOption.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/InputPollOption.hs new file mode 100644 index 0000000..ecec77b --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/InputPollOption.hs @@ -0,0 +1,23 @@ +{-# LANGUAGE DeriveGeneric #-} +module Telegram.Bot.API.Types.InputPollOption where + +import Data.Aeson (FromJSON (..), ToJSON (..)) +import Data.Text (Text) +import GHC.Generics (Generic) + +import Telegram.Bot.API.Internal.Utils +import Telegram.Bot.API.Types.MessageEntity +import Telegram.Bot.API.Types.ParseMode + +-- ** 'InputPollOption' + +-- | This object contains information about one answer option in a poll to send. +data InputPollOption = InputPollOption + { inputPollOptionText :: Text -- ^ Option text, 1-100 characters. + , inputPollOptionTextParseMode :: Maybe ParseMode -- ^ Mode for parsing entities in the text. See [formatting options](https://core.telegram.org/bots/api#formatting-options) for more details. Currently, only custom emoji entities are allowed. + , inputPollOptionTextEntities :: Maybe [MessageEntity] -- ^ A JSON-serialized list of special entities that appear in the poll option text. It can be specified instead of @text_parse_mode@. + } + deriving (Generic, Show) + +instance ToJSON InputPollOption where toJSON = gtoJSON +instance FromJSON InputPollOption where parseJSON = gparseJSON diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/Message.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/Message.hs index 326d5ee..993ae5c 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/Message.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/Message.hs @@ -8,14 +8,15 @@ import GHC.Generics (Generic) import Telegram.Bot.API.Types.Animation import Telegram.Bot.API.Types.Audio -import {-# SOURCE #-} Telegram.Bot.API.Types.Chat +import Telegram.Bot.API.Types.Chat +import Telegram.Bot.API.Types.ChatBackground import Telegram.Bot.API.Types.ChatBoostAdded import Telegram.Bot.API.Types.ChatShared import Telegram.Bot.API.Types.Common import Telegram.Bot.API.Types.Contact import Telegram.Bot.API.Types.Dice import Telegram.Bot.API.Types.Document -import {-# SOURCE #-} Telegram.Bot.API.Types.ExternalReplyInfo +import Telegram.Bot.API.Types.ExternalReplyInfo import Telegram.Bot.API.Types.ForumTopicEdited import Telegram.Bot.API.Types.ForumTopicClosed import Telegram.Bot.API.Types.ForumTopicCreated @@ -23,23 +24,23 @@ import Telegram.Bot.API.Types.ForumTopicReopened import Telegram.Bot.API.Types.Game import Telegram.Bot.API.Types.GeneralForumTopicHidden import Telegram.Bot.API.Types.GeneralForumTopicUnhidden -import {-# SOURCE #-} Telegram.Bot.API.Types.Giveaway +import Telegram.Bot.API.Types.Giveaway import {-# SOURCE #-} Telegram.Bot.API.Types.GiveawayCompleted import Telegram.Bot.API.Types.GiveawayCreated -import {-# SOURCE #-} Telegram.Bot.API.Types.GiveawayWinners +import Telegram.Bot.API.Types.GiveawayWinners import Telegram.Bot.API.Types.InlineKeyboardMarkup import Telegram.Bot.API.Types.Invoice import Telegram.Bot.API.Types.LinkPreviewOptions import Telegram.Bot.API.Types.Location import Telegram.Bot.API.Types.MessageAutoDeleteTimerChanged import Telegram.Bot.API.Types.MessageEntity -import {-# SOURCE #-} Telegram.Bot.API.Types.MessageOrigin +import Telegram.Bot.API.Types.MessageOrigin import Telegram.Bot.API.Types.PassportData import Telegram.Bot.API.Types.PhotoSize import Telegram.Bot.API.Types.Poll import Telegram.Bot.API.Types.ProximityAlertTriggered import Telegram.Bot.API.Types.Sticker -import {-# SOURCE #-} Telegram.Bot.API.Types.Story +import Telegram.Bot.API.Types.Story import Telegram.Bot.API.Types.SuccessfulPayment import Telegram.Bot.API.Types.TextQuote import Telegram.Bot.API.Types.User @@ -125,6 +126,7 @@ data Message = Message , messagePassportData :: Maybe PassportData -- ^ Telegram Passport data. , messageProximityAlertTriggered :: Maybe ProximityAlertTriggered -- ^ Service message. A user in the chat triggered another user's proximity alert while sharing Live Location. , messageBoostAdded :: Maybe ChatBoostAdded -- ^ Service message: user boosted the chat. + , messageChatBackgroundSet :: Maybe ChatBackground -- ^ Service message: chat background set. , messageForumTopicCreated :: Maybe ForumTopicCreated -- ^ Service message: forum topic created. , messageForumTopicEdited :: Maybe ForumTopicEdited -- ^ Service message: forum topic edited. , messageForumTopicClosed :: Maybe ForumTopicClosed -- ^ Service message: forum topic closed. diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/Poll.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/Poll.hs index 632966b..7a9f273 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/Poll.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/Poll.hs @@ -17,8 +17,9 @@ import Telegram.Bot.API.Internal.Utils data Poll = Poll { pollId :: PollId -- ^ Unique poll identifier. , pollQuestion :: Text -- ^ Poll question, 1-300 characters. + , pollQuestionEntities :: Maybe [MessageEntity] -- ^ Special entities that appear in the @question@. Currently, only custom emoji entities are allowed in poll questions. , pollOptions :: [PollOption] -- ^ List of poll options. - , pollTotalVoterCount :: Int -- ^ Total number of users that voted in the poll. + , pollTotalVoterCount :: Int -- ^ Total number of users that voted in the poll. , pollIsClosed :: Bool -- ^ 'True', if the poll is closed. , pollIsAnonymous :: Bool -- ^ 'True', if the poll is anonymous. , pollType :: PollType -- ^ Poll type, currently can be “regular” or “quiz”. diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/PollOption.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/PollOption.hs index f3d521b..1942c0d 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/PollOption.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/PollOption.hs @@ -6,12 +6,14 @@ import Data.Text (Text) import GHC.Generics (Generic) import Telegram.Bot.API.Internal.Utils +import Telegram.Bot.API.Types.MessageEntity -- ** 'PollOption' -- | This object contains information about one answer option in a poll. data PollOption = PollOption { pollOptionText :: Text -- ^ Option text, 1-100 characters. + , pollOptionEntities :: Maybe [MessageEntity] -- ^ Special entities that appear in the option @text@. Currently, only custom emoji entities are allowed in poll option texts. , pollOptionVoterCount :: Int -- ^ Number of users that voted for this option. } deriving (Generic, Show) diff --git a/telegram-bot-api/telegram-bot-api.cabal b/telegram-bot-api/telegram-bot-api.cabal index a83ea5e..1cc44d2 100644 --- a/telegram-bot-api/telegram-bot-api.cabal +++ b/telegram-bot-api/telegram-bot-api.cabal @@ -123,6 +123,8 @@ library -- Types Telegram.Bot.API.Types.Animation Telegram.Bot.API.Types.Audio + Telegram.Bot.API.Types.BackgroundFill + Telegram.Bot.API.Types.BackgroundType Telegram.Bot.API.Types.Birthdate Telegram.Bot.API.Types.BotCommand Telegram.Bot.API.Types.BotCommandScope @@ -138,12 +140,14 @@ library Telegram.Bot.API.Types.CallbackGame Telegram.Bot.API.Types.CallbackQuery Telegram.Bot.API.Types.Chat + Telegram.Bot.API.Types.ChatAdministratorRights + Telegram.Bot.API.Types.ChatBackground Telegram.Bot.API.Types.ChatBoost Telegram.Bot.API.Types.ChatBoostAdded Telegram.Bot.API.Types.ChatBoostRemoved Telegram.Bot.API.Types.ChatBoostSource Telegram.Bot.API.Types.ChatBoostUpdated - Telegram.Bot.API.Types.ChatAdministratorRights + Telegram.Bot.API.Types.ChatFullInfo Telegram.Bot.API.Types.ChatInviteLink Telegram.Bot.API.Types.ChatJoinRequest Telegram.Bot.API.Types.ChatLocation @@ -152,6 +156,7 @@ library Telegram.Bot.API.Types.ChatPermissions Telegram.Bot.API.Types.ChatPhoto Telegram.Bot.API.Types.ChatShared + Telegram.Bot.API.Types.ChatType Telegram.Bot.API.Types.Common Telegram.Bot.API.Types.Contact Telegram.Bot.API.Types.CopyMessageId @@ -178,6 +183,7 @@ library Telegram.Bot.API.Types.InlineKeyboardButton Telegram.Bot.API.Types.InlineKeyboardMarkup Telegram.Bot.API.Types.InputMedia + Telegram.Bot.API.Types.InputPollOption Telegram.Bot.API.Types.Invoice Telegram.Bot.API.Types.KeyboardButton Telegram.Bot.API.Types.KeyboardButtonRequestChat