diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da31f52..c91aaab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - ghc: ["8.10.7", "9.0.2", "9.4", "9.6"] - cabal: ["3.10.2.1"] + ghc: ["9.2", "9.4", "9.6", "9.8", "9.10"] + cabal: ["3.10.3.0"] os: [ubuntu-latest] name: build and test (cabal) steps: diff --git a/cabal.project b/cabal.project index 882c428..e8306d4 100644 --- a/cabal.project +++ b/cabal.project @@ -1,3 +1,39 @@ packages: telegram-bot-api/ telegram-bot-simple/ + + +allow-newer: deepseq:base +allow-newer: vault:base +allow-newer: array:base +allow-newer: wai-app-static:wai +allow-newer: http2:containers +allow-newer: servant-server:warp +allow-newer: servant-server:wai-app-static +allow-newer: servant-server:http-types +allow-newer: servant-server:either +allow-newer: servant-server:base +allow-newer: servant-client-core:base +allow-newer: servant-client-core:containers +allow-newer: servant-client-core:template-haskell +allow-newer: servant-multipart-client:servant-server +allow-newer: servant-multipart:servant-server +allow-newer: servant-server:containers +allow-newer: servant-server:base-compat +allow-newer: servant-docs:base-compat +allow-newer: servant-docs:base +allow-newer: servant-client:base +allow-newer: servant-client:containers +allow-newer: servant:base +allow-newer: servant-foreign:base +allow-newer: singleton-bool:base +allow-newer: http-api-data:base +allow-newer: http-api-data:containers +allow-newer: uuid-types:template-haskell +allow-newer: dhall:containers +allow-newer: dhall:template-haskell +allow-newer: repline:containers +allow-newer: haskeline:base +allow-newer: serialise:base +allow-newer: cborg:base +allow-newer: cborg-json:base diff --git a/telegram-bot-api/src/Telegram/Bot/API/Games.hs b/telegram-bot-api/src/Telegram/Bot/API/Games.hs index c5709ce..cafcac5 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Games.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Games.hs @@ -16,7 +16,8 @@ import Servant.Client hiding (Response) import Telegram.Bot.API.Internal.Utils (deriveJSON') import Telegram.Bot.API.MakingRequests (Response) import Telegram.Bot.API.Types - ( ChatId, GameHighScore, InlineKeyboardMarkup, Message, MessageId, MessageThreadId + ( BusinessConnectionId, ChatId, GameHighScore, InlineKeyboardMarkup + , Message, MessageId, MessageThreadId , ReplyParameters, UserId ) import Telegram.Bot.API.Internal.TH @@ -26,7 +27,8 @@ import Telegram.Bot.API.Internal.TH -- ** 'SendGameRequest' data SendGameRequest = SendGameRequest - { sendGameChatId :: ChatId -- ^ Unique identifier for the target chat. + { sendGameBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendGameChatId :: ChatId -- ^ Unique identifier for the target chat. , sendGameMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendGameGameShortName :: Text -- ^ Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather. , sendGameDisableNotification :: Maybe Bool -- ^ Sends the message silently. Users will receive a notification with no sound. diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods.hs index 1aeab92..d6861ce 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods.hs @@ -32,6 +32,7 @@ module Telegram.Bot.API.Methods , module Telegram.Bot.API.Methods.ExportChatInviteLink , module Telegram.Bot.API.Methods.ForwardMessage , module Telegram.Bot.API.Methods.ForwardMessages + , module Telegram.Bot.API.Methods.GetBusinessConnection , module Telegram.Bot.API.Methods.GetChat , module Telegram.Bot.API.Methods.GetChatAdministrators , module Telegram.Bot.API.Methods.GetChatMember @@ -116,6 +117,7 @@ import Telegram.Bot.API.Methods.EditMessageLiveLocation import Telegram.Bot.API.Methods.ExportChatInviteLink import Telegram.Bot.API.Methods.ForwardMessage import Telegram.Bot.API.Methods.ForwardMessages +import Telegram.Bot.API.Methods.GetBusinessConnection import Telegram.Bot.API.Methods.GetChat import Telegram.Bot.API.Methods.GetChatAdministrators import Telegram.Bot.API.Methods.GetChatMember diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/GetBusinessConnection.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/GetBusinessConnection.hs new file mode 100644 index 0000000..372ec00 --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/GetBusinessConnection.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeOperators #-} +module Telegram.Bot.API.Methods.GetBusinessConnection where + +import Data.Proxy +import Servant.API +import Servant.Client hiding (Response) + +import Telegram.Bot.API.MakingRequests +import Telegram.Bot.API.Types + +-- ** 'getBusinessConnection' + +type GetBusinessConnection = "getBusinessConnection" + :> RequiredQueryParam "business_connection_id" BusinessConnectionId + :> Post '[JSON] (Response BusinessConnection) + +-- | Use this method to get information about the connection of the bot with a business account. Returns a 'BusinessConnection' object on success. +getBusinessConnection :: BusinessConnectionId -> ClientM (Response BusinessConnection) +getBusinessConnection = client (Proxy @GetBusinessConnection) diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendAnimation.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendAnimation.hs index 96aff61..3f14f6c 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendAnimation.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendAnimation.hs @@ -37,7 +37,8 @@ import Telegram.Bot.API.Internal.TH -- | Request parameters for 'sendAnimation'. data SendAnimationRequest = SendAnimationRequest - { sendAnimationChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername) + { sendAnimationBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendAnimationChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername) , sendAnimationMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendAnimationAnimation :: InputFile -- ^ Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. More info on Sending Files » , sendAnimationDuration :: Maybe Int -- ^ Duration of sent animation in seconds diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendAudio.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendAudio.hs index 1dd231f..a356c4a 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendAudio.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendAudio.hs @@ -37,7 +37,8 @@ import Telegram.Bot.API.Internal.TH -- | Request parameters for 'sendAudio'. data SendAudioRequest = SendAudioRequest - { sendAudioChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). + { sendAudioBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendAudioChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). , sendAudioMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendAudioAudio :: InputFile -- ^ Audio to send. Pass a file_id as String to send an audio that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a audio from the Internet, or upload a new audio using multipart/form-data. More info on Sending Files » , sendAudioDuration :: Maybe Int -- ^ Duration of sent audio in seconds diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendChatAction.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendChatAction.hs index f1ae6a6..197e8ed 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendChatAction.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendChatAction.hs @@ -1,20 +1,32 @@ {-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} module Telegram.Bot.API.Methods.SendChatAction where +import Data.Aeson (ToJSON (..)) import Data.Proxy import Data.Text (Text) +import GHC.Generics (Generic) import Servant.API import Servant.Client hiding (Response) +import Telegram.Bot.API.Internal.Utils import Telegram.Bot.API.MakingRequests import Telegram.Bot.API.Types +data SendChatActionRequest = SendChatActionRequest + { sendChatActionBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the action will be sent. + , sendChatActionChatId :: ChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@). + , sendChatActionMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread; for supergroups only. + , sendChatActionAction :: Text -- ^ Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes. + } + deriving Generic + +instance ToJSON SendChatActionRequest where toJSON = gtoJSON + type SendChatAction = "sendChatAction" - :> RequiredQueryParam "chat_id" SomeChatId - :> QueryParam "message_thread_id" MessageThreadId - :> RequiredQueryParam "action" Text + :> ReqBody '[JSON] SendChatActionRequest :> Post '[JSON] (Response Bool) -- | Use this method when you need to tell the @@ -34,8 +46,5 @@ type SendChatAction = "sendChatAction" -- We only recommend using this method when a -- response from the bot will take a noticeable -- amount of time to arrive. -sendChatAction :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername). - -> Maybe MessageThreadId -- ^ Unique identifier for the target message thread; supergroups only. - -> Text -- ^ Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes. - -> ClientM (Response Bool) +sendChatAction :: SendChatActionRequest -> ClientM (Response Bool) sendChatAction = client (Proxy @SendChatAction) diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendContact.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendContact.hs index f29e255..b9ba697 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendContact.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendContact.hs @@ -20,7 +20,8 @@ import Telegram.Bot.API.Internal.TH -- | Request parameters for 'sendContact'. data SendContactRequest = SendContactRequest - { sendContactChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). + { sendContactBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendContactChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). , sendContactMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendContactPhoneNumber :: Text -- ^ Contact's phone number , sendContactFirstName :: Text -- ^ Contact's first name diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendDice.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendDice.hs index 4544e5d..daa192d 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendDice.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendDice.hs @@ -20,7 +20,8 @@ import Telegram.Bot.API.Internal.TH -- | Request parameters for 'sendDice'. data SendDiceRequest = SendDiceRequest - { sendDiceChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). + { sendDiceBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendDiceChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). , sendDiceMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendDiceEmoji :: Maybe Text -- ^ Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲” , sendDiceDisableNotification :: Maybe Bool -- ^ Sends the message silently. Users will receive a notification with no sound. diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendDocument.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendDocument.hs index 74b8ee6..0a4386c 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendDocument.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendDocument.hs @@ -59,7 +59,8 @@ sendDocument r = do -- | Request parameters for 'sendDocument' data SendDocumentRequest = SendDocumentRequest - { sendDocumentChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@). + { sendDocumentBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendDocumentChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@). , sendDocumentMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendDocumentDocument :: DocumentFile -- ^ Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data , sendDocumentThumbnail :: Maybe FilePath -- ^ Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendLocation.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendLocation.hs index 1a60513..d73a5ef 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendLocation.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendLocation.hs @@ -19,7 +19,8 @@ import Telegram.Bot.API.Internal.TH -- | Request parameters for 'sendLocation'. data SendLocationRequest = SendLocationRequest - { sendLocationChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). + { sendLocationBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendLocationChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). , sendLocationMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendLocationLatitude :: Float -- ^ Latitude of new location , sendLocationLongitude :: Float -- ^ Longitude of new location diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendMediaGroup.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendMediaGroup.hs index 7a9e6a7..8d99ac5 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendMediaGroup.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendMediaGroup.hs @@ -19,7 +19,8 @@ import Telegram.Bot.API.Internal.TH -- | Request parameters for 'sendMediaGroup'. data SendMediaGroupRequest = SendMediaGroupRequest - { sendMediaGroupChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). + { sendMediaGroupBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendMediaGroupChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). , sendMediaGroupMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendMediaGroupMedia :: [InputMedia] -- ^ A JSON-serialized array describing messages to be sent, must include 2-10 items. InputMediaAudio, InputMediaDocument, InputMediaPhoto or InputMediaVideo. , sendMediaGroupDisableNotification :: Maybe Bool -- ^ Sends the message silently. Users will receive a notification with no sound. diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendMessage.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendMessage.hs index 8c2d403..ef6592a 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendMessage.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendMessage.hs @@ -30,7 +30,8 @@ sendMessage = client (Proxy @SendMessage) -- | Request parameters for 'sendMessage'. data SendMessageRequest = SendMessageRequest - { sendMessageChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@). + { sendMessageBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendMessageChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@). , sendMessageMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendMessageText :: Text -- ^ Text of the message to be sent. , sendMessageParseMode :: 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. diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendPhoto.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendPhoto.hs index 40d57df..a06cdd7 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendPhoto.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendPhoto.hs @@ -61,7 +61,8 @@ pattern PhotoFile x y = MakePhotoFile (InputFile x y) -- | Request parameters for 'sendPhoto' data SendPhotoRequest = SendPhotoRequest - { sendPhotoChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@). + { sendPhotoBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendPhotoChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @\@channelusername@). , sendPhotoMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendPhotoPhoto :: PhotoFile -- ^ Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data , sendPhotoThumb :: Maybe FilePath -- ^ Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under 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 648d760..2576116 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendPoll.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendPoll.hs @@ -21,7 +21,8 @@ import Telegram.Bot.API.Internal.TH -- | Request parameters for 'sendPoll'. data SendPollRequest = SendPollRequest - { sendPollChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). + { 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 diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVenue.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVenue.hs index aa442d1..febc6b8 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVenue.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVenue.hs @@ -20,7 +20,8 @@ import Telegram.Bot.API.Internal.TH -- | Request parameters for 'sendVenue'. data SendVenueRequest = SendVenueRequest - { sendVenueChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). + { sendVenueBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendVenueChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). , sendVenueMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendVenueLatitude :: Float -- ^ Latitude of the venue , sendVenueLongitude :: Float -- ^ Longitude of the venue diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVideo.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVideo.hs index 55032ca..cf4e00c 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVideo.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVideo.hs @@ -37,7 +37,8 @@ import Telegram.Bot.API.Internal.TH -- | Request parameters for 'sendVideo'. data SendVideoRequest = SendVideoRequest - { sendVideoChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername) + { sendVideoBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendVideoChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername) , sendVideoMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendVideoVideo :: InputFile -- ^ Video to send. Pass a file_id as String to send an video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. More info on Sending Files » , sendVideoDuration :: Maybe Int -- ^ Duration of sent video in seconds diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVideoNote.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVideoNote.hs index 78c7fee..230595a 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVideoNote.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVideoNote.hs @@ -35,7 +35,8 @@ import Telegram.Bot.API.Internal.TH -- | Request parameters for 'sendVideoNote'. data SendVideoNoteRequest = SendVideoNoteRequest - { sendVideoNoteChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). + { sendVideoNoteBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendVideoNoteChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). , sendVideoNoteMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendVideoNoteVideoNote :: InputFile -- ^ Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. More info on Sending Files ». Sending video notes by a URL is currently unsupported , sendVideoNoteDuration :: Maybe Int -- ^ Duration of sent video in seconds diff --git a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVoice.hs b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVoice.hs index 9301f8d..9c45d14 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVoice.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Methods/SendVoice.hs @@ -37,7 +37,8 @@ import Telegram.Bot.API.Internal.TH -- | Request parameters for 'sendVoice'. data SendVoiceRequest = SendVoiceRequest - { sendVoiceChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). + { sendVoiceBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendVoiceChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). , sendVoiceMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendVoiceVoice :: InputFile -- ^ Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files » , sendVoiceCaption :: Maybe Text -- ^ Voice message caption, 0-1024 characters after entities parsing diff --git a/telegram-bot-api/src/Telegram/Bot/API/Stickers.hs b/telegram-bot-api/src/Telegram/Bot/API/Stickers.hs index 293b6e9..6297f29 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Stickers.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Stickers.hs @@ -45,10 +45,11 @@ data StickerFile = StickerFile {stickerFileSticker :: InputFile, stickerFileLabe -- | Request parameters for 'sendSticker'. data SendStickerRequest = SendStickerRequest - { sendStickerChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). + { sendStickerBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection on behalf of which the message will be sent. + , sendStickerChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername). , sendStickerMessageThreadId :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only. , sendStickerEmoji :: Maybe Text -- ^ Emoji associated with the sticker; only for just uploaded stickers. - , sendStickerSticker :: InputFile -- ^ Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP file from the Internet, or upload a new one using multipart/form-data. + , sendStickerSticker :: InputFile -- ^ Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a __.WEBP__ sticker from the Internet, or upload a new __.WEBP__, __.TGS__, or __.WEBM__ sticker using multipart\/form-data. More information on Sending Files ». Video and animated stickers can't be sent via an HTTP URL. , sendStickerDisableNotification :: Maybe Bool -- ^ Sends the message silently. Users will receive a notification with no sound. , sendStickerProtectContent :: Maybe Bool -- ^ Protects the contents of the sent message from forwarding and saving. , sendStickerReplyToMessageId :: Maybe MessageId -- ^ If the message is a reply, ID of the original message @@ -147,7 +148,7 @@ type UploadStickerFileLink :> ReqBody '[JSON] UploadStickerFileRequest :> Post '[JSON] (Response File) --- | Use this method to upload f file in .WEBP, .PNG, .TGS, or .WEBM format +-- | Use this method to upload f file in __.WEBP__, __.PNG__, __.TGS__, or __.WEBM__ format -- with a sticker for later use in createNewStickerSet -- and addStickerToSet methods (can be used multiple times). -- Returns the uploaded File on success. @@ -168,8 +169,7 @@ data CreateNewStickerSetRequest = CreateNewStickerSetRequest , createNewStickerSetName :: T.Text -- ^ Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_”. is case insensitive. 1-64 characters. , createNewStickerSetTitle :: T.Text -- ^ Sticker set title, 1-64 characters , createNewStickerSetStickers :: [InputSticker] -- ^ A JSON-serialized list of 1-50 initial stickers to be added to the sticker set. - , createNewStickerFormat :: Text -- ^ Format of stickers in the set, must be one of “static”, “animated”, “video”. - , createNewStickerSetType :: Maybe StickerSetType -- ^ Type of stickers in the set, pass “regular”, “mask”, or “custom_emoji”. By default, a regular sticker set is created. + , createNewStickerSetStickerType :: Maybe StickerSetType -- ^ Type of stickers in the set, pass “regular”, “mask”, or “custom_emoji”. By default, a regular sticker set is created. , createNewStickerSetNeedsRepainting :: Maybe Bool -- ^ 'True' if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only. } deriving Generic @@ -182,9 +182,7 @@ type CreateNewStickerSet -- | Use this method to create a new sticker -- set owned by a user. The bot will be able --- to edit the sticker set thus created. You --- must use exactly one of the fields png_sticker or tgs_sticker. --- Returns True on success. +-- to edit the sticker set thus created. Returns 'True' on success. createNewStickerSet :: CreateNewStickerSetRequest -> ClientM (Response Bool) createNewStickerSet = client (Proxy @CreateNewStickerSet) @@ -263,6 +261,7 @@ data SetStickerSetThumbnailRequest = SetStickerSetThumbnailRequest { setStickerSetThumbnailName :: T.Text -- ^ Sticker set name , setStickerSetThumbnailUserId :: UserId -- ^ User identifier of the sticker set owner , setStickerSetThumbnailThumbnail :: InputFile -- ^ A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see for animated sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. Animated sticker set thumbnail can't be uploaded via HTTP URL. + , setStickerSetThumbnailFormat :: Text -- ^ Format of the thumbnail, must be one of “static” for a __.WEBP__ or __.PNG__ image, “animated” for a __.TGS__ animation, or “video” for a WEBM video. } deriving Generic instance ToJSON SetStickerSetThumbnailRequest 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 a48d055..87a7bcc 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types.hs @@ -18,10 +18,15 @@ module Telegram.Bot.API.Types , module Telegram.Bot.API.Types.BotCommand , module Telegram.Bot.API.Types.BotCommandScope , module Telegram.Bot.API.Types.BotDescription + , module Telegram.Bot.API.Types.Birthdate , module Telegram.Bot.API.Types.BotName , module Telegram.Bot.API.Types.BotShortDescription , module Telegram.Bot.API.Types.BusinessConnection + , module Telegram.Bot.API.Types.BusinessIntro , module Telegram.Bot.API.Types.BusinessMessagesDeleted + , module Telegram.Bot.API.Types.BusinessLocation + , module Telegram.Bot.API.Types.BusinessOpeningHours + , module Telegram.Bot.API.Types.BusinessOpeningHoursInterval , module Telegram.Bot.API.Types.CallbackGame , module Telegram.Bot.API.Types.CallbackQuery , module Telegram.Bot.API.Types.Chat @@ -98,6 +103,7 @@ module Telegram.Bot.API.Types , module Telegram.Bot.API.Types.ReplyKeyboardRemove , module Telegram.Bot.API.Types.ReplyParameters , module Telegram.Bot.API.Types.ResponseParameters + , module Telegram.Bot.API.Types.SharedUser , module Telegram.Bot.API.Types.ShippingAddress , module Telegram.Bot.API.Types.ShippingOption , module Telegram.Bot.API.Types.ShippingQuery @@ -128,10 +134,15 @@ import Telegram.Bot.API.Types.Audio import Telegram.Bot.API.Types.BotCommand import Telegram.Bot.API.Types.BotCommandScope import Telegram.Bot.API.Types.BotDescription +import Telegram.Bot.API.Types.Birthdate import Telegram.Bot.API.Types.BotName import Telegram.Bot.API.Types.BotShortDescription import Telegram.Bot.API.Types.BusinessConnection +import Telegram.Bot.API.Types.BusinessIntro import Telegram.Bot.API.Types.BusinessMessagesDeleted +import Telegram.Bot.API.Types.BusinessLocation +import Telegram.Bot.API.Types.BusinessOpeningHours +import Telegram.Bot.API.Types.BusinessOpeningHoursInterval import Telegram.Bot.API.Types.CallbackGame import Telegram.Bot.API.Types.CallbackQuery import Telegram.Bot.API.Types.Chat @@ -208,6 +219,7 @@ import Telegram.Bot.API.Types.ReplyKeyboardMarkup import Telegram.Bot.API.Types.ReplyKeyboardRemove import Telegram.Bot.API.Types.ReplyParameters import Telegram.Bot.API.Types.ResponseParameters +import Telegram.Bot.API.Types.SharedUser import Telegram.Bot.API.Types.ShippingAddress import Telegram.Bot.API.Types.ShippingOption import Telegram.Bot.API.Types.ShippingQuery diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/Birthdate.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/Birthdate.hs new file mode 100644 index 0000000..c157152 --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/Birthdate.hs @@ -0,0 +1,23 @@ +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +module Telegram.Bot.API.Types.Birthdate where + +import Data.Aeson (FromJSON (..), ToJSON (..)) +import Data.Time.Calendar +import GHC.Generics (Generic) + +import Telegram.Bot.API.Internal.Utils + + +-- ** 'Birthdate' + +-- | Describes the birthdate of a user. +data Birthdate = Birthdate + { birthdateDay :: DayOfMonth -- ^ Day of the user's birth; 1-31. + , birthdateMonth :: MonthOfYear -- ^ Month of the user's birth; 1-12. + , birthdate :: Maybe Year -- ^ Year of the user's birth. + } + deriving (Generic, Show) + +instance ToJSON Birthdate where toJSON = gtoJSON +instance FromJSON Birthdate where parseJSON = gparseJSON diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessConnection.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessConnection.hs index f5bbdbd..c41a133 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessConnection.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessConnection.hs @@ -2,7 +2,6 @@ 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) @@ -14,7 +13,7 @@ import Telegram.Bot.API.Internal.Utils -- | Describes the connection of the bot with a business account. data BusinessConnection = BusinessConnection - { businessConnectionId :: Text -- ^ Unique identifier of the business connection. + { businessConnectionId :: BusinessConnectionId -- ^ 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. diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessIntro.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessIntro.hs new file mode 100644 index 0000000..f0d39b5 --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessIntro.hs @@ -0,0 +1,22 @@ +{-# LANGUAGE DeriveGeneric #-} +module Telegram.Bot.API.Types.BusinessIntro 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.Sticker (Sticker) + +-- ** 'BusinessIntro' + +-- | Contains information about the start page settings of a Telegram Business account. +data BusinessIntro = BusinessIntro + { businessIntroTitle :: Maybe Text -- ^ Title text of the business intro. + , businessIntroMessage :: Maybe Text -- ^ Message text of the business intro. + , businessIntroSticker :: Maybe Sticker -- ^ Sticker of the business intro. + } + deriving (Generic, Show) + +instance ToJSON BusinessIntro where toJSON = gtoJSON +instance FromJSON BusinessIntro where parseJSON = gparseJSON diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessLocation.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessLocation.hs new file mode 100644 index 0000000..c44c7cc --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessLocation.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE DeriveGeneric #-} +module Telegram.Bot.API.Types.BusinessLocation 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.Location + +-- ** 'BusinessLocation' + +-- | Contains information about the location of a Telegram Business account. +data BusinessLocation = BusinessLocation + { businessLocationAddress :: Text -- ^ Address of the business. + , businessLocationLocation :: Maybe Location -- ^ Location of the business. + } + deriving (Generic, Show) + +instance ToJSON BusinessLocation where toJSON = gtoJSON +instance FromJSON BusinessLocation 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 index ea95b60..682236f 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessMessagesDeleted.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessMessagesDeleted.hs @@ -2,7 +2,6 @@ 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 @@ -13,7 +12,7 @@ import Telegram.Bot.API.Internal.Utils -- | This object is received when messages are deleted from a connected business account. data BusinessMessagesDeleted = BusinessMessagesDeleted - { businessMessagesDeletedBusinessConnectionId :: Text -- ^ Unique identifier of the business connection. + { businessMessagesDeletedBusinessConnectionId :: BusinessConnectionId -- ^ 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. } diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessOpeningHours.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessOpeningHours.hs new file mode 100644 index 0000000..eac5a3a --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessOpeningHours.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE DeriveGeneric #-} +module Telegram.Bot.API.Types.BusinessOpeningHours 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.BusinessOpeningHoursInterval + +-- ** 'BusinessOpeningHours' + +-- | +data BusinessOpeningHours = BusinessOpeningHours + { businessOpeningHoursTimeZoneName :: Text -- ^ Unique name of the time zone for which the opening hours are defined. + , businessOpeningHoursOpeningHours :: [BusinessOpeningHoursInterval] -- ^ List of time intervals describing business opening hours. + } + deriving (Generic, Show) + +instance ToJSON BusinessOpeningHours where toJSON = gtoJSON +instance FromJSON BusinessOpeningHours where parseJSON = gparseJSON diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessOpeningHoursInterval.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessOpeningHoursInterval.hs new file mode 100644 index 0000000..f23d17a --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/BusinessOpeningHoursInterval.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE DeriveGeneric #-} +module Telegram.Bot.API.Types.BusinessOpeningHoursInterval where + +import Data.Aeson (FromJSON (..), ToJSON (..)) +import GHC.Generics (Generic) + +import Telegram.Bot.API.Internal.Utils + +-- ** 'BusinessOpeningHoursInterval' + +-- | Contains information about the start page settings of a Telegram Business account. +data BusinessOpeningHoursInterval = BusinessOpeningHoursInterval + { businessOpeningHoursIntervalOpeningMinute :: Int -- ^ The minute's sequence number in a week, starting on Monday, marking the start of the time interval during which the business is open; @0 - 7 * 24 * 60@. + , businessOpeningHoursIntervalClosingMinute :: Int -- ^ The minute's sequence number in a week, starting on Monday, marking the end of the time interval during which the business is open; @0 - 8 * 24 * 60@. + } + deriving (Generic, Show) + +instance ToJSON BusinessOpeningHoursInterval where toJSON = gtoJSON +instance FromJSON BusinessOpeningHoursInterval where parseJSON = gparseJSON 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 24e3965..dcdc33a 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/Chat.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/Chat.hs @@ -6,6 +6,10 @@ 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.ChatLocation import Telegram.Bot.API.Types.ChatPhoto import Telegram.Bot.API.Types.ChatPermissions @@ -21,16 +25,23 @@ import Telegram.Bot.API.Internal.Utils -- 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'. - , 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'. , 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'. diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/ChatShared.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/ChatShared.hs index eb1463e..e2a6e18 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/ChatShared.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/ChatShared.hs @@ -2,9 +2,11 @@ module Telegram.Bot.API.Types.ChatShared where import Data.Aeson (FromJSON (..), ToJSON (..)) +import Data.Text (Text) import GHC.Generics (Generic) import Telegram.Bot.API.Types.Common +import Telegram.Bot.API.Types.PhotoSize import Telegram.Bot.API.Internal.Utils -- ** 'ChatShared' @@ -13,6 +15,9 @@ import Telegram.Bot.API.Internal.Utils data ChatShared = ChatShared { chatSharedRequestId :: RequestId -- ^ Identifier of the request. , chatSharedChatId :: ChatId -- ^ Identifier of the shared chat. 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. The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means. + , chatSharedTitle :: Maybe Text -- ^ Title of the chat, if the title was requested by the bot. + , chatSharedUsername :: Maybe Text -- ^ Username of the chat, if the username was requested by the bot and available. + , chatSharedPhoto :: Maybe [PhotoSize] -- ^ Available sizes of the chat photo, if the photo was requested by the bot. } deriving (Generic, Show) diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/Common.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/Common.hs index e83513b..a3cd1e1 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/Common.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/Common.hs @@ -79,6 +79,10 @@ newtype WebAppInfo = WebAppInfo { webAppInfoUrl :: Text } newtype CallbackQueryId = CallbackQueryId Text deriving (Eq, Show, Generic, ToJSON, FromJSON) +-- | Unique identifier of the business connection. +newtype BusinessConnectionId = BusinessConnectionId Text + deriving (Eq, Show, Generic, ToHttpApiData, ToJSON, FromJSON) + -- | Unique identifier for the target chat -- or username of the target channel (in the format @\@channelusername@). data SomeChatId diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/KeyboardButtonRequestChat.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/KeyboardButtonRequestChat.hs index 70a93ba..4393467 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/KeyboardButtonRequestChat.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/KeyboardButtonRequestChat.hs @@ -20,6 +20,9 @@ data KeyboardButtonRequestChat = KeyboardButtonRequestChat , keyboardButtonRequestChatUserAdministratorRights :: Maybe ChatAdministratorRights -- ^ A JSON-serialized object listing the required administrator rights of the user in the chat. The rights must be a superset of @bot_administrator_rights@. If not specified, no additional restrictions are applied. , keyboardButtonRequestChatBotAdministratorRights :: Maybe ChatAdministratorRights -- ^ A JSON-serialized object listing the required administrator rights of the bot in the chat. The rights must be a subset of @user_administrator_rights@. If not specified, no additional restrictions are applied. , keyboardButtonRequestChatBotIsMember :: Maybe Bool -- ^ Pass 'True' to request a chat with the bot as a member. Otherwise, no additional restrictions are applied. + , keyboardButtonRequestChatRequestTitle :: Maybe Bool -- ^ Pass 'True' to request the chat's title. + , keyboardButtonRequestChatRequestUsername :: Maybe Bool -- ^ Pass 'True' to request the chat's username. + , keyboardButtonRequestChatRequestPhoto :: Maybe Bool -- ^ Pass 'True' to request the chat's photo. } deriving (Generic, Show) diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/KeyboardButtonRequestUsers.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/KeyboardButtonRequestUsers.hs index a99df4c..9a285a5 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/KeyboardButtonRequestUsers.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/KeyboardButtonRequestUsers.hs @@ -17,6 +17,9 @@ data KeyboardButtonRequestUsers = KeyboardButtonRequestUsers , keyboardButtonRequestUsersUserIsBot :: Maybe Bool -- ^ Pass 'True' to request a bot, pass 'False' to request a regular user. If not specified, no additional restrictions are applied. , keyboardButtonRequestUsersUserIsPremium :: Maybe Bool -- ^ Pass 'True' to request a premium user, pass 'False' to request a non-premium user. If not specified, no additional restrictions are applied. , keyboardButtonRequestUsersMaxQuantity :: Maybe Int -- ^ The maximum number of users to be selected; 1-10. Defaults to 1. + , keyboardButtonRequestUsersRequestName :: Maybe Bool -- ^ Pass 'True' to request the users' first and last names. + , keyboardButtonRequestUsersRequestUsername :: Maybe Bool -- ^ Pass 'True' to request the users' usernames. + , keyboardButtonRequestUsersRequestPhoto :: Maybe Bool -- ^ Pass 'True' to request the users' photos. } deriving (Generic, Show) 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 e7acaa8..326d5ee 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/Message.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/Message.hs @@ -8,13 +8,13 @@ import GHC.Generics (Generic) 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 import Telegram.Bot.API.Types.Dice +import Telegram.Bot.API.Types.Document import {-# SOURCE #-} Telegram.Bot.API.Types.ExternalReplyInfo import Telegram.Bot.API.Types.ForumTopicEdited import Telegram.Bot.API.Types.ForumTopicClosed @@ -33,6 +33,7 @@ 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.PassportData import Telegram.Bot.API.Types.PhotoSize import Telegram.Bot.API.Types.Poll @@ -63,14 +64,11 @@ data Message = Message , 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. + , messageSenderBusinessBot :: Maybe User -- ^ The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account. , messageDate :: POSIXTime -- ^ Date the message was sent in Unix time. + , messageBusinessConnectionId :: Maybe BusinessConnectionId -- ^ Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier. , messageChat :: Chat -- ^ Conversation the message belongs to. - , messageForwardFrom :: Maybe User -- ^ For forwarded messages, sender of the original message. - , messageForwardFromChat :: Maybe Chat -- ^ For messages forwarded from channels, information about the original channel. - , messageForwardFromMessageId :: Maybe MessageId -- ^ For messages forwarded from channels, identifier of the original message in the channel. - , messageForwardSignature :: Maybe Text -- ^ For messages forwarded from channels, signature of the post author if present. - , messageForwardSenderName :: Maybe Text -- ^ Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages. - , messageForwardDate :: Maybe POSIXTime -- ^ For forwarded messages, date the original message was sent in Unix time + , messageForwardOrigin :: Maybe MessageOrigin -- ^ Information about the original message for forwarded messages. , messageIsTopicMessage :: Maybe Bool -- ^ 'True', if the message is sent to a forum topic. , 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. @@ -80,6 +78,7 @@ data Message = Message , 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. + , messageIsFromOffline :: Maybe Bool -- ^ 'True', if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message. , messageMediaGroupId :: Maybe MediaGroupId -- ^ The unique identifier of a media message group this message belongs to , messageAuthorSignature :: Maybe Text -- ^ Signature of the post author for messages in channels , messageText :: Maybe Text -- ^ For text messages, the actual UTF-8 text of the message, 0-4096 characters. diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/MessageOrigin.hs-boot b/telegram-bot-api/src/Telegram/Bot/API/Types/MessageOrigin.hs-boot new file mode 100644 index 0000000..67bb73a --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/MessageOrigin.hs-boot @@ -0,0 +1,11 @@ +module Telegram.Bot.API.Types.MessageOrigin where + +import Data.Aeson + +data MessageOrigin + +instance Show MessageOrigin + +instance FromJSON MessageOrigin + +instance ToJSON MessageOrigin diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/SharedUser.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/SharedUser.hs new file mode 100644 index 0000000..917fc91 --- /dev/null +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/SharedUser.hs @@ -0,0 +1,25 @@ +{-# LANGUAGE DeriveGeneric #-} +module Telegram.Bot.API.Types.SharedUser where + +import Data.Aeson (FromJSON (..), ToJSON (..)) +import Data.Text (Text) +import GHC.Generics (Generic) + +import Telegram.Bot.API.Types.Common +import Telegram.Bot.API.Types.PhotoSize +import Telegram.Bot.API.Internal.Utils + +-- ** 'SharedUser' + +-- | This object contains information about a user that was shared with the bot using a 'KeyboardButtonRequestUsers' button. +data SharedUser = SharedUser + { sharedUserUserId :: UserId -- ^ Identifier of the shared user. 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 64-bit integers or double-precision float types are safe for storing these identifiers. The bot may not have access to the user and could be unable to use this identifier, unless the user is already known to the bot by some other means. + , sharedUserFirstName :: Maybe Text -- ^ First name of the user, if the name was requested by the bot. + , sharedUserLastName :: Maybe Text -- ^ Last name of the user, if the name was requested by the bot. + , sharedUserUsername :: Maybe Text -- ^ Username of the user, if the username was requested by the bot. + , sharedUserPhoto :: Maybe [PhotoSize] -- ^ Available sizes of the chat photo, if the photo was requested by the bot.3 + } + deriving (Generic, Show) + +instance ToJSON SharedUser where toJSON = gtoJSON +instance FromJSON SharedUser where parseJSON = gparseJSON diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/Sticker.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/Sticker.hs index 09f5951..0752ea5 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/Sticker.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/Sticker.hs @@ -17,6 +17,7 @@ import Telegram.Bot.API.Internal.Utils data InputSticker = InputSticker { inputStickerSticker :: InputFile -- ^ The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, upload a new one using @multipart/form-data@, or pass @attach://@ to upload a new one using @multipart/form-data@ under @@ name. Animated and video stickers can't be uploaded via HTTP URL. + , inputStickerFormat :: Text -- ^ Format of the added sticker, must be one of “static” for a __.WEBP__ or __.PNG__ image, “animated” for a __.TGS__ animation, “video” for a WEBM video. , inputStickerEmojiList :: [Text] -- ^ List of 1-20 emoji associated with the sticker. , inputStickerMaskPosition :: Maybe MaskPosition -- ^ Position where the mask should be placed on faces. For “mask” stickers only. , inputStickerKeywords :: Maybe [Text] -- ^ List of 0-20 search keywords for the sticker with total length of up to 64 characters. For “regular” and “custom_emoji” stickers only. @@ -56,8 +57,6 @@ data StickerSet = StickerSet { stickerSetName :: Text -- ^ Sticker set name. , stickerSetTitle :: Text -- ^ Sticker set title. , stickerSetType :: StickerSetType -- ^ Type of stickers in the set, currently one of “regular”, “mask”, “custom_emoji”. - , stickerSetIsAnimated :: Bool -- ^ 'True', if the sticker set contains animated stickers. - , stickerSetIsVideo :: Bool -- ^ 'True', if the sticker is a video sticker. , stickerSetContainsMasks :: Maybe Bool -- ^ True, if the sticker set contains masks. , stickerSetStickers :: [Sticker] -- ^ List of all set stickers. , stickerSetThumbnail :: Maybe PhotoSize -- ^ Sticker set thumbnail in the .WEBP or .TGS format. diff --git a/telegram-bot-api/src/Telegram/Bot/API/Types/UsersShared.hs b/telegram-bot-api/src/Telegram/Bot/API/Types/UsersShared.hs index 22063ce..eb37b77 100644 --- a/telegram-bot-api/src/Telegram/Bot/API/Types/UsersShared.hs +++ b/telegram-bot-api/src/Telegram/Bot/API/Types/UsersShared.hs @@ -5,6 +5,7 @@ import Data.Aeson (FromJSON (..), ToJSON (..)) import GHC.Generics (Generic) import Telegram.Bot.API.Types.Common +import Telegram.Bot.API.Types.SharedUser import Telegram.Bot.API.Internal.Utils -- ** 'UsersShared' @@ -12,7 +13,7 @@ import Telegram.Bot.API.Internal.Utils -- | This object contains information about the users whose identifiers were shared with the bot using a 'KeyboardButtonRequestUsers' button. data UsersShared = UsersShared { usersSharedRequestId :: RequestId -- ^ Identifier of the request. - , usersSharedUserId :: [UserId] -- ^ Identifiers of the shared users. These numbers may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting them. But they have at most 52 significant bits, so 64-bit integers or double-precision float types are safe for storing these identifiers. The bot may not have access to the users and could be unable to use these identifiers, unless the users are already known to the bot by some other means. + , usersSharedUserId :: [SharedUser] -- ^ Information about users shared with the bot. } deriving (Generic, Show) diff --git a/telegram-bot-api/telegram-bot-api.cabal b/telegram-bot-api/telegram-bot-api.cabal index 1172db4..a83ea5e 100644 --- a/telegram-bot-api/telegram-bot-api.cabal +++ b/telegram-bot-api/telegram-bot-api.cabal @@ -57,6 +57,7 @@ library Telegram.Bot.API.Methods.ExportChatInviteLink Telegram.Bot.API.Methods.ForwardMessage Telegram.Bot.API.Methods.ForwardMessages + Telegram.Bot.API.Methods.GetBusinessConnection Telegram.Bot.API.Methods.GetChat Telegram.Bot.API.Methods.GetChatAdministrators Telegram.Bot.API.Methods.GetChatMember @@ -122,13 +123,18 @@ library -- Types Telegram.Bot.API.Types.Animation Telegram.Bot.API.Types.Audio + Telegram.Bot.API.Types.Birthdate Telegram.Bot.API.Types.BotCommand Telegram.Bot.API.Types.BotCommandScope Telegram.Bot.API.Types.BotDescription Telegram.Bot.API.Types.BotName Telegram.Bot.API.Types.BotShortDescription Telegram.Bot.API.Types.BusinessConnection + Telegram.Bot.API.Types.BusinessIntro Telegram.Bot.API.Types.BusinessMessagesDeleted + Telegram.Bot.API.Types.BusinessLocation + Telegram.Bot.API.Types.BusinessOpeningHours + Telegram.Bot.API.Types.BusinessOpeningHoursInterval Telegram.Bot.API.Types.CallbackGame Telegram.Bot.API.Types.CallbackQuery Telegram.Bot.API.Types.Chat @@ -206,6 +212,7 @@ library Telegram.Bot.API.Types.ReplyKeyboardRemove Telegram.Bot.API.Types.ReplyParameters Telegram.Bot.API.Types.ResponseParameters + Telegram.Bot.API.Types.SharedUser Telegram.Bot.API.Types.ShippingAddress Telegram.Bot.API.Types.ShippingOption Telegram.Bot.API.Types.ShippingQuery @@ -240,7 +247,7 @@ library build-depends: aeson , aeson-pretty - , base >=4.9 && <5 + , base >=4.16 && <5 , bytestring , cron >=0.7.0 , filepath diff --git a/telegram-bot-simple/src/Telegram/Bot/Simple/Reply.hs b/telegram-bot-simple/src/Telegram/Bot/Simple/Reply.hs index ca36a9f..0e3587c 100644 --- a/telegram-bot-simple/src/Telegram/Bot/Simple/Reply.hs +++ b/telegram-bot-simple/src/Telegram/Bot/Simple/Reply.hs @@ -60,6 +60,7 @@ toReplyMessage text replyMessageToSendMessageRequest :: SomeChatId -> ReplyMessage -> SendMessageRequest replyMessageToSendMessageRequest someChatId ReplyMessage{..} = SendMessageRequest { sendMessageChatId = someChatId + , sendMessageBusinessConnectionId = Nothing , sendMessageMessageThreadId = replyMessageMessageThreadId , sendMessageText = replyMessageText , sendMessageParseMode = replyMessageParseMode