diff --git a/.azure-pipelines/variables.yml b/.azure-pipelines/variables.yml
index b36cebb48..0bdc5c342 100644
--- a/.azure-pipelines/variables.yml
+++ b/.azure-pipelines/variables.yml
@@ -1,7 +1,7 @@
variables:
- group: Integration Tests Variables
- name: versionPrefix
- value: 21.3.0
+ value: 21.4.0
- name: versionSuffix
value: ''
- name: ciVersionSuffix
diff --git a/README.md b/README.md
index 1de8a1553..fa9428fbc 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# .NET Client for Telegram Bot API
[](https://nuget.voids.site/packages/Telegram.Bot)
-[](https://core.telegram.org/bots/api#march-31-2024)
+[](https://core.telegram.org/bots/api#july-1-2024)
[](https://telegrambots.github.io/book/)
[](https://t.me/joinchat/B35YY0QbLfd034CFnvCtCA)
[](https://dev.azure.com/tgbots/Telegram.Bot/_build/latest?definitionId=6&branchName=master)
diff --git a/src/Telegram.Bot/Extend.Types.cs b/src/Telegram.Bot/Extend.Types.cs
index eb2f54329..ec02591c2 100644
--- a/src/Telegram.Bot/Extend.Types.cs
+++ b/src/Telegram.Bot/Extend.Types.cs
@@ -480,6 +480,30 @@ public override HttpContent ToHttpContent()
}
}
+ public partial class SendPaidMediaRequest
+ {
+ ///
+ public override HttpContent ToHttpContent()
+ {
+ var multipartContent = GenerateMultipartFormDataContent();
+
+ foreach (var mediaItem in Media)
+ {
+ if (mediaItem is InputPaidMedia { Media: InputFileStream file })
+ {
+ multipartContent.AddContentIfInputFile(file, file.FileName!);
+ }
+
+ if (mediaItem is IInputMediaThumb { Thumbnail: InputFileStream thumbnail })
+ {
+ multipartContent.AddContentIfInputFile(thumbnail, thumbnail.FileName!);
+ }
+ }
+
+ return multipartContent;
+ }
+ }
+
public partial class SendPollRequest
{
///
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessageRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessageRequest.cs
index f3e49d5fc..fe15f28c1 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessageRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessageRequest.cs
@@ -1,6 +1,6 @@
namespace Telegram.Bot.Requests;
-/// Use this method to copy messages of any kind. Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz can be copied only if the value of the field CorrectOptionId is known to the bot. The method is analogous to the method ForwardMessage, but the copied message doesn't have a link to the original message.Returns: The of the sent message on success.
+/// Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz can be copied only if the value of the field CorrectOptionId is known to the bot. The method is analogous to the method ForwardMessage, but the copied message doesn't have a link to the original message.Returns: The of the sent message on success.
public partial class CopyMessageRequest : RequestBase, IChatTargetable
{
/// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessagesRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessagesRequest.cs
index 0bcbba2b5..5b0068426 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessagesRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessagesRequest.cs
@@ -1,6 +1,6 @@
namespace Telegram.Bot.Requests;
-/// Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz can be copied only if the value of the field CorrectOptionId is known to the bot. The method is analogous to the method ForwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages.Returns: An array of of the sent messages is returned.
+/// Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz can be copied only if the value of the field CorrectOptionId is known to the bot. The method is analogous to the method ForwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages.Returns: An array of of the sent messages is returned.
public partial class CopyMessagesRequest : RequestBase, IChatTargetable
{
/// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
diff --git a/src/Telegram.Bot/Requests/Available methods/SendPaidMediaRequest.cs b/src/Telegram.Bot/Requests/Available methods/SendPaidMediaRequest.cs
new file mode 100644
index 000000000..4432a9963
--- /dev/null
+++ b/src/Telegram.Bot/Requests/Available methods/SendPaidMediaRequest.cs
@@ -0,0 +1,57 @@
+namespace Telegram.Bot.Requests;
+
+/// Use this method to send paid media to channel chats.Returns: The sent is returned.
+public partial class SendPaidMediaRequest : FileRequestBase, IChatTargetable
+{
+ /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
+ public required ChatId ChatId { get; set; }
+
+ /// The number of Telegram Stars that must be paid to buy access to the media
+ [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
+ public required int StarCount { get; set; }
+
+ /// A array describing the media to be sent; up to 10 items
+ [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
+ public required IEnumerable Media { get; set; }
+
+ /// Media caption, 0-1024 characters after entities parsing
+ public string? Caption { get; set; }
+
+ /// Mode for parsing entities in the media caption. See formatting options for more details.
+ public ParseMode ParseMode { get; set; }
+
+ /// A list of special entities that appear in the caption, which can be specified instead of ParseMode
+ public IEnumerable? CaptionEntities { get; set; }
+
+ /// Pass , if the caption must be shown above the message media
+ public bool ShowCaptionAboveMedia { get; set; }
+
+ /// Sends the message silently. Users will receive a notification with no sound.
+ public bool DisableNotification { get; set; }
+
+ /// Protects the contents of the sent message from forwarding and saving
+ public bool ProtectContent { get; set; }
+
+ /// Description of the message to reply to
+ public ReplyParameters? ReplyParameters { get; set; }
+
+ /// Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
+ public IReplyMarkup? ReplyMarkup { get; set; }
+
+ /// Initializes an instance of
+ /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ /// The number of Telegram Stars that must be paid to buy access to the media
+ /// A array describing the media to be sent; up to 10 items
+ [Obsolete("Use parameterless constructor with required properties")]
+ [SetsRequiredMembers]
+ public SendPaidMediaRequest(ChatId chatId, int starCount, IEnumerable media) : this()
+ {
+ ChatId = chatId;
+ StarCount = starCount;
+ Media = media;
+ }
+
+ /// Instantiates a new
+ public SendPaidMediaRequest() : base("sendPaidMedia") { }
+}
diff --git a/src/Telegram.Bot/TelegramBotClientExtensions.ApiMethods.cs b/src/Telegram.Bot/TelegramBotClientExtensions.ApiMethods.cs
index a13770c03..d10b27f4e 100644
--- a/src/Telegram.Bot/TelegramBotClientExtensions.ApiMethods.cs
+++ b/src/Telegram.Bot/TelegramBotClientExtensions.ApiMethods.cs
@@ -240,7 +240,7 @@ public static async Task ForwardMessagesAsync(
ProtectContent = protectContent,
}, cancellationToken).ConfigureAwait(false);
- /// Use this method to copy messages of any kind. Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz can be copied only if the value of the field CorrectOptionId is known to the bot. The method is analogous to the method ForwardMessage, but the copied message doesn't have a link to the original message.
+ /// Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz can be copied only if the value of the field CorrectOptionId is known to the bot. The method is analogous to the method ForwardMessage, but the copied message doesn't have a link to the original message.
/// An instance of
/// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
/// Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
@@ -287,7 +287,7 @@ public static async Task CopyMessageAsync(
ReplyMarkup = replyMarkup,
}, cancellationToken).ConfigureAwait(false);
- /// Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz can be copied only if the value of the field CorrectOptionId is known to the bot. The method is analogous to the method ForwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages.
+ /// Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz can be copied only if the value of the field CorrectOptionId is known to the bot. The method is analogous to the method ForwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages.
/// An instance of
/// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
/// Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername)
@@ -719,6 +719,50 @@ public static async Task SendVideoNoteAsync(
BusinessConnectionId = businessConnectionId,
}, cancellationToken).ConfigureAwait(false);
+ /// Use this method to send paid media to channel chats.
+ /// An instance of
+ /// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
+ /// The number of Telegram Stars that must be paid to buy access to the media
+ /// A array describing the media to be sent; up to 10 items
+ /// Media caption, 0-1024 characters after entities parsing
+ /// Mode for parsing entities in the media caption. See formatting options for more details.
+ /// A list of special entities that appear in the caption, which can be specified instead of
+ /// Pass , if the caption must be shown above the message media
+ /// Sends the message silently. Users will receive a notification with no sound.
+ /// Protects the contents of the sent message from forwarding and saving
+ /// Description of the message to reply to
+ /// Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ /// The sent is returned.
+ public static async Task SendPaidMedia(
+ this ITelegramBotClient botClient,
+ ChatId chatId,
+ int starCount,
+ IEnumerable media,
+ string? caption = default,
+ ParseMode parseMode = default,
+ IEnumerable? captionEntities = default,
+ bool showCaptionAboveMedia = default,
+ bool disableNotification = default,
+ bool protectContent = default,
+ ReplyParameters? replyParameters = default,
+ IReplyMarkup? replyMarkup = default,
+ CancellationToken cancellationToken = default
+ ) => await botClient.ThrowIfNull().MakeRequestAsync(new SendPaidMediaRequest
+ {
+ ChatId = chatId,
+ StarCount = starCount,
+ Media = media,
+ Caption = caption,
+ ParseMode = parseMode,
+ CaptionEntities = captionEntities,
+ ShowCaptionAboveMedia = showCaptionAboveMedia,
+ DisableNotification = disableNotification,
+ ProtectContent = protectContent,
+ ReplyParameters = replyParameters,
+ ReplyMarkup = replyMarkup,
+ }, cancellationToken).ConfigureAwait(false);
+
/// Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type.
/// An instance of
/// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
diff --git a/src/Telegram.Bot/Types/Animation.cs b/src/Telegram.Bot/Types/Animation.cs
index f0f34ffa5..240321221 100644
--- a/src/Telegram.Bot/Types/Animation.cs
+++ b/src/Telegram.Bot/Types/Animation.cs
@@ -3,24 +3,24 @@
/// This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
public partial class Animation : FileBase
{
- /// Video width as defined by sender
+ /// Video width as defined by the sender
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public int Width { get; set; }
- /// Video height as defined by sender
+ /// Video height as defined by the sender
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public int Height { get; set; }
- /// Duration of the video in seconds as defined by sender
+ /// Duration of the video in seconds as defined by the sender
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public int Duration { get; set; }
- /// Optional. Animation thumbnail as defined by sender
+ /// Optional. Animation thumbnail as defined by the sender
public PhotoSize? Thumbnail { get; set; }
- /// Optional. Original animation filename as defined by sender
+ /// Optional. Original animation filename as defined by the sender
public string? FileName { get; set; }
- /// Optional. MIME type of the file as defined by sender
+ /// Optional. MIME type of the file as defined by the sender
public string? MimeType { get; set; }
}
diff --git a/src/Telegram.Bot/Types/Audio.cs b/src/Telegram.Bot/Types/Audio.cs
index 4f3d155dc..f1f72fcf1 100644
--- a/src/Telegram.Bot/Types/Audio.cs
+++ b/src/Telegram.Bot/Types/Audio.cs
@@ -3,20 +3,20 @@
/// This object represents an audio file to be treated as music by the Telegram clients.
public partial class Audio : FileBase
{
- /// Duration of the audio in seconds as defined by sender
+ /// Duration of the audio in seconds as defined by the sender
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public int Duration { get; set; }
- /// Optional. Performer of the audio as defined by sender or by audio tags
+ /// Optional. Performer of the audio as defined by the sender or by audio tags
public string? Performer { get; set; }
- /// Optional. Title of the audio as defined by sender or by audio tags
+ /// Optional. Title of the audio as defined by the sender or by audio tags
public string? Title { get; set; }
- /// Optional. Original filename as defined by sender
+ /// Optional. Original filename as defined by the sender
public string? FileName { get; set; }
- /// Optional. MIME type of the file as defined by sender
+ /// Optional. MIME type of the file as defined by the sender
public string? MimeType { get; set; }
/// Optional. Thumbnail of the album cover to which the music file belongs
diff --git a/src/Telegram.Bot/Types/Chat.cs b/src/Telegram.Bot/Types/Chat.cs
index d0a6412d3..d1cd6d906 100644
--- a/src/Telegram.Bot/Types/Chat.cs
+++ b/src/Telegram.Bot/Types/Chat.cs
@@ -105,6 +105,9 @@ public partial class ChatFullInfo : Chat
/// Optional. Default chat member permissions, for groups and supergroups
public ChatPermissions? Permissions { get; set; }
+ /// Optional. , if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats.
+ public bool CanSendPaidMedia { get; set; }
+
/// Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds
public int? SlowModeDelay { get; set; }
diff --git a/src/Telegram.Bot/Types/Document.cs b/src/Telegram.Bot/Types/Document.cs
index 1ba83a726..f3a97961b 100644
--- a/src/Telegram.Bot/Types/Document.cs
+++ b/src/Telegram.Bot/Types/Document.cs
@@ -3,12 +3,12 @@
/// This object represents a general file (as opposed to photos, voice messages and audio files).
public partial class Document : FileBase
{
- /// Optional. Document thumbnail as defined by sender
+ /// Optional. Document thumbnail as defined by the sender
public PhotoSize? Thumbnail { get; set; }
- /// Optional. Original filename as defined by sender
+ /// Optional. Original filename as defined by the sender
public string? FileName { get; set; }
- /// Optional. MIME type of the file as defined by sender
+ /// Optional. MIME type of the file as defined by the sender
public string? MimeType { get; set; }
}
diff --git a/src/Telegram.Bot/Types/Enums/InputPaidMediaType.cs b/src/Telegram.Bot/Types/Enums/InputPaidMediaType.cs
new file mode 100644
index 000000000..43ec096fe
--- /dev/null
+++ b/src/Telegram.Bot/Types/Enums/InputPaidMediaType.cs
@@ -0,0 +1,11 @@
+namespace Telegram.Bot.Types.Enums;
+
+/// Type of the media
+[JsonConverter(typeof(InputPaidMediaTypeConverter))]
+public enum InputPaidMediaType
+{
+ /// The paid media to send is a photo.
( can be cast into )
+ Photo = 1,
+ /// The paid media to send is a video.
( can be cast into )
+ Video,
+}
diff --git a/src/Telegram.Bot/Types/Enums/MessageType.cs b/src/Telegram.Bot/Types/Enums/MessageType.cs
index eae332dd4..63b726a3a 100644
--- a/src/Telegram.Bot/Types/Enums/MessageType.cs
+++ b/src/Telegram.Bot/Types/Enums/MessageType.cs
@@ -112,6 +112,8 @@ public enum MessageType
BoostAdded,
/// The contains a
ChatBackgroundSet,
+ /// The contains a
+ PaidMedia,
#pragma warning disable CS1591
WebsiteConnected = ConnectedWebsite,
diff --git a/src/Telegram.Bot/Types/Enums/PaidMediaType.cs b/src/Telegram.Bot/Types/Enums/PaidMediaType.cs
new file mode 100644
index 000000000..5b165e8c8
--- /dev/null
+++ b/src/Telegram.Bot/Types/Enums/PaidMediaType.cs
@@ -0,0 +1,13 @@
+namespace Telegram.Bot.Types.Enums;
+
+/// Type of the paid media, always
+[JsonConverter(typeof(PaidMediaTypeConverter))]
+public enum PaidMediaType
+{
+ /// The paid media isn't available before the payment.
( can be cast into )
+ Preview = 1,
+ /// The paid media is a photo.
( can be cast into )
+ Photo,
+ /// The paid media is a video.
( can be cast into )
+ Video,
+}
diff --git a/src/Telegram.Bot/Types/ExternalReplyInfo.cs b/src/Telegram.Bot/Types/ExternalReplyInfo.cs
index e6d1a18dc..2552a28f0 100644
--- a/src/Telegram.Bot/Types/ExternalReplyInfo.cs
+++ b/src/Telegram.Bot/Types/ExternalReplyInfo.cs
@@ -25,6 +25,9 @@ public partial class ExternalReplyInfo
/// Optional. Message is a general file, information about the file
public Document? Document { get; set; }
+ /// Optional. Message contains paid media; information about the paid media
+ public PaidMediaInfo? PaidMedia { get; set; }
+
/// Optional. Message is a photo, available sizes of the photo
public PhotoSize[]? Photo { get; set; }
diff --git a/src/Telegram.Bot/Types/InputPaidMedia.cs b/src/Telegram.Bot/Types/InputPaidMedia.cs
new file mode 100644
index 000000000..faf12f437
--- /dev/null
+++ b/src/Telegram.Bot/Types/InputPaidMedia.cs
@@ -0,0 +1,45 @@
+namespace Telegram.Bot.Types;
+
+/// This object describes the paid media to be sent. Currently, it can be one of ,
+[CustomJsonPolymorphic("type")]
+[CustomJsonDerivedType(typeof(InputPaidMediaPhoto), "photo")]
+[CustomJsonDerivedType(typeof(InputPaidMediaVideo), "video")]
+public abstract partial class InputPaidMedia
+{
+ /// Type of the media
+ [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
+ public abstract InputPaidMediaType Type { get; }
+
+ /// File to send. Pass a FileId to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or use with a specific filename. More information on Sending Files »
+ [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
+ public InputFile Media { get; set; } = default!;
+}
+
+/// The paid media to send is a photo.
+public partial class InputPaidMediaPhoto : InputPaidMedia
+{
+ /// Type of the media, always
+ public override InputPaidMediaType Type => InputPaidMediaType.Photo;
+}
+
+/// The paid media to send is a video.
+public partial class InputPaidMediaVideo : InputPaidMedia, IInputMediaThumb
+{
+ /// Type of the media, always
+ public override InputPaidMediaType Type => InputPaidMediaType.Video;
+
+ /// Optional. 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 . Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://<FileAttachName>” if the thumbnail was uploaded using under <FileAttachName>. More information on Sending Files »
+ public InputFile? Thumbnail { get; set; }
+
+ /// Optional. Video width
+ public int Width { get; set; }
+
+ /// Optional. Video height
+ public int Height { get; set; }
+
+ /// Optional. Video duration in seconds
+ public int Duration { get; set; }
+
+ /// Optional. Pass if the uploaded video is suitable for streaming
+ public bool SupportsStreaming { get; set; }
+}
diff --git a/src/Telegram.Bot/Types/InputPollOption.cs b/src/Telegram.Bot/Types/InputPollOption.cs
index 723f0962a..683ca78c7 100644
--- a/src/Telegram.Bot/Types/InputPollOption.cs
+++ b/src/Telegram.Bot/Types/InputPollOption.cs
@@ -1,6 +1,6 @@
namespace Telegram.Bot.Types;
-/// This object contains information about one answer option in a poll to send.
+/// This object contains information about one answer option in a poll to be sent.
public partial class InputPollOption
{
/// Option text, 1-100 characters
diff --git a/src/Telegram.Bot/Types/Location.cs b/src/Telegram.Bot/Types/Location.cs
index 1fd11eba0..dd305fa3e 100644
--- a/src/Telegram.Bot/Types/Location.cs
+++ b/src/Telegram.Bot/Types/Location.cs
@@ -3,11 +3,11 @@
/// This object represents a point on the map.
public partial class Location
{
- /// Latitude as defined by sender
+ /// Latitude as defined by the sender
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public double Latitude { get; set; }
- /// Longitude as defined by sender
+ /// Longitude as defined by the sender
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public double Longitude { get; set; }
diff --git a/src/Telegram.Bot/Types/MenuButton.cs b/src/Telegram.Bot/Types/MenuButton.cs
index bdfb6447c..be509f5cc 100644
--- a/src/Telegram.Bot/Types/MenuButton.cs
+++ b/src/Telegram.Bot/Types/MenuButton.cs
@@ -29,7 +29,7 @@ public partial class MenuButtonWebApp : MenuButton
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string Text { get; set; } = default!;
- /// Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method AnswerWebAppQuery.
+ /// Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method AnswerWebAppQuery. Alternatively, a t.me link to a Web App of the bot can be specified in the object instead of the Web App's URL, in which case the Web App will be opened as if the user pressed the link.
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public WebAppInfo WebApp { get; set; } = default!;
}
diff --git a/src/Telegram.Bot/Types/Message.cs b/src/Telegram.Bot/Types/Message.cs
index a307a1ae7..e192097be 100644
--- a/src/Telegram.Bot/Types/Message.cs
+++ b/src/Telegram.Bot/Types/Message.cs
@@ -95,6 +95,9 @@ public partial class Message
/// Optional. Message is a general file, information about the file
public Document? Document { get; set; }
+ /// Optional. Message contains paid media; information about the paid media
+ public PaidMediaInfo? PaidMedia { get; set; }
+
/// Optional. Message is a photo, available sizes of the photo
public PhotoSize[]? Photo { get; set; }
@@ -113,7 +116,7 @@ public partial class Message
/// Optional. Message is a voice message, information about the file
public Voice? Voice { get; set; }
- /// Optional. Caption for the animation, audio, document, photo, video or voice
+ /// Optional. Caption for the animation, audio, document, paid media, photo, video or voice
public string? Caption { get; set; }
/// Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption
@@ -266,6 +269,7 @@ public partial class Message
{ Animation: not null } => MessageType.Animation,
{ Audio: not null } => MessageType.Audio,
{ Document: not null } => MessageType.Document,
+ { PaidMedia: not null } => MessageType.PaidMedia,
{ Photo: not null } => MessageType.Photo,
{ Sticker: not null } => MessageType.Sticker,
{ Story: not null } => MessageType.Story,
diff --git a/src/Telegram.Bot/Types/PaidMedia.cs b/src/Telegram.Bot/Types/PaidMedia.cs
new file mode 100644
index 000000000..658036c8a
--- /dev/null
+++ b/src/Telegram.Bot/Types/PaidMedia.cs
@@ -0,0 +1,51 @@
+namespace Telegram.Bot.Types;
+
+/// This object describes paid media. Currently, it can be one of , ,
+[CustomJsonPolymorphic("type")]
+[CustomJsonDerivedType(typeof(PaidMediaPreview), "preview")]
+[CustomJsonDerivedType(typeof(PaidMediaPhoto), "photo")]
+[CustomJsonDerivedType(typeof(PaidMediaVideo), "video")]
+public abstract partial class PaidMedia
+{
+ /// Type of the paid media, always
+ [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
+ public abstract PaidMediaType Type { get; }
+}
+
+/// The paid media isn't available before the payment.
+public partial class PaidMediaPreview : PaidMedia
+{
+ /// Type of the paid media, always
+ public override PaidMediaType Type => PaidMediaType.Preview;
+
+ /// Optional. Media width as defined by the sender
+ public int Width { get; set; }
+
+ /// Optional. Media height as defined by the sender
+ public int Height { get; set; }
+
+ /// Optional. Duration of the media in seconds as defined by the sender
+ public int Duration { get; set; }
+}
+
+/// The paid media is a photo.
+public partial class PaidMediaPhoto : PaidMedia
+{
+ /// Type of the paid media, always
+ public override PaidMediaType Type => PaidMediaType.Photo;
+
+ /// The photo
+ [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
+ public PhotoSize[] Photo { get; set; } = default!;
+}
+
+/// The paid media is a video.
+public partial class PaidMediaVideo : PaidMedia
+{
+ /// Type of the paid media, always
+ public override PaidMediaType Type => PaidMediaType.Video;
+
+ /// The video
+ [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
+ public Video Video { get; set; } = default!;
+}
diff --git a/src/Telegram.Bot/Types/PaidMediaInfo.cs b/src/Telegram.Bot/Types/PaidMediaInfo.cs
new file mode 100644
index 000000000..1c3f89ca2
--- /dev/null
+++ b/src/Telegram.Bot/Types/PaidMediaInfo.cs
@@ -0,0 +1,13 @@
+namespace Telegram.Bot.Types;
+
+/// Describes the paid media added to a message.
+public partial class PaidMediaInfo
+{
+ /// The number of Telegram Stars that must be paid to buy access to the media
+ [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
+ public int StarCount { get; set; }
+
+ /// Information about the paid media
+ [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
+ public PaidMedia[] PaidMedia { get; set; } = default!;
+}
diff --git a/src/Telegram.Bot/Types/Payments/PreCheckoutQuery.cs b/src/Telegram.Bot/Types/Payments/PreCheckoutQuery.cs
index 073864795..1decf097e 100644
--- a/src/Telegram.Bot/Types/Payments/PreCheckoutQuery.cs
+++ b/src/Telegram.Bot/Types/Payments/PreCheckoutQuery.cs
@@ -19,7 +19,7 @@ public partial class PreCheckoutQuery
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public int TotalAmount { get; set; }
- /// Bot specified invoice payload
+ /// Bot-specified invoice payload
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string InvoicePayload { get; set; } = default!;
diff --git a/src/Telegram.Bot/Types/Payments/ShippingQuery.cs b/src/Telegram.Bot/Types/Payments/ShippingQuery.cs
index f79d1aaae..a0ce7c632 100644
--- a/src/Telegram.Bot/Types/Payments/ShippingQuery.cs
+++ b/src/Telegram.Bot/Types/Payments/ShippingQuery.cs
@@ -11,7 +11,7 @@ public partial class ShippingQuery
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public User From { get; set; } = default!;
- /// Bot specified invoice payload
+ /// Bot-specified invoice payload
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string InvoicePayload { get; set; } = default!;
diff --git a/src/Telegram.Bot/Types/Payments/SuccessfulPayment.cs b/src/Telegram.Bot/Types/Payments/SuccessfulPayment.cs
index 7064f6885..a88329292 100644
--- a/src/Telegram.Bot/Types/Payments/SuccessfulPayment.cs
+++ b/src/Telegram.Bot/Types/Payments/SuccessfulPayment.cs
@@ -11,7 +11,7 @@ public partial class SuccessfulPayment
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public int TotalAmount { get; set; }
- /// Bot specified invoice payload
+ /// Bot-specified invoice payload
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string InvoicePayload { get; set; } = default!;
diff --git a/src/Telegram.Bot/Types/Payments/TransactionPartner.cs b/src/Telegram.Bot/Types/Payments/TransactionPartner.cs
index 7d969ddd2..cc1cb9a6c 100644
--- a/src/Telegram.Bot/Types/Payments/TransactionPartner.cs
+++ b/src/Telegram.Bot/Types/Payments/TransactionPartner.cs
@@ -1,17 +1,32 @@
namespace Telegram.Bot.Types.Payments;
-/// This object describes the source of a transaction, or its recipient for outgoing transactions. Currently, it can be one of , ,
+/// This object describes the source of a transaction, or its recipient for outgoing transactions. Currently, it can be one of , , ,
[CustomJsonPolymorphic("type")]
-[CustomJsonDerivedType(typeof(TransactionPartnerFragment), "fragment")]
[CustomJsonDerivedType(typeof(TransactionPartnerUser), "user")]
+[CustomJsonDerivedType(typeof(TransactionPartnerFragment), "fragment")]
+[CustomJsonDerivedType(typeof(TransactionPartnerTelegramAds), "telegram_ads")]
[CustomJsonDerivedType(typeof(TransactionPartnerOther), "other")]
public abstract partial class TransactionPartner
{
- /// Type of the transaction partner, always
+ /// Type of the transaction partner
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public abstract TransactionPartnerType Type { get; }
}
+/// Describes a transaction with a user.
+public partial class TransactionPartnerUser : TransactionPartner
+{
+ /// Type of the transaction partner, always
+ public override TransactionPartnerType Type => TransactionPartnerType.User;
+
+ /// Information about the user
+ [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
+ public User User { get; set; } = default!;
+
+ /// Optional. Bot-specified invoice payload
+ public string? InvoicePayload { get; set; }
+}
+
/// Describes a withdrawal transaction with Fragment.
public partial class TransactionPartnerFragment : TransactionPartner
{
@@ -22,15 +37,11 @@ public partial class TransactionPartnerFragment : TransactionPartner
public RevenueWithdrawalState? WithdrawalState { get; set; }
}
-/// Describes a transaction with a user.
-public partial class TransactionPartnerUser : TransactionPartner
+/// Describes a withdrawal transaction to the Telegram Ads platform.
+public partial class TransactionPartnerTelegramAds : TransactionPartner
{
- /// Type of the transaction partner, always
- public override TransactionPartnerType Type => TransactionPartnerType.User;
-
- /// Information about the user
- [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
- public User User { get; set; } = default!;
+ /// Type of the transaction partner, always
+ public override TransactionPartnerType Type => TransactionPartnerType.TelegramAds;
}
/// Describes a transaction with an unknown source or recipient.
diff --git a/src/Telegram.Bot/Types/Payments/TransactionPartnerType.cs b/src/Telegram.Bot/Types/Payments/TransactionPartnerType.cs
index 0c498e10c..f72ab797e 100644
--- a/src/Telegram.Bot/Types/Payments/TransactionPartnerType.cs
+++ b/src/Telegram.Bot/Types/Payments/TransactionPartnerType.cs
@@ -1,6 +1,6 @@
namespace Telegram.Bot.Types.Payments;
-/// Type of the transaction partner, always
+/// Type of the transaction partner
[JsonConverter(typeof(TransactionPartnerTypeConverter))]
public enum TransactionPartnerType
{
@@ -10,4 +10,6 @@ public enum TransactionPartnerType
User,
/// Describes a transaction with an unknown source or recipient.
( can be cast into )
Other,
+ /// Describes a withdrawal transaction to the Telegram Ads platform.
( can be cast into )
+ TelegramAds,
}
diff --git a/src/Telegram.Bot/Types/Video.cs b/src/Telegram.Bot/Types/Video.cs
index 06f7cfeb9..253e0321a 100644
--- a/src/Telegram.Bot/Types/Video.cs
+++ b/src/Telegram.Bot/Types/Video.cs
@@ -3,24 +3,24 @@
/// This object represents a video file.
public partial class Video : FileBase
{
- /// Video width as defined by sender
+ /// Video width as defined by the sender
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public int Width { get; set; }
- /// Video height as defined by sender
+ /// Video height as defined by the sender
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public int Height { get; set; }
- /// Duration of the video in seconds as defined by sender
+ /// Duration of the video in seconds as defined by the sender
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public int Duration { get; set; }
/// Optional. Video thumbnail
public PhotoSize? Thumbnail { get; set; }
- /// Optional. Original filename as defined by sender
+ /// Optional. Original filename as defined by the sender
public string? FileName { get; set; }
- /// Optional. MIME type of the file as defined by sender
+ /// Optional. MIME type of the file as defined by the sender
public string? MimeType { get; set; }
}
diff --git a/src/Telegram.Bot/Types/VideoNote.cs b/src/Telegram.Bot/Types/VideoNote.cs
index 3356a1728..6c7860354 100644
--- a/src/Telegram.Bot/Types/VideoNote.cs
+++ b/src/Telegram.Bot/Types/VideoNote.cs
@@ -3,11 +3,11 @@
/// This object represents a video message (available in Telegram apps as of v.4.0).
public partial class VideoNote : FileBase
{
- /// Video width and height (diameter of the video message) as defined by sender
+ /// Video width and height (diameter of the video message) as defined by the sender
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public int Length { get; set; }
- /// Duration of the video in seconds as defined by sender
+ /// Duration of the video in seconds as defined by the sender
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public int Duration { get; set; }
diff --git a/src/Telegram.Bot/Types/Voice.cs b/src/Telegram.Bot/Types/Voice.cs
index 3bc2665ba..317eee72b 100644
--- a/src/Telegram.Bot/Types/Voice.cs
+++ b/src/Telegram.Bot/Types/Voice.cs
@@ -3,10 +3,10 @@
/// This object represents a voice note.
public partial class Voice : FileBase
{
- /// Duration of the audio in seconds as defined by sender
+ /// Duration of the audio in seconds as defined by the sender
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public int Duration { get; set; }
- /// Optional. MIME type of the file as defined by sender
+ /// Optional. MIME type of the file as defined by the sender
public string? MimeType { get; set; }
}
diff --git a/test/Telegram.Bot.Tests.Unit/EnumConverter/MessageTypeConverterTests.cs b/test/Telegram.Bot.Tests.Unit/EnumConverter/MessageTypeConverterTests.cs
index 709e2e6f1..436f56925 100644
--- a/test/Telegram.Bot.Tests.Unit/EnumConverter/MessageTypeConverterTests.cs
+++ b/test/Telegram.Bot.Tests.Unit/EnumConverter/MessageTypeConverterTests.cs
@@ -142,6 +142,7 @@ public IEnumerator