From 29743ffa40fa88a0ba90e464689e6f3d7c5d5f96 Mon Sep 17 00:00:00 2001 From: Andrey Prokopenko Date: Mon, 20 May 2024 16:51:46 +0200 Subject: [PATCH] Bot API 7.1 --- telegram-bot-api/src/Telegram/Bot/API/Types.hs | 2 ++ .../src/Telegram/Bot/API/Types/Chat.hs | 2 ++ .../Bot/API/Types/ChatAdministratorRights.hs | 6 +++--- .../Telegram/Bot/API/Types/ChatBoostAdded.hs | 18 ++++++++++++++++++ .../src/Telegram/Bot/API/Types/Message.hs | 8 ++++++-- .../src/Telegram/Bot/API/Types/Story.hs | 11 ++++++++++- .../src/Telegram/Bot/API/Types/Story.hs-boot | 11 +++++++++++ telegram-bot-api/telegram-bot-api.cabal | 1 + 8 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 telegram-bot-api/src/Telegram/Bot/API/Types/ChatBoostAdded.hs create mode 100644 telegram-bot-api/src/Telegram/Bot/API/Types/Story.hs-boot diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types.hs b/telegram-bot-api/src/Telegram/Bot/API/Types.hs index b13615b..a48d055 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types.hs @@ -26,6 +26,7 @@ module Telegram.Bot.API.Types , module Telegram.Bot.API.Types.CallbackQuery , module Telegram.Bot.API.Types.Chat , 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 @@ -135,6 +136,7 @@ import Telegram.Bot.API.Types.CallbackGame import Telegram.Bot.API.Types.CallbackQuery import Telegram.Bot.API.Types.Chat 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 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 ce43ef2..24e3965 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/Chat.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/Chat.hs @@ -46,6 +46,7 @@ data Chat = Chat , 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'. @@ -53,6 +54,7 @@ data Chat = Chat , 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. } diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/ChatAdministratorRights.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/ChatAdministratorRights.hs index b059ec8..19fcf74 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/ChatAdministratorRights.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/ChatAdministratorRights.hs @@ -18,12 +18,12 @@ data ChatAdministratorRights = ChatAdministratorRights , chatAdministratorRightsCanPromoteMembers :: Bool -- ^ 'True', if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user). , chatAdministratorRightsCanChangeInfo :: Bool -- ^ 'True', if the user is allowed to change the chat title, photo and other settings. , chatAdministratorRightsCanInviteUsers :: Bool -- ^ 'True', if the user is allowed to invite new users to the chat. + , chatAdministratorRightsCanPostStories :: Maybe Bool -- ^ 'True', if the administrator can post stories to the chat. + , chatAdministratorRightsCanEditStories :: Maybe Bool -- ^ 'True', if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat's story archive. + , chatAdministratorRightsCanDeleteStories :: Maybe Bool -- ^ 'True', if the administrator can delete stories posted by other users. , chatAdministratorRightsCanPostMessages :: Maybe Bool -- ^ 'True', if the administrator can post in the channel; channels only. , chatAdministratorRightsCanEditMessages :: Maybe Bool -- ^ 'True', if the administrator can edit messages of other users and can pin messages; channels only. , chatAdministratorRightsCanPinMessages :: Maybe Bool -- ^ 'True', if the user is allowed to pin messages; groups and supergroups only - , chatAdministratorRightsCanPostStories :: Maybe Bool -- ^ 'True', if the administrator can post stories in the channel; channels only. - , chatAdministratorRightsCanEditStories :: Maybe Bool -- ^ 'True', if the administrator can edit stories posted by other users; channels only. - , chatAdministratorRightsCanDeleteStories :: Maybe Bool -- ^ 'True', if the administrator can delete stories posted by other users; channels only. , chatAdministratorRightsCanManageTopics :: Maybe Bool -- ^ 'True', if the user is allowed to create, rename, close, and reopen forum topics; supergroups only. } deriving (Generic, Show) diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/ChatBoostAdded.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/ChatBoostAdded.hs new file mode 100644 index 0000000..74263f0 --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/ChatBoostAdded.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE DeriveGeneric #-} +module Telegram.Bot.API.Types.ChatBoostAdded where + +import Data.Aeson (FromJSON (..), ToJSON (..)) +import GHC.Generics (Generic) + +import Telegram.Bot.API.Internal.Utils + +-- ** 'ChatBoostAdded' + +-- | This object represents a boost added to a chat or changed. +data ChatBoostAdded = ChatBoostAdded + { chatBoostAddedBoostCount :: Int -- ^ Number of boosts added by the user. + } + deriving (Generic, Show) + +instance ToJSON ChatBoostAdded where toJSON = gtoJSON +instance FromJSON ChatBoostAdded 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 029e298..e7acaa8 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/Message.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/Message.hs @@ -10,6 +10,7 @@ import Telegram.Bot.API.Types.Animation import Telegram.Bot.API.Types.Audio import Telegram.Bot.API.Types.Document import {-# SOURCE #-} Telegram.Bot.API.Types.Chat +import Telegram.Bot.API.Types.ChatBoostAdded import Telegram.Bot.API.Types.ChatShared import Telegram.Bot.API.Types.Common import Telegram.Bot.API.Types.Contact @@ -37,7 +38,7 @@ 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 Telegram.Bot.API.Types.Story +import {-# SOURCE #-} Telegram.Bot.API.Types.Story import Telegram.Bot.API.Types.SuccessfulPayment import Telegram.Bot.API.Types.TextQuote import Telegram.Bot.API.Types.User @@ -61,6 +62,7 @@ data Message = Message , messageMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier of a message thread to which the message belongs; for supergroups only. , messageFrom :: Maybe User -- ^ Sender, empty for messages sent to channels. , messageSenderChat :: Maybe Chat -- ^ Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. + , messageSenderBoostCount :: Maybe Int -- ^ If the sender of the message boosted the chat, the number of boosts added by the user. , messageDate :: POSIXTime -- ^ Date the message was sent in Unix time. , messageChat :: Chat -- ^ Conversation the message belongs to. , messageForwardFrom :: Maybe User -- ^ For forwarded messages, sender of the original message. @@ -73,7 +75,8 @@ data Message = Message , messageIsAutomaticForward :: Maybe Bool -- ^ 'True', if the message is a channel post that was automatically forwarded to the connected discussion group. , messageReplyToMessage :: Maybe Message -- ^ For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. , messageExternalReply :: Maybe ExternalReplyInfo -- ^ Information about the message that is being replied to, which may come from another chat or forum topic. - , quote :: Maybe TextQuote -- ^ For replies that quote part of the original message, the quoted part of the message. + , messageQuote :: Maybe TextQuote -- ^ For replies that quote part of the original message, the quoted part of the message. + , messageReplyToStory :: Maybe Story -- ^ For replies to a story, the original story. , messageViaBot :: Maybe User -- ^ Bot through which the message was sent. , messageEditDate :: Maybe POSIXTime -- ^ Date the message was last edited in Unix time , messageHasProtectedContent :: Maybe Bool -- ^ 'True', if the message can't be forwarded. @@ -122,6 +125,7 @@ data Message = Message , messageWriteAccessAllowed :: Maybe WriteAccessAllowed -- ^ Service message: the user allowed the bot added to the attachment menu to write messages. , 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. , 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/Story.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/Story.hs index 7dfb475..607e302 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/Story.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/Story.hs @@ -1,16 +1,25 @@ {-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} module Telegram.Bot.API.Types.Story where import Data.Aeson (FromJSON (..), ToJSON (..)) import GHC.Generics (Generic) import Telegram.Bot.API.Internal.Utils +import Telegram.Bot.API.Types.Chat + -- ** 'Story' --- | This object represents a message about a forwarded story in the chat. Currently holds no information. +-- | Unique identifier for the story in the chat +newtype StoryId = StoryId Int + deriving (Show, ToJSON, FromJSON) +-- | This object represents a message about a story. data Story = Story + { storyChat :: Chat -- ^ Chat that posted the story. + , storyId :: StoryId -- ^ Unique identifier for the story in the chat. + } deriving (Generic, Show) instance ToJSON Story where toJSON = gtoJSON diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/Story.hs-boot b/telegram-bot-api/src/Telegram/Bot/API/Types/Story.hs-boot new file mode 100644 index 0000000..bd20dc0 --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/Story.hs-boot @@ -0,0 +1,11 @@ +module Telegram.Bot.API.Types.Story where + +import Data.Aeson + +data Story + +instance Show Story + +instance FromJSON Story + +instance ToJSON Story \ No newline at end of file diff --git a/telegram-bot-api/telegram-bot-api.cabal b/telegram-bot-api/telegram-bot-api.cabal index a7144c0..1172db4 100644 --- a/telegram-bot-api/telegram-bot-api.cabal +++ b/telegram-bot-api/telegram-bot-api.cabal @@ -133,6 +133,7 @@ library Telegram.Bot.API.Types.CallbackQuery Telegram.Bot.API.Types.Chat 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