Skip to content

Commit

Permalink
Merge pull request #181 from fizruk/bot-api-7.1
Browse files Browse the repository at this point in the history
Bot API 7.1
  • Loading branch information
swamp-agr authored May 20, 2024
2 parents 8adbe0b + 29743ff commit d451367
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 6 deletions.
2 changes: 2 additions & 0 deletions telegram-bot-api/src/Telegram/Bot/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions telegram-bot-api/src/Telegram/Bot/API/Types/Chat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ 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'.
, 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.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions telegram-bot-api/src/Telegram/Bot/API/Types/ChatBoostAdded.hs
Original file line number Diff line number Diff line change
@@ -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
8 changes: 6 additions & 2 deletions telegram-bot-api/src/Telegram/Bot/API/Types/Message.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 10 additions & 1 deletion telegram-bot-api/src/Telegram/Bot/API/Types/Story.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 11 additions & 0 deletions telegram-bot-api/src/Telegram/Bot/API/Types/Story.hs-boot
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions telegram-bot-api/telegram-bot-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d451367

Please sign in to comment.