Skip to content

Commit

Permalink
Merge pull request #182 from fizruk/bot-api-7.2
Browse files Browse the repository at this point in the history
Bot API 7.2
  • Loading branch information
swamp-agr authored May 21, 2024
2 parents d451367 + b5bc76b commit e966fb7
Show file tree
Hide file tree
Showing 41 changed files with 317 additions and 49 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
36 changes: 36 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions telegram-bot-api/src/Telegram/Bot/API/Games.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions telegram-bot-api/src/Telegram/Bot/API/Methods.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion telegram-bot-api/src/Telegram/Bot/API/Methods/SendAudio.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 16 additions & 7 deletions telegram-bot-api/src/Telegram/Bot/API/Methods/SendChatAction.hs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
3 changes: 2 additions & 1 deletion telegram-bot-api/src/Telegram/Bot/API/Methods/SendContact.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion telegram-bot-api/src/Telegram/Bot/API/Methods/SendDice.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion telegram-bot-api/src/Telegram/Bot/API/Methods/SendMessage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion telegram-bot-api/src/Telegram/Bot/API/Methods/SendPhoto.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>
Expand Down
3 changes: 2 additions & 1 deletion telegram-bot-api/src/Telegram/Bot/API/Methods/SendPoll.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion telegram-bot-api/src/Telegram/Bot/API/Methods/SendVenue.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit e966fb7

Please sign in to comment.