diff --git a/.azure-pipelines/variables.yml b/.azure-pipelines/variables.yml
index f62e9d522..f26fdfe0c 100644
--- a/.azure-pipelines/variables.yml
+++ b/.azure-pipelines/variables.yml
@@ -3,7 +3,7 @@ variables:
- name: versionPrefix
value: 20.0.0
- name: versionSuffix
- value: 'alpha.2'
+ value: 'alpha.3'
- name: ciVersionSuffix
value: ci.$(Build.BuildId)+git.commit.$(Build.SourceVersion)
- name: isPreRelease
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
index 94397f0ca..676357a4d 100644
--- a/.devcontainer/Dockerfile
+++ b/.devcontainer/Dockerfile
@@ -1,5 +1,5 @@
-ARG DOTNET_VERSION=6.0
-FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-bullseye-slim
+ARG DOTNET_VERSION=8.0
+FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-bookworm-slim
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=${USER_UID}
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index a79f624d2..e88852588 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -4,14 +4,18 @@
"service": "devhost",
"shutdownAction": "stopCompose",
"workspaceFolder": "/workspace",
- "extensions": [
- "ms-dotnettools.csharp",
- "ms-azuretools.vscode-docker",
- "editorconfig.editorconfig",
- "eamodio.gitlens",
- "tintoy.msbuild-project-tools",
- "logerfo.sln-support",
- "formulahendry.dotnet-test-explorer"
- ],
+ "customizations": {
+ "vscode": {
+ "extensions": [
+ "ms-dotnettools.csdevkit",
+ "ms-azuretools.vscode-docker",
+ "editorconfig.editorconfig",
+ "eamodio.gitlens",
+ "tintoy.msbuild-project-tools",
+ "logerfo.sln-support",
+ "formulahendry.dotnet-test-explorer"
+ ]
+ }
+ },
"remoteUser": "vscode"
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3414d4887..feea649b1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,120 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
+## [Unreleased]
+
+> [Bot API 7.0](https://core.telegram.org/bots/api#december-29-2023) (December 29, 2023)
+> [Bot API 7.1](https://core.telegram.org/bots/api#february-16-2024) (February 16, 2024)
+
+### Added
+
+- API methods on `ITelegramBotClient` that accept request classes with parameters
+- Class `UnpinAllGeneralForumTopicMessagesRequest`
+- The classes `ReactionType`, `ReactionTypeEmoji` and `ReactionTypeCustomEmoji` representing different types of reaction.
+- Enum `ReactionTypeKind`
+- Enum `ChatBoostSourceType`
+- The class `KnownReactionTypeEmoji` containing Emojis available for `ReactionTypeEmoji`.
+- Updates about a reaction change on a message with non-anonymous reactions, represented by the class `MessageReactionUpdated`
+and the property `MessageReaction` in the class `Update`. The bot must explicitly allow the update to receive it.
+- Updates about reaction changes on a message with anonymous reactions, represented by the class `MessageReactionCountUpdated`
+and the property `MessageReactionCount` in the class `Update`. The bot must explicitly allow the update to receive it.
+- New enum values `MessageReaction`, `MessageReactionCount` for `UpdateType`.
+- Type `ReactionCount`.
+- Request classes `SetMessageReactionRequest` that allows bots to react to messages.
+- New method `ITelegramBotClient.SetMessageReactionAsync` that allows bots to react to messages.
+- The property `AvailableReactions` to the class `Chat`.
+- The class `ExternalReplyInfo` and the property `ExternalReply` of type `ExternalReplyInfo` to the class `Message`,
+containing information about a message that is replied to by the current message, but can be from another chat or forum topic.
+- The class `TextQuote` and the property `Quote` of type `TextQuote` to the class `Message`,
+which contains the part of the replied message text or caption that is quoted in the current message.
+- The class `ReplyParameters`.
+- The class `LinkPreviewOptions`.
+- The property `LinkPreviewOptions` to the class `Message` with information about the link preview options used to send the message.
+- New enum value `Blockquote` for `MessageEntityType`.
+- Request classes `DeleteMessagesRequest`, `ForwardMessagesRequest` and `CopyMessagesRequest`.
+- New methods `ITelegramBotClient.DeleteMessagesAsync`, `ITelegramBotClient.ForwardMessagesAsync` and `ITelegramBotClient.CopyMessagesAsync`.
+- Updates about chat boost changes, represented by the classes `ChatBoostUpdated` and `ChatBoostRemoved` and the properties `ChatBoost` and `RemovedChatBoost`
+in the class `Update`. The bot must be an administrator in the chat to receive these updates.
+- The classes `ChatBoostSourcePremium`, `ChatBoostSourceGiftCode` and `ChatBoostSourceGiveaway`, representing different sources of a chat boost.
+- The method `ITelegramBotClient.GetUserChatBoostsAsync` for obtaining the list of all active boosts a user has contributed to a chat.
+- Request class `GetUserChatBoostsRequest` for obtaining the list of all active boosts a user has contributed to a chat.
+- The class `Giveaway` and the property `Giveaway` to the class `Message` for messages about scheduled giveaways.
+- The class `GiveawayCreated` and the property `GiveawayCreated` to the class `Message` for service messages about the creation of a scheduled giveaway.
+- The class `GiveawayWinners` and the property `GiveawayWinners` to the class `Message` for messages about the completion of a giveaway with public winners.
+- The class `GiveawayCompleted` and the property `GiveawayCompleted` to the class `Message` for service messages about the completion of a giveaway without public winners.
+- New `MessageType` enum members: `Giveaway`, `GiveawayCreated`, `GiveawayWinners` and `GiveawayCompleted`
+- The properties `AccentColorId`, `BackgroundCustomEmojiId`, `ProfileAccentColorId`, and `ProfileBackgroundCustomEmojiId` to the class `Chat`.
+- The property `HasVisibleHistory` to the class `Chat`.
+- Classes `MaybeInaccessibleMessage` and `InaccessibleMessage`.
+- The class `ChatBoostAdded`
+- Classes `MessageOrigin`, `MessageOriginUser`, `MessageOriginHiddenUser` and `MessageOriginChannel`
+- Enum `MessageOriginType`
+- Fields `UnrestrictBoostCount` and `CustomEmojiStickerSetName` to type `Chat`
+- Enum member `MessageType.BoostAdded`
+- Fields `SenderBoostCount`, `ReplyToStory` and `BoostAdded` to type `Message`
+- Fields `Chat` and `Id` to type `Story`
+
+### Changed
+- All required properties without setters marked as required using `required` keyword
+- All non-default ctors are marked as obsolete in favor of the default ctors with object initialization syntax and required properties
+- All API methods with positional parameters on `ITelegramBotClient` are marked obsolete
+- Class `UnpinAllGeneralForumTopicMessages` marked as obsolete
+- Replaced parameters `ReplyToMessageId` and `AllowSendingWithoutReply` with the property `ReplyParameters` of type `ReplyParameters` in the methods
+ - `ITelegramBotClient.CopyMessageAsync`,
+ - `ITelegramBotClient.SendMessageAsync`,
+ - `ITelegramBotClient.SendPhotoAsync`,
+ - `ITelegramBotClient.SendVideoAsync`,
+ - `ITelegramBotClient.SendAnimationAsync`,
+ - `ITelegramBotClient.SendAudioAsync`,
+ - `ITelegramBotClient.SendDocumentAsync`,
+ - `ITelegramBotClient.SendStickerAsync`,
+ - `ITelegramBotClient.SendVideoNoteAsync`,
+ - `ITelegramBotClient.SendVoiceAsync`,
+ - `ITelegramBotClient.SendLocationAsync`,
+ - `ITelegramBotClient.SendVenueAsync`,
+ - `ITelegramBotClient.SendContactAsync`,
+ - `ITelegramBotClient.SendPollAsync`,
+ - `ITelegramBotClient.SendDiceAsync`,
+ - `ITelegramBotClient.SendInvoiceAsync`,
+ - `ITelegramBotClient.SendGameAsync`,
+ - `ITelegramBotClient.SendMediaGroupAsync`
+- Replaced properties `ReplyToMessageId` and `AllowSendingWithoutReply` with the property `ReplyParameters` of type `ReplyParameters` in the request classes
+ - `CopyMessageRequest`,
+ - `SendMessageRequest`,
+ - `SendPhotoRequest`,
+ - `SendVideoRequest`,
+ - `SendAnimationRequest`,
+ - `SendAudioRequest`,
+ - `SendDocumentRequest`,
+ - `SendStickerRequest`,
+ - `SendVideoNoteRequest`,
+ - `SendVoiceRequest`,
+ - `SendLocationRequest`,
+ - `SendVenueRequest`,
+ - `SendContactRequest`,
+ - `SendPollRequest`,
+ - `SendDiceRequest`,
+ - `SendInvoiceRequest`,
+ - `SendGameRequest`,
+ - `SendMediaGroupRequest`
+- Replaced the parameter `DisableWebPagePreview` with `LinkPreviewOptions` in the methods `SendTextMessageAsync` and `EditMessageTextAsync`.
+- Replaced the property `DisableWebPagePreview` with `LinkPreviewOptions` in the request classes `SendMessageRequest`, `EditMessageTextRequest`
+ and `EditInlineMessageTextRequest`.
+- Replaced the property disable_web_page_preview with `DisableWebPagePreview` in the class `InputTextMessageContent`.
+- Renamed the class `KeyboardButtonRequestUser` to `KeyboardButtonRequestUsers` and added the property `MaxQuantity` to it.
+- Renamed the property `RequestUser` in the class `KeyboardButton` to `RequestUsers`. The old name will still work for backward compatibility.
+- Renamed the class `UserShared` to `UsersShared` and changed the property `UserId` to `UserIds`.
+- Replaced the property `UserShared` in the class Message with the property `UsersShared`.
+- Replaced enum member `MessageType.UserShared` with `MessageType.UsersShared`
+- Fields `ForwardFrom`, `ForwardFromChat`, `ForwardFromMessageId`, `ForwardSignature`, `ForwardSenderName`
+and `ForwardDate` replaced with the field `ForwardOrigin` of type `MessageOrigin` in the class `Message`.
+- Type of the property `Message` of the class `CallbackQuery` to `MaybeInaccessibleMessage`
+- Type of the property `PinnedMessage` of the class `Message` to `MaybeInaccessibleMessage`.
+
+### Removed
+- Fields `ForwardFrom`, `ForwardFromChat`, `ForwardFromMessageId`, `ForwardSignature`, `ForwardSenderName`
+ and `ForwardDate` from type `Message`
+
## [v20.0.0] - Unreleased
> [Bot API 6.9](https://core.telegram.org/bots/api#september-22-2023) (September 22, 2023)
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 000000000..9f6a21db5
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,5 @@
+
+
+ en
+
+
diff --git a/README.md b/README.md
index daf9c3f35..8ebc3ade9 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# .NET Client for Telegram Bot API
[![package](https://img.shields.io/nuget/vpre/Telegram.Bot.svg?label=Telegram.Bot&style=flat-square)](https://www.nuget.org/packages/Telegram.Bot)
-[![Bot API Version](https://img.shields.io/badge/Bot%20API-6.9%20(September%2022,%202023)-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api#september-22-2023)
+[![Bot API Version](https://img.shields.io/badge/Bot%20API-7.1%20(February%2016,%202024)-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api#february-16-2024)
[![documentations](https://img.shields.io/badge/Documentations-Book-orange.svg?style=flat-square)](https://telegrambots.github.io/book/)
[![telegram chat](https://img.shields.io/badge/Support_Chat-Telegram-blue.svg?style=flat-square)](https://t.me/joinchat/B35YY0QbLfd034CFnvCtCA)
diff --git a/Telegram.Bot.sln b/Telegram.Bot.sln
index db2d533c5..8c5817cac 100644
--- a/Telegram.Bot.sln
+++ b/Telegram.Bot.sln
@@ -25,6 +25,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
.gitpod.yml = .gitpod.yml
LICENSE = LICENSE
+ Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".azure-pipelines", ".azure-pipelines", "{71662597-40F2-4192-AC4D-5FB9A1F12642}"
diff --git a/src/EnumSerializer.Generator/EnumSerializer.Generator.csproj b/src/EnumSerializer.Generator/EnumSerializer.Generator.csproj
index d95a01efa..d4d409290 100644
--- a/src/EnumSerializer.Generator/EnumSerializer.Generator.csproj
+++ b/src/EnumSerializer.Generator/EnumSerializer.Generator.csproj
@@ -14,10 +14,10 @@
-
+
-
-
+
+
diff --git a/src/Telegram.Bot/Converters/ChatBoostSourceConverter.cs b/src/Telegram.Bot/Converters/ChatBoostSourceConverter.cs
new file mode 100644
index 000000000..fc1e79983
--- /dev/null
+++ b/src/Telegram.Bot/Converters/ChatBoostSourceConverter.cs
@@ -0,0 +1,58 @@
+using System.Reflection;
+using Newtonsoft.Json.Linq;
+using Telegram.Bot.Types.Enums;
+
+namespace Telegram.Bot.Converters;
+
+internal class ChatBoostSourceConverter : JsonConverter
+{
+ static readonly TypeInfo BaseType = typeof(ChatBoostSource).GetTypeInfo();
+
+ public override bool CanWrite => false;
+ public override bool CanRead => true;
+ public override bool CanConvert(Type objectType) =>
+ BaseType.IsAssignableFrom(objectType.GetTypeInfo());
+
+ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
+ {
+ if (value is null)
+ {
+ writer.WriteNull();
+ }
+ else
+ {
+ var jo = JObject.FromObject(value);
+ jo.WriteTo(writer);
+ }
+ }
+
+ public override object? ReadJson(
+ JsonReader reader,
+ Type objectType,
+ object? existingValue,
+ JsonSerializer serializer)
+ {
+ var jo = JObject.Load(reader);
+ var type = jo["source"]?.ToObject();
+
+ if (type is null)
+ {
+ return null;
+ }
+
+ var actualType = type switch
+ {
+ ChatBoostSourceType.Premium => typeof(ChatBoostSourcePremium),
+ ChatBoostSourceType.GiftCode => typeof(ChatBoostSourceGiftCode),
+ ChatBoostSourceType.Giveaway => typeof(ChatBoostSourceGiveaway),
+ _ => throw new JsonSerializationException($"Unknown chat boost source value of '{jo["source"]}'")
+ };
+
+ // Remove status because status property only has getter
+ jo.Remove("source");
+ var value = Activator.CreateInstance(actualType)!;
+ serializer.Populate(jo.CreateReader(), value);
+
+ return value;
+ }
+}
diff --git a/src/Telegram.Bot/Converters/InputFileConverter.cs b/src/Telegram.Bot/Converters/InputFileConverter.cs
index 1ca84c50e..0a30ef462 100644
--- a/src/Telegram.Bot/Converters/InputFileConverter.cs
+++ b/src/Telegram.Bot/Converters/InputFileConverter.cs
@@ -32,7 +32,7 @@ public override void WriteJson(JsonWriter writer, InputFile? value, JsonSerializ
}
return Uri.TryCreate(value, UriKind.Absolute, out var url)
- ? new InputFileUrl(url)
- : new InputFileId(value);
+ ? InputFile.FromUri(url)
+ : InputFile.FromFileId(value);
}
}
diff --git a/src/Telegram.Bot/Converters/MaybeInaccessibleMessageConverter.cs b/src/Telegram.Bot/Converters/MaybeInaccessibleMessageConverter.cs
new file mode 100644
index 000000000..26508e1be
--- /dev/null
+++ b/src/Telegram.Bot/Converters/MaybeInaccessibleMessageConverter.cs
@@ -0,0 +1,54 @@
+using System.Reflection;
+using Newtonsoft.Json.Linq;
+
+namespace Telegram.Bot.Converters;
+
+internal class MaybeInaccessibleMessageConverter : JsonConverter
+{
+ static readonly TypeInfo BaseType = typeof(MaybeInaccessibleMessage).GetTypeInfo();
+
+ public override bool CanWrite => false;
+ public override bool CanRead => true;
+ public override bool CanConvert(Type objectType) =>
+ BaseType.IsAssignableFrom(objectType.GetTypeInfo());
+
+ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
+ {
+ if (value is null)
+ {
+ writer.WriteNull();
+ }
+ else
+ {
+ var jo = JObject.FromObject(value);
+ jo.WriteTo(writer);
+ }
+ }
+
+ public override object? ReadJson(
+ JsonReader reader,
+ Type objectType,
+ object? existingValue,
+ JsonSerializer serializer)
+ {
+ var jo = JObject.Load(reader);
+ var date = jo["date"]?.Value();
+
+ if (date is null)
+ {
+ return null;
+ }
+
+ var actualType = date switch
+ {
+ 0 => typeof(InaccessibleMessage),
+ _ => typeof(Message),
+ };
+
+ // Remove status because status property only has getter
+ var value = Activator.CreateInstance(actualType)!;
+ serializer.Populate(jo.CreateReader(), value);
+
+ return value;
+ }
+}
diff --git a/src/Telegram.Bot/Converters/MessageOriginConverter.cs b/src/Telegram.Bot/Converters/MessageOriginConverter.cs
new file mode 100644
index 000000000..11b7e8439
--- /dev/null
+++ b/src/Telegram.Bot/Converters/MessageOriginConverter.cs
@@ -0,0 +1,59 @@
+using System.Reflection;
+using Newtonsoft.Json.Linq;
+using Telegram.Bot.Types.Enums;
+
+namespace Telegram.Bot.Converters;
+
+internal class MessageOriginConverter : JsonConverter
+{
+ static readonly TypeInfo BaseType = typeof(MessageOrigin).GetTypeInfo();
+
+ public override bool CanWrite => false;
+ public override bool CanRead => true;
+ public override bool CanConvert(Type objectType) =>
+ BaseType.IsAssignableFrom(objectType.GetTypeInfo());
+
+ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
+ {
+ if (value is null)
+ {
+ writer.WriteNull();
+ }
+ else
+ {
+ var jo = JObject.FromObject(value);
+ jo.WriteTo(writer);
+ }
+ }
+
+ public override object? ReadJson(
+ JsonReader reader,
+ Type objectType,
+ object? existingValue,
+ JsonSerializer serializer)
+ {
+ var jo = JObject.Load(reader);
+ var type = jo["type"]?.ToObject();
+
+ if (type is null)
+ {
+ return null;
+ }
+
+ var actualType = type switch
+ {
+ MessageOriginType.User => typeof(MessageOriginUser),
+ MessageOriginType.HiddenUser => typeof(MessageOriginHiddenUser),
+ MessageOriginType.Chat => typeof(MessageOriginChat),
+ MessageOriginType.Channel => typeof(MessageOriginChannel),
+ _ => throw new JsonSerializationException($"Unknown message origin type value of '{jo["type"]}'")
+ };
+
+ // Remove status because status property only has getter
+ jo.Remove("type");
+ var value = Activator.CreateInstance(actualType)!;
+ serializer.Populate(jo.CreateReader(), value);
+
+ return value;
+ }
+}
diff --git a/src/Telegram.Bot/Converters/ReactionTypeConverter.cs b/src/Telegram.Bot/Converters/ReactionTypeConverter.cs
new file mode 100644
index 000000000..382f7281b
--- /dev/null
+++ b/src/Telegram.Bot/Converters/ReactionTypeConverter.cs
@@ -0,0 +1,56 @@
+using System.Reflection;
+using Newtonsoft.Json.Linq;
+
+namespace Telegram.Bot.Converters;
+
+internal class ReactionTypeConverter : JsonConverter
+{
+ static readonly TypeInfo BaseType = typeof(ReactionType).GetTypeInfo();
+
+ public override bool CanWrite => false;
+ public override bool CanRead => true;
+ public override bool CanConvert(Type objectType) =>
+ BaseType.IsAssignableFrom(objectType.GetTypeInfo());
+
+ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
+ {
+ if (value is null)
+ {
+ writer.WriteNull();
+ }
+ else
+ {
+ var jo = JObject.FromObject(value);
+ jo.WriteTo(writer);
+ }
+ }
+
+ public override object? ReadJson(
+ JsonReader reader,
+ Type objectType,
+ object? existingValue,
+ JsonSerializer serializer)
+ {
+ var jo = JObject.Load(reader);
+ var type = jo["type"]?.Value();
+
+ if (type is null)
+ {
+ return null;
+ }
+
+ var actualType = type switch
+ {
+ "emoji" => typeof(ReactionTypeEmoji),
+ "custom_emoji" => typeof(ReactionTypeCustomEmoji),
+ _ => throw new JsonSerializationException($"Unknown reaction type value of '{jo["type"]}'")
+ };
+
+ // Remove status because status property only has getter
+ jo.Remove("type");
+ var value = Activator.CreateInstance(actualType)!;
+ serializer.Populate(jo.CreateReader(), value);
+
+ return value;
+ }
+}
diff --git a/src/Telegram.Bot/Requests/Abstractions/Documentation.cs b/src/Telegram.Bot/Requests/Abstractions/Documentation.cs
index 3202bd265..f353e976f 100644
--- a/src/Telegram.Bot/Requests/Abstractions/Documentation.cs
+++ b/src/Telegram.Bot/Requests/Abstractions/Documentation.cs
@@ -1,6 +1,6 @@
#nullable disable
#pragma warning disable 169
-#pragma warning disable CA1823
+#pragma warning disable IDE0051
using Telegram.Bot.Types.ReplyMarkups;
@@ -57,14 +57,9 @@ internal static class Documentation
static readonly object DisableNotification;
///
- /// If the message is a reply, ID of the original message
+ /// Description of the message to reply to
///
- static readonly object ReplyToMessageId;
-
- ///
- /// Pass , if the message should be sent even if the specified replied-to message is not found
- ///
- static readonly object AllowSendingWithoutReply;
+ static readonly object ReplyParameters;
///
/// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported
diff --git a/src/Telegram.Bot/Requests/Available methods/AnswerCallbackQueryRequest.cs b/src/Telegram.Bot/Requests/Available methods/AnswerCallbackQueryRequest.cs
index ea52aee09..ed41d35f0 100644
--- a/src/Telegram.Bot/Requests/Available methods/AnswerCallbackQueryRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/AnswerCallbackQueryRequest.cs
@@ -1,3 +1,5 @@
+using System.Diagnostics.CodeAnalysis;
+
// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
@@ -19,7 +21,7 @@ public class AnswerCallbackQueryRequest : RequestBase
/// Unique identifier for the query to be answered
///
[JsonProperty(Required = Required.Always)]
- public string CallbackQueryId { get; }
+ public required string CallbackQueryId { get; init; }
///
/// Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
@@ -54,12 +56,19 @@ public class AnswerCallbackQueryRequest : RequestBase
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public int? CacheTime { get; set; }
+ ///
+ /// Initializes a new request with callbackQueryId
+ ///
+ public AnswerCallbackQueryRequest() : base("answerCallbackQuery") { }
+
///
/// Initializes a new request with callbackQueryId
///
/// Unique identifier for the query to be answered
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public AnswerCallbackQueryRequest(string callbackQueryId)
- : base("answerCallbackQuery")
+ : this()
{
CallbackQueryId = callbackQueryId;
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Commands/SetMyCommandsRequest.cs b/src/Telegram.Bot/Requests/Available methods/Commands/SetMyCommandsRequest.cs
index 49afa7909..ac5051f9b 100644
--- a/src/Telegram.Bot/Requests/Available methods/Commands/SetMyCommandsRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Commands/SetMyCommandsRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
@@ -16,7 +17,7 @@ public class SetMyCommandsRequest : RequestBase
/// At most 100 commands can be specified.
///
[JsonProperty(Required = Required.Always)]
- public IEnumerable Commands { get; }
+ public required IEnumerable Commands { get; init; }
///
/// An object, describing scope of users for which the commands are relevant.
@@ -36,9 +37,18 @@ public class SetMyCommandsRequest : RequestBase
/// Initializes a new request with commands
///
/// A list of bot commands to be set
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetMyCommandsRequest(IEnumerable commands)
- : base("setMyCommands")
+ : this()
{
Commands = commands;
}
+
+ ///
+ /// Initializes a new request with commands
+ ///
+ public SetMyCommandsRequest()
+ : base("setMyCommands")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Get Files/GetFileRequest.cs b/src/Telegram.Bot/Requests/Available methods/Get Files/GetFileRequest.cs
index 6c189f65e..c062fd337 100644
--- a/src/Telegram.Bot/Requests/Available methods/Get Files/GetFileRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Get Files/GetFileRequest.cs
@@ -1,4 +1,7 @@
// ReSharper disable once CheckNamespace
+
+using System.Diagnostics.CodeAnalysis;
+
namespace Telegram.Bot.Requests;
///
@@ -21,15 +24,24 @@ public class GetFileRequest : RequestBase
/// File identifier to get info about
///
[JsonProperty(Required = Required.Always)]
- public string FileId { get; }
+ public required string FileId { get; init; }
///
/// Initializes a new request with
///
/// File identifier to get info about
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public GetFileRequest(string fileId)
- : base("getFile")
+ : this()
{
FileId = fileId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public GetFileRequest()
+ : base("getFile")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Get Files/GetUserProfilePhotosRequest.cs b/src/Telegram.Bot/Requests/Available methods/Get Files/GetUserProfilePhotosRequest.cs
index 1c5efc2e6..b4591778b 100644
--- a/src/Telegram.Bot/Requests/Available methods/Get Files/GetUserProfilePhotosRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Get Files/GetUserProfilePhotosRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -12,7 +13,7 @@ public class GetUserProfilePhotosRequest : RequestBase, IUser
{
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// Sequential number of the first photo to be returned. By default, all photos are returned
@@ -30,9 +31,18 @@ public class GetUserProfilePhotosRequest : RequestBase, IUser
/// Initializes a new request with userId
///
/// Unique identifier of the target user
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public GetUserProfilePhotosRequest(long userId)
- : base("getUserProfilePhotos")
+ : this()
{
UserId = userId;
}
+
+ ///
+ /// Initializes a new request with userId
+ ///
+ public GetUserProfilePhotosRequest()
+ : base("getUserProfilePhotos")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/GetMyDefaultAdministratorRightsRequest.cs b/src/Telegram.Bot/Requests/Available methods/GetMyDefaultAdministratorRightsRequest.cs
index fde9f8d90..85d99e7c3 100644
--- a/src/Telegram.Bot/Requests/Available methods/GetMyDefaultAdministratorRightsRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/GetMyDefaultAdministratorRightsRequest.cs
@@ -1,4 +1,7 @@
// ReSharper disable once CheckNamespace
+
+using System.Diagnostics.CodeAnalysis;
+
namespace Telegram.Bot.Requests;
///
diff --git a/src/Telegram.Bot/Requests/Available methods/GetUserChatBoostsRequest.cs b/src/Telegram.Bot/Requests/Available methods/GetUserChatBoostsRequest.cs
new file mode 100644
index 000000000..62dce8505
--- /dev/null
+++ b/src/Telegram.Bot/Requests/Available methods/GetUserChatBoostsRequest.cs
@@ -0,0 +1,48 @@
+using System.Diagnostics.CodeAnalysis;
+
+// ReSharper disable once CheckNamespace
+namespace Telegram.Bot.Requests;
+
+///
+/// Use this method to get the list of boosts added to a chat by a user.
+/// Requires administrator rights in the chat.
+/// Returns a object.
+///
+[JsonObject(MemberSerialization.OptIn, NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
+public class GetUserChatBoostsRequest : RequestBase
+{
+ ///
+ /// Unique identifier for the chat or username of the channel (in the format @channelusername)
+ ///
+ [JsonProperty(Required = Required.Always)]
+ public required ChatId ChatId { get; init; }
+
+ ///
+ /// Unique identifier of the target user
+ ///
+ [JsonProperty(Required = Required.Always)]
+ public required long UserId { get; init; }
+
+ ///
+ /// Initializes a new request
+ ///
+ public GetUserChatBoostsRequest()
+ : base("getUserChatBoosts")
+ { }
+
+ ///
+ /// Initializes a new request with chatId and userId
+ ///
+ ///
+ /// Unique identifier for the chat or username of the channel (in the format @channelusername)
+ ///
+ /// Unique identifier of the target user
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
+ public GetUserChatBoostsRequest(ChatId chatId, long userId)
+ : this()
+ {
+ ChatId = chatId;
+ UserId = userId;
+ }
+}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/BanChatMemberRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/BanChatMemberRequest.cs
index e8d3a84f8..88ee3ec09 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/BanChatMemberRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/BanChatMemberRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json.Converters;
using Telegram.Bot.Requests.Abstractions;
@@ -16,11 +17,11 @@ public class BanChatMemberRequest : RequestBase, IChatTargetable, IUserTar
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// Date when the user will be unbanned. If user is banned for more than 366 days or less
@@ -46,10 +47,19 @@ public class BanChatMemberRequest : RequestBase, IChatTargetable, IUserTar
/// (in the format @channelusername)
///
/// Unique identifier of the target user
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public BanChatMemberRequest(ChatId chatId, long userId)
- : base("banChatMember")
+ : this()
{
ChatId = chatId;
UserId = userId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public BanChatMemberRequest()
+ : base("banChatMember")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/BanChatSenderChatRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/BanChatSenderChatRequest.cs
index 2f11e85fa..67cc0c9da 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/BanChatSenderChatRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/BanChatSenderChatRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json.Converters;
using Telegram.Bot.Requests.Abstractions;
@@ -15,13 +16,13 @@ public class BanChatSenderChatRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier of the target sender chat
///
[JsonProperty(Required = Required.Always)]
- public long SenderChatId { get; }
+ public required long SenderChatId { get; init; }
///
/// Date when the sender chat will be unbanned, unix time. If the chat is banned for more than 366 days or
@@ -40,10 +41,19 @@ public class BanChatSenderChatRequest : RequestBase, IChatTargetable
///
/// Unique identifier of the target sender chat
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public BanChatSenderChatRequest(ChatId chatId, long senderChatId)
- : base("banChatSenderChat")
+ : this()
{
ChatId = chatId;
SenderChatId = senderChatId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public BanChatSenderChatRequest()
+ : base("banChatSenderChat")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/ApproveChatJoinRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/ApproveChatJoinRequest.cs
index f27f1ae6f..a061a24a8 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/ApproveChatJoinRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/ApproveChatJoinRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,13 +14,13 @@ public class ApproveChatJoinRequest : RequestBase, IChatTargetable, IUserT
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier of the target user
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// Initializes a new request with chatId and userId
@@ -28,10 +29,19 @@ public class ApproveChatJoinRequest : RequestBase, IChatTargetable, IUserT
/// (in the format @channelusername)
///
/// Unique identifier of the target user
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public ApproveChatJoinRequest(ChatId chatId, long userId)
- : base("approveChatJoinRequest")
+ : this()
{
ChatId = chatId;
UserId = userId;
}
+
+ ///
+ /// Initializes a new request with chatId and userId
+ ///
+ public ApproveChatJoinRequest()
+ : base("approveChatJoinRequest")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/CreateChatInviteLinkRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/CreateChatInviteLinkRequest.cs
index 39364bb9f..9babf9bb3 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/CreateChatInviteLinkRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/CreateChatInviteLinkRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json.Converters;
using Telegram.Bot.Requests.Abstractions;
@@ -15,7 +16,7 @@ public class CreateChatInviteLinkRequest : RequestBase, IChatTar
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Invite link name; 0-32 characters
@@ -50,9 +51,18 @@ public class CreateChatInviteLinkRequest : RequestBase, IChatTar
/// Unique identifier for the target chat or username of the target channel
/// (in the format @channelusername)
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public CreateChatInviteLinkRequest(ChatId chatId)
- : base("createChatInviteLink")
+ : this()
{
ChatId = chatId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public CreateChatInviteLinkRequest()
+ : base("createChatInviteLink")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/DeclineChatJoinRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/DeclineChatJoinRequest.cs
index fd62dabf5..05d848040 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/DeclineChatJoinRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/DeclineChatJoinRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,13 +14,13 @@ public class DeclineChatJoinRequest : RequestBase, IChatTargetable, IUserT
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier of the target user
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// Initializes a new request with chatId and userId
@@ -28,10 +29,19 @@ public class DeclineChatJoinRequest : RequestBase, IChatTargetable, IUserT
/// (in the format @channelusername)
///
/// Unique identifier of the target user
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public DeclineChatJoinRequest(ChatId chatId, long userId)
- : base("declineChatJoinRequest")
+ : this()
{
ChatId = chatId;
UserId = userId;
}
+
+ ///
+ /// Initializes a new request with chatId and userId
+ ///
+ public DeclineChatJoinRequest()
+ : base("declineChatJoinRequest")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/EditChatInviteLinkRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/EditChatInviteLinkRequest.cs
index 3099e3e01..54cba67fc 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/EditChatInviteLinkRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/EditChatInviteLinkRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json.Converters;
using Telegram.Bot.Requests.Abstractions;
@@ -14,13 +15,13 @@ public class EditChatInviteLinkRequest : RequestBase, IChatTarge
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// The invite link to edit
///
[JsonProperty(Required = Required.Always)]
- public string InviteLink { get; }
+ public required string InviteLink { get; init; }
///
/// Invite link name; 0-32 characters
@@ -56,10 +57,19 @@ public class EditChatInviteLinkRequest : RequestBase, IChatTarge
/// (in the format @channelusername)
///
/// The invite link to edit
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public EditChatInviteLinkRequest(ChatId chatId, string inviteLink)
- : base("editChatInviteLink")
+ : this()
{
ChatId = chatId;
InviteLink = inviteLink;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public EditChatInviteLinkRequest()
+ : base("editChatInviteLink")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/ExportChatInviteLinkRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/ExportChatInviteLinkRequest.cs
index 4254342b6..ff7881197 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/ExportChatInviteLinkRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/ExportChatInviteLinkRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,7 +14,7 @@ public class ExportChatInviteLinkRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Initializes a new request with chatId
@@ -21,9 +22,18 @@ public class ExportChatInviteLinkRequest : RequestBase, IChatTargetable
/// Unique identifier for the target chat or username of the target channel
/// (in the format @channelusername)
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public ExportChatInviteLinkRequest(ChatId chatId)
- : base("exportChatInviteLink")
+ : this()
{
ChatId = chatId;
}
+
+ ///
+ /// Initializes a new request with chatId
+ ///
+ public ExportChatInviteLinkRequest()
+ : base("exportChatInviteLink")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/RevokeChatInviteLinkRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/RevokeChatInviteLinkRequest.cs
index 945db9dec..5d1fe0222 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/RevokeChatInviteLinkRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Chat Invite Link/RevokeChatInviteLinkRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -14,13 +15,13 @@ public class RevokeChatInviteLinkRequest : RequestBase, IChatTar
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// The invite link to revoke
///
[JsonProperty(Required = Required.Always)]
- public string InviteLink { get; }
+ public required string InviteLink { get; init; }
///
/// Initializes a new request with chatId and inviteLink
@@ -29,10 +30,19 @@ public class RevokeChatInviteLinkRequest : RequestBase, IChatTar
/// (in the format @channelusername)
///
/// The invite link to revoke
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public RevokeChatInviteLinkRequest(ChatId chatId, string inviteLink)
- : base("revokeChatInviteLink")
+ : this()
{
ChatId = chatId;
InviteLink = inviteLink;
}
+
+ ///
+ /// Initializes a new request with chatId and inviteLink
+ ///
+ public RevokeChatInviteLinkRequest()
+ : base("revokeChatInviteLink")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/CloseForumTopicRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/CloseForumTopicRequest.cs
index cca6ffebe..0a147a893 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/CloseForumTopicRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/CloseForumTopicRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,23 +14,32 @@ public class CloseForumTopicRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread of the forum topic
///
[JsonProperty(Required = Required.Always)]
- public int MessageThreadId { get; }
+ public required int MessageThreadId { get; init; }
///
/// Initializes a new request
///
/// Unique identifier for the target chat or username of the target supergroup
/// Unique identifier for the target message thread of the forum topic
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public CloseForumTopicRequest(ChatId chatId, int messageThreadId)
- : base("closeForumTopic")
+ : this()
{
ChatId = chatId;
MessageThreadId = messageThreadId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public CloseForumTopicRequest()
+ : base("closeForumTopic")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/CloseGeneralForumTopicRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/CloseGeneralForumTopicRequest.cs
index 2f7998df9..87c6825ef 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/CloseGeneralForumTopicRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/CloseGeneralForumTopicRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,12 +14,21 @@ public class CloseGeneralForumTopicRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Initializes a new request
///
/// Unique identifier for the target chat or username of the target supergroup
- public CloseGeneralForumTopicRequest(ChatId chatId)
- : base("closeGeneralForumTopic") => ChatId = chatId;
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
+ public CloseGeneralForumTopicRequest(ChatId chatId) : this()
+ => ChatId = chatId;
+
+ ///
+ /// Initializes a new request
+ ///
+ public CloseGeneralForumTopicRequest()
+ : base("closeGeneralForumTopic")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/CreateForumTopicRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/CreateForumTopicRequest.cs
index c73ddd196..5fd3dd2fd 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/CreateForumTopicRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/CreateForumTopicRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Converters;
using Telegram.Bot.Requests.Abstractions;
@@ -14,13 +15,13 @@ public class CreateForumTopicRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Topic name, 1-128 characters
///
[JsonProperty(Required = Required.Always)]
- public string Name { get; }
+ public required string Name { get; init; }
///
/// Optional. Color of the topic icon in RGB format. Currently, must be one of 0x6FB9F0, 0xFFD67E, 0xCB86DB,
@@ -41,10 +42,19 @@ public class CreateForumTopicRequest : RequestBase, IChatTargetable
///
/// Unique identifier for the target chat or username of the target supergroup
/// Topic name
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public CreateForumTopicRequest(ChatId chatId, string name)
- : base("createForumTopic")
+ : this()
{
ChatId = chatId;
Name = name;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public CreateForumTopicRequest()
+ : base("createForumTopic")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/DeleteChatPhotoRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/DeleteChatPhotoRequest.cs
index 4881e90de..2a8325685 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/DeleteChatPhotoRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/DeleteChatPhotoRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,7 +14,7 @@ public class DeleteChatPhotoRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Initializes a new request with chatId
@@ -21,9 +22,18 @@ public class DeleteChatPhotoRequest : RequestBase, IChatTargetable
/// Unique identifier for the target chat or username of the target channel
/// (in the format @channelusername)
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public DeleteChatPhotoRequest(ChatId chatId)
- : base("deleteChatPhoto")
+ : this()
{
ChatId = chatId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public DeleteChatPhotoRequest()
+ : base("deleteChatPhoto")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/DeleteChatStickerSetRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/DeleteChatStickerSetRequest.cs
index de3cca835..ab028e5d5 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/DeleteChatStickerSetRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/DeleteChatStickerSetRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -14,7 +15,7 @@ public class DeleteChatStickerSetRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Initializes a new request with chatId
@@ -22,9 +23,18 @@ public class DeleteChatStickerSetRequest : RequestBase, IChatTargetable
/// Unique identifier for the target chat or username of the target channel
/// (in the format @channelusername)
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public DeleteChatStickerSetRequest(ChatId chatId)
- : base("deleteChatStickerSet")
+ : this()
{
ChatId = chatId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public DeleteChatStickerSetRequest()
+ : base("deleteChatStickerSet")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/DeleteForumTopicRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/DeleteForumTopicRequest.cs
index 644b7cec6..4cb60a1b7 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/DeleteForumTopicRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/DeleteForumTopicRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,23 +14,32 @@ public class DeleteForumTopicRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread of the forum topic
///
[JsonProperty(Required = Required.Always)]
- public int MessageThreadId { get; }
+ public required int MessageThreadId { get; init; }
///
/// Initializes a new request
///
/// Unique identifier for the target chat or username of the target supergroup
/// Unique identifier for the target message thread of the forum topic
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public DeleteForumTopicRequest(ChatId chatId, int messageThreadId)
- : base("deleteForumTopic")
+ : this()
{
ChatId = chatId;
MessageThreadId = messageThreadId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public DeleteForumTopicRequest()
+ : base("deleteForumTopic")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/EditForumTopicRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/EditForumTopicRequest.cs
index a267bc979..b02c2f0a0 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/EditForumTopicRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/EditForumTopicRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,13 +14,13 @@ public class EditForumTopicRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread of the forum topic
///
[JsonProperty(Required = Required.Always)]
- public int MessageThreadId { get; }
+ public required int MessageThreadId { get; init; }
///
/// New topic name, 0-128 characters. If not specififed or empty, the current name of the topic will be kept
@@ -40,7 +41,16 @@ public class EditForumTopicRequest : RequestBase, IChatTargetable
///
/// Unique identifier for the target chat or username of the target supergroup
/// Unique identifier for the target message thread of the forum topic
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public EditForumTopicRequest(ChatId chatId, int messageThreadId)
- : base("editForumTopic") =>
- (ChatId, MessageThreadId) = (chatId, messageThreadId);
+ : this()
+ => (ChatId, MessageThreadId) = (chatId, messageThreadId);
+
+ ///
+ /// Initializes a new request
+ ///
+ public EditForumTopicRequest()
+ : base("editForumTopic")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/EditGeneralForumTopicRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/EditGeneralForumTopicRequest.cs
index eb5a76bfd..8844d0a9e 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/EditGeneralForumTopicRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/EditGeneralForumTopicRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,19 +14,28 @@ public class EditGeneralForumTopicRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// New topic name, 1-128 characters
///
[JsonProperty(Required = Required.Always)]
- public string Name { get; }
+ public required string Name { get; init; }
///
/// Initializes a new request
///
/// Unique identifier for the target chat or username of the target supergroup
/// New topic name, 1-128 characters
- public EditGeneralForumTopicRequest(ChatId chatId, string name)
- : base("editGeneralForumTopic") => (ChatId, Name) = (chatId, name);
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
+ public EditGeneralForumTopicRequest(ChatId chatId, string name) : this()
+ => (ChatId, Name) = (chatId, name);
+
+ ///
+ /// Initializes a new request
+ ///
+ public EditGeneralForumTopicRequest()
+ : base("editGeneralForumTopic")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatAdministratorsRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatAdministratorsRequest.cs
index 221803d8e..16d2bb42d 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatAdministratorsRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatAdministratorsRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -14,7 +15,7 @@ public class GetChatAdministratorsRequest : RequestBase, IChatTarg
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Initializes a new request with chatId
@@ -23,9 +24,18 @@ public class GetChatAdministratorsRequest : RequestBase, IChatTarg
/// Unique identifier for the target chat or username of the target supergroup or channel
/// (in the format @channelusername)
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public GetChatAdministratorsRequest(ChatId chatId)
- : base("getChatAdministrators")
+ : this()
{
ChatId = chatId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public GetChatAdministratorsRequest()
+ : base("getChatAdministrators")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatMemberCountRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatMemberCountRequest.cs
index 61fded3b8..de4320675 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatMemberCountRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatMemberCountRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -11,7 +12,7 @@ public class GetChatMemberCountRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Initializes a new request with chatId
@@ -20,9 +21,18 @@ public class GetChatMemberCountRequest : RequestBase, IChatTargetable
/// Unique identifier for the target chat or username of the target supergroup or channel
/// (in the format @channelusername)
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public GetChatMemberCountRequest(ChatId chatId)
- : base("getChatMemberCount")
+ : this()
{
ChatId = chatId;
}
+
+ ///
+ /// Initializes a new request with chatId
+ ///
+ public GetChatMemberCountRequest()
+ : base("getChatMemberCount")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatMemberRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatMemberRequest.cs
index 0a6197f94..f4bdd3672 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatMemberRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatMemberRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -12,11 +13,11 @@ public class GetChatMemberRequest : RequestBase, IChatTargetable, IU
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// Initializes a new request with chatId and userId
@@ -26,10 +27,19 @@ public class GetChatMemberRequest : RequestBase, IChatTargetable, IU
/// (in the format @channelusername)
///
/// Unique identifier of the target user
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public GetChatMemberRequest(ChatId chatId, long userId)
- : base("getChatMember")
+ : this()
{
ChatId = chatId;
UserId = userId;
}
+
+ ///
+ /// Initializes a new request with chatId and userId
+ ///
+ public GetChatMemberRequest()
+ : base("getChatMember")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatRequest.cs
index fb610defd..3b625d32d 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/Get Chat/GetChatRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Converters;
using Telegram.Bot.Requests.Abstractions;
@@ -15,7 +16,7 @@ public class GetChatRequest : RequestBase, IChatTargetable
///
[JsonProperty(Required = Required.Always)]
[JsonConverter(typeof(ChatIdConverter))]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Initializes a new request with chatId
@@ -24,9 +25,18 @@ public class GetChatRequest : RequestBase, IChatTargetable
/// Unique identifier for the target chat or username of the target supergroup or channel
/// (in the format @channelusername)
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public GetChatRequest(ChatId chatId)
- : base("getChat")
+ : this()
{
ChatId = chatId;
}
+
+ ///
+ /// Initializes a new request with chatId
+ ///
+ public GetChatRequest()
+ : base("getChat")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/HideGeneralForumTopicRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/HideGeneralForumTopicRequest.cs
index 4149de12b..bc951440e 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/HideGeneralForumTopicRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/HideGeneralForumTopicRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,12 +14,21 @@ public class HideGeneralForumTopicRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Initializes a new request
///
/// Unique identifier for the target chat or username of the target supergroup
- public HideGeneralForumTopicRequest(ChatId chatId)
- : base("hideGeneralForumTopic") => ChatId = chatId;
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
+ public HideGeneralForumTopicRequest(ChatId chatId) : this()
+ => ChatId = chatId;
+
+ ///
+ /// Initializes a new request
+ ///
+ public HideGeneralForumTopicRequest()
+ : base("hideGeneralForumTopic")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/LeaveChatRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/LeaveChatRequest.cs
index 5b947c684..f2c520df4 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/LeaveChatRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/LeaveChatRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -11,7 +12,7 @@ public class LeaveChatRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Initializes a new request with chatId
@@ -20,9 +21,18 @@ public class LeaveChatRequest : RequestBase, IChatTargetable
/// Unique identifier for the target chat or username of the target supergroup or channel
/// (in the format @channelusername)
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public LeaveChatRequest(ChatId chatId)
- : base("leaveChat")
+ : this()
{
ChatId = chatId;
}
+
+ ///
+ /// Initializes a new request with chatId
+ ///
+ public LeaveChatRequest()
+ : base("leaveChat")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/PinChatMessageRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/PinChatMessageRequest.cs
index 73dc8ba13..671039a7a 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/PinChatMessageRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/PinChatMessageRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -15,13 +16,13 @@ public class PinChatMessageRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Identifier of a message to pin
///
[JsonProperty(Required = Required.Always)]
- public int MessageId { get; }
+ public required int MessageId { get; init; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -34,10 +35,19 @@ public class PinChatMessageRequest : RequestBase, IChatTargetable
/// (in the format @channelusername)
///
/// Identifier of a message to pin
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public PinChatMessageRequest(ChatId chatId, int messageId)
- : base("pinChatMessage")
+ : this()
{
ChatId = chatId;
MessageId = messageId;
}
+
+ ///
+ /// Initializes a new request with chatId and messageId
+ ///
+ public PinChatMessageRequest()
+ : base("pinChatMessage")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/PromoteChatMemberRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/PromoteChatMemberRequest.cs
index d13245ac1..74b26a91a 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/PromoteChatMemberRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/PromoteChatMemberRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,11 +14,11 @@ public class PromoteChatMemberRequest : RequestBase, IChatTargetable, IUse
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// Pass , if the administrator's presence in the chat is hidden
@@ -121,10 +122,19 @@ public class PromoteChatMemberRequest : RequestBase, IChatTargetable, IUse
/// (in the format @channelusername)
///
/// Unique identifier of the target user
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public PromoteChatMemberRequest(ChatId chatId, long userId)
- : base("promoteChatMember")
+ : this()
{
ChatId = chatId;
UserId = userId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public PromoteChatMemberRequest()
+ : base("promoteChatMember")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/ReopenForumTopicRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/ReopenForumTopicRequest.cs
index 52d6fe8eb..5443af88d 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/ReopenForumTopicRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/ReopenForumTopicRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,23 +14,32 @@ public class ReopenForumTopicRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread of the forum topic
///
[JsonProperty(Required = Required.Always)]
- public int MessageThreadId { get; }
+ public required int MessageThreadId { get; init; }
///
/// Initializes a new request
///
/// Unique identifier for the target chat or username of the target supergroup
/// Unique identifier for the target message thread of the forum topic
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public ReopenForumTopicRequest(ChatId chatId, int messageThreadId)
- : base("reopenForumTopic")
+ : this()
{
ChatId = chatId;
MessageThreadId = messageThreadId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public ReopenForumTopicRequest()
+ : base("reopenForumTopic")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/ReopenGeneralForumTopicRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/ReopenGeneralForumTopicRequest.cs
index 6094c28cb..f9280fe66 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/ReopenGeneralForumTopicRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/ReopenGeneralForumTopicRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,12 +14,21 @@ public class ReopenGeneralForumTopicRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Initializes a new request
///
/// Unique identifier for the target chat or username of the target supergroup
- public ReopenGeneralForumTopicRequest(ChatId chatId)
- : base("reopenGeneralForumTopic") => ChatId = chatId;
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
+ public ReopenGeneralForumTopicRequest(ChatId chatId) : this()
+ => ChatId = chatId;
+
+ ///
+ /// Initializes a new request
+ ///
+ public ReopenGeneralForumTopicRequest()
+ : base("reopenGeneralForumTopic")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/RestrictChatMemberRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/RestrictChatMemberRequest.cs
index 5fa83aa97..43e99c6e5 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/RestrictChatMemberRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/RestrictChatMemberRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json.Converters;
using Telegram.Bot.Requests.Abstractions;
@@ -14,17 +15,17 @@ public class RestrictChatMemberRequest : RequestBase, IChatTargetable, IUs
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// New user permissions
///
[JsonProperty(Required = Required.Always)]
- public ChatPermissions Permissions { get; }
+ public required ChatPermissions Permissions { get; init; }
///
/// Pass if chat permissions are set independently. Otherwise, the
@@ -56,11 +57,20 @@ public class RestrictChatMemberRequest : RequestBase, IChatTargetable, IUs
///
/// Unique identifier of the target user
/// New user permissions
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public RestrictChatMemberRequest(ChatId chatId, long userId, ChatPermissions permissions)
- : base("restrictChatMember")
+ : this()
{
ChatId = chatId;
UserId = userId;
Permissions = permissions;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public RestrictChatMemberRequest()
+ : base("restrictChatMember")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatAdministratorCustomTitleRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatAdministratorCustomTitleRequest.cs
index 8688da527..9ed2f9284 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatAdministratorCustomTitleRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatAdministratorCustomTitleRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -12,17 +13,17 @@ public class SetChatAdministratorCustomTitleRequest : RequestBase, IChatTa
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// New custom title for the administrator; 0-16 characters, emoji are not allowed
///
[JsonProperty(Required = Required.Always)]
- public string CustomTitle { get; }
+ public required string CustomTitle { get; init; }
///
/// Initializes a new request with chatId, userId and customTitle
@@ -34,11 +35,20 @@ public class SetChatAdministratorCustomTitleRequest : RequestBase, IChatTa
///
/// New custom title for the administrator; 0-16 characters, emoji are not allowed
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetChatAdministratorCustomTitleRequest(ChatId chatId, long userId, string customTitle)
- : base("setChatAdministratorCustomTitle")
+ : this()
{
ChatId = chatId;
UserId = userId;
CustomTitle = customTitle;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SetChatAdministratorCustomTitleRequest()
+ : base("setChatAdministratorCustomTitle")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatDescriptionRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatDescriptionRequest.cs
index aa49b0d2c..234018482 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatDescriptionRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatDescriptionRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,7 +14,7 @@ public class SetChatDescriptionRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// New chat Description, 0-255 characters
@@ -28,9 +29,18 @@ public class SetChatDescriptionRequest : RequestBase, IChatTargetable
/// Unique identifier for the target chat or username of the target channel
/// (in the format @channelusername)
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetChatDescriptionRequest(ChatId chatId)
- : base("setChatDescription")
+ : this()
{
ChatId = chatId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SetChatDescriptionRequest()
+ : base("setChatDescription")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatPermissionsRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatPermissionsRequest.cs
index 1644dba4f..556fb4307 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatPermissionsRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatPermissionsRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,13 +14,13 @@ public class SetChatPermissionsRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// New default chat permissions
///
[JsonProperty(Required = Required.Always)]
- public ChatPermissions Permissions { get; }
+ public required ChatPermissions Permissions { get; init; }
///
/// Pass if chat permissions are set independently. Otherwise, the
@@ -41,10 +42,19 @@ public class SetChatPermissionsRequest : RequestBase, IChatTargetable
/// (in the format @channelusername)
///
/// New default chat permissions
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetChatPermissionsRequest(ChatId chatId, ChatPermissions permissions)
- : base("setChatPermissions")
+ : this()
{
ChatId = chatId;
Permissions = permissions;
}
+
+ ///
+ /// Initializes a new request with chatId and new default permissions
+ ///
+ public SetChatPermissionsRequest()
+ : base("setChatPermissions")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatPhotoRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatPhotoRequest.cs
index 2f2c08632..44170308e 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatPhotoRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatPhotoRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Requests.Abstractions;
@@ -14,13 +15,13 @@ public class SetChatPhotoRequest : FileRequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// New chat photo, uploaded using multipart/form-data
///
[JsonProperty(Required = Required.Always)]
- public InputFileStream Photo { get; }
+ public required InputFileStream Photo { get; init; }
///
/// Initializes a new request with chatId and photo
@@ -29,13 +30,22 @@ public class SetChatPhotoRequest : FileRequestBase, IChatTargetable
/// (in the format @channelusername)
///
/// New chat photo, uploaded using multipart/form-data
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetChatPhotoRequest(ChatId chatId, InputFileStream photo)
- : base("setChatPhoto")
+ : this()
{
ChatId = chatId;
Photo = photo;
}
+ ///
+ /// Initializes a new request
+ ///
+ public SetChatPhotoRequest()
+ : base("setChatPhoto")
+ { }
+
///
public override HttpContent ToHttpContent()
=> ToMultipartFormDataContent("photo", Photo);
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatStickerSetRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatStickerSetRequest.cs
index 4bb49a721..2c3b9b0cc 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatStickerSetRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatStickerSetRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -14,13 +15,13 @@ public class SetChatStickerSetRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Name of the sticker set to be set as the group sticker set
///
[JsonProperty(Required = Required.Always)]
- public string StickerSetName { get; }
+ public required string StickerSetName { get; init; }
///
/// Initializes a new request with chatId and new stickerSetName
@@ -29,10 +30,19 @@ public class SetChatStickerSetRequest : RequestBase, IChatTargetable
/// (in the format @channelusername)
///
/// Name of the sticker set to be set as the group sticker set
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetChatStickerSetRequest(ChatId chatId, string stickerSetName)
- : base("setChatStickerSet")
+ : this()
{
ChatId = chatId;
StickerSetName = stickerSetName;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SetChatStickerSetRequest()
+ : base("setChatStickerSet")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatTitleRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatTitleRequest.cs
index 70ba0f165..7eeca20d0 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatTitleRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/SetChatTitleRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,13 +14,13 @@ public class SetChatTitleRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// New chat title, 1-255 characters
///
[JsonProperty(Required = Required.Always)]
- public string Title { get; }
+ public required string Title { get; init; }
///
/// Initializes a new request with chatId and title
@@ -28,10 +29,19 @@ public class SetChatTitleRequest : RequestBase, IChatTargetable
/// (in the format @channelusername)
///
/// New chat title, 1-255 characters
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetChatTitleRequest(ChatId chatId, string title)
- : base("setChatTitle")
+ : this()
{
ChatId = chatId;
Title = title;
}
+
+ ///
+ /// Initializes a new request with chatId and title
+ ///
+ public SetChatTitleRequest()
+ : base("setChatTitle")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnbanChatMemberRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnbanChatMemberRequest.cs
index 90e57e117..6bae92753 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnbanChatMemberRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnbanChatMemberRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -16,11 +17,11 @@ public class UnbanChatMemberRequest : RequestBase, IChatTargetable, IUserT
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// Do nothing if the user is not banned
@@ -35,10 +36,19 @@ public class UnbanChatMemberRequest : RequestBase, IChatTargetable, IUserT
/// (in the format @channelusername)
///
/// Unique identifier of the target user
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public UnbanChatMemberRequest(ChatId chatId, long userId)
- : base("unbanChatMember")
+ : this()
{
ChatId = chatId;
UserId = userId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public UnbanChatMemberRequest()
+ : base("unbanChatMember")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnbanChatSenderChatRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnbanChatSenderChatRequest.cs
index b24dada2b..5406a2cba 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnbanChatSenderChatRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnbanChatSenderChatRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,13 +14,13 @@ public class UnbanChatSenderChatRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier of the target sender chat
///
[JsonProperty(Required = Required.Always)]
- public long SenderChatId { get; }
+ public required long SenderChatId { get; init; }
///
/// Initializes a new request with chatId and senderChatId
@@ -30,10 +31,19 @@ public class UnbanChatSenderChatRequest : RequestBase, IChatTargetable
///
/// Unique identifier of the target sender chat
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public UnbanChatSenderChatRequest(ChatId chatId, long senderChatId)
- : base("unbanChatSenderChat")
+ : this()
{
ChatId = chatId;
SenderChatId = senderChatId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public UnbanChatSenderChatRequest()
+ : base("unbanChatSenderChat")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnhideGeneralForumTopicRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnhideGeneralForumTopicRequest.cs
index 6a60c4cba..52cfbb097 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnhideGeneralForumTopicRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnhideGeneralForumTopicRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,12 +14,22 @@ public class UnhideGeneralForumTopicRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Initializes a new request
///
/// Unique identifier for the target chat or username of the target supergroup
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public UnhideGeneralForumTopicRequest(ChatId chatId)
- : base("unhideGeneralForumTopic") => ChatId = chatId;
+ : this()
+ => ChatId = chatId;
+
+ ///
+ /// Initializes a new request
+ ///
+ public UnhideGeneralForumTopicRequest()
+ : base("unhideGeneralForumTopic")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllChatMessagesRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllChatMessagesRequest.cs
index 52874d1f6..80374dfdb 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllChatMessagesRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllChatMessagesRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -15,7 +16,7 @@ public class UnpinAllChatMessagesRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Initializes a new request with chatId
@@ -23,9 +24,18 @@ public class UnpinAllChatMessagesRequest : RequestBase, IChatTargetable
/// Unique identifier for the target chat or username of the target channel
/// (in the format @channelusername)
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public UnpinAllChatMessagesRequest(ChatId chatId)
- : base("unpinAllChatMessages")
+ : this()
{
ChatId = chatId;
}
+
+ ///
+ /// Initializes a new request with chatId
+ ///
+ public UnpinAllChatMessagesRequest()
+ : base("unpinAllChatMessages")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllForumTopicMessagesRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllForumTopicMessagesRequest.cs
index 86e38cf8c..e4de3973a 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllForumTopicMessagesRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllForumTopicMessagesRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -13,23 +14,32 @@ public class UnpinAllForumTopicMessagesRequest : RequestBase, IChatTargeta
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread of the forum topic
///
[JsonProperty(Required = Required.Always)]
- public int MessageThreadId { get; }
+ public required int MessageThreadId { get; init; }
///
/// Initializes a new request
///
/// Unique identifier for the target chat or username of the target supergroup
/// Unique identifier for the target message thread of the forum topic
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public UnpinAllForumTopicMessagesRequest(ChatId chatId, int messageThreadId)
- : base("unpinAllForumTopicMessages")
+ : this()
{
ChatId = chatId;
MessageThreadId = messageThreadId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public UnpinAllForumTopicMessagesRequest()
+ : base("unpinAllForumTopicMessages")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllGeneralForumTopicMessages.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllGeneralForumTopicMessages.cs
index bffb715c5..e95f50681 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllGeneralForumTopicMessages.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllGeneralForumTopicMessages.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -5,23 +6,33 @@ namespace Telegram.Bot.Requests;
///
/// Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in
-/// the chat for this to work and must have the administrator right in the supergroup.
-/// Returns on success.
+/// the chat for this to work and must have the administrator
+/// right in the supergroup. Returns on success.
///
[JsonObject(MemberSerialization.OptIn, NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
+[Obsolete("Use class UnpinAllGeneralForumTopicMessagesRequest")]
public class UnpinAllGeneralForumTopicMessages : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Initializes a new request
///
/// Unique identifier for the target chat or username of the target supergroup
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public UnpinAllGeneralForumTopicMessages(ChatId chatId)
- : base("unpinAllGeneralForumTopicMessages")
+ : this()
{
ChatId = chatId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public UnpinAllGeneralForumTopicMessages()
+ : base("unpinAllGeneralForumTopicMessages")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllGeneralForumTopicMessagesRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllGeneralForumTopicMessagesRequest.cs
new file mode 100644
index 000000000..4bd82407a
--- /dev/null
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinAllGeneralForumTopicMessagesRequest.cs
@@ -0,0 +1,37 @@
+using System.Diagnostics.CodeAnalysis;
+using Telegram.Bot.Requests.Abstractions;
+
+// ReSharper disable once CheckNamespace
+namespace Telegram.Bot.Requests;
+
+///
+/// Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in
+/// the chat for this to work and must have the administrator
+/// right in the supergroup. Returns on success.
+///
+[JsonObject(MemberSerialization.OptIn, NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
+public class UnpinAllGeneralForumTopicMessagesRequest : RequestBase, IChatTargetable
+{
+ ///
+ [JsonProperty(Required = Required.Always)]
+ public required ChatId ChatId { get; init; }
+
+ ///
+ /// Initializes a new request
+ ///
+ /// Unique identifier for the target chat or username of the target supergroup
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
+ public UnpinAllGeneralForumTopicMessagesRequest(ChatId chatId)
+ : this()
+ {
+ ChatId = chatId;
+ }
+
+ ///
+ /// Initializes a new request
+ ///
+ public UnpinAllGeneralForumTopicMessagesRequest()
+ : base("unpinAllGeneralForumTopicMessages")
+ { }
+}
diff --git a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinChatMessageRequest.cs b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinChatMessageRequest.cs
index 53ad93406..663dbbb09 100644
--- a/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinChatMessageRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Manage Chat/UnpinChatMessageRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -15,7 +16,7 @@ public class UnpinChatMessageRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Identifier of a message to unpin. If not specified, the most recent pinned message
@@ -30,9 +31,18 @@ public class UnpinChatMessageRequest : RequestBase, IChatTargetable
/// Unique identifier for the target chat or username of the target channel
/// (in the format @channelusername)
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public UnpinChatMessageRequest(ChatId chatId)
- : base("unpinChatMessage")
+ : this()
{
ChatId = chatId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public UnpinChatMessageRequest()
+ : base("unpinChatMessage")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessageRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessageRequest.cs
index 2712b17f3..85264a70e 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessageRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessageRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
@@ -21,7 +22,7 @@ public class CopyMessageRequest : RequestBase, IChatTargetable
/// (in the format @channelusername)
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
@@ -34,13 +35,13 @@ public class CopyMessageRequest : RequestBase, IChatTargetable
/// (or channel username in the format @channelusername)
///
[JsonProperty(Required = Required.Always)]
- public ChatId FromChatId { get; }
+ public required ChatId FromChatId { get; init; }
///
/// Message identifier in the chat specified in
///
[JsonProperty(Required = Required.Always)]
- public int MessageId { get; }
+ public required int MessageId { get; init; }
///
/// New caption for media, 0-1024 characters after entities parsing.
@@ -65,13 +66,9 @@ public class CopyMessageRequest : RequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -90,11 +87,20 @@ public class CopyMessageRequest : RequestBase, IChatTargetable
///
/// Message identifier in the chat specified in
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public CopyMessageRequest(ChatId chatId, ChatId fromChatId, int messageId)
- : base("copyMessage")
+ : this()
{
ChatId = chatId;
FromChatId = fromChatId;
MessageId = messageId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public CopyMessageRequest()
+ : base("copyMessage")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessagesRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessagesRequest.cs
new file mode 100644
index 000000000..38e2180ee
--- /dev/null
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/CopyMessagesRequest.cs
@@ -0,0 +1,91 @@
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using Telegram.Bot.Requests.Abstractions;
+
+// ReSharper disable once CheckNamespace
+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 , but the copied messages don't have a link
+/// to the original message. Album grouping is kept for copied messages.
+/// On success, an array of of the sent messages is returned.
+///
+[JsonObject(MemberSerialization.OptIn, NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
+public class CopyMessagesRequest : RequestBase, IChatTargetable
+{
+ ///
+ /// Unique identifier for the target chat or username of the target channel
+ /// (in the format @channelusername)
+ ///
+ [JsonProperty(Required = Required.Always)]
+ public required ChatId ChatId { get; init; }
+
+ ///
+ /// Unique identifier for the chat where the original messages were sent
+ /// (or channel username in the format @channelusername)
+ ///
+ [JsonProperty(Required = Required.Always)]
+ public required ChatId FromChatId { get; init; }
+
+ ///
+ /// Identifiers of 1-100 messages in the chat to copy.
+ /// The identifiers must be specified in a strictly increasing order.
+ ///
+ [JsonProperty(Required = Required.Always)]
+ public required IEnumerable MessageIds { get; init; }
+
+ ///
+ /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public int? MessageThreadId { get; set; }
+
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public bool? DisableNotification { get; set; }
+
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public bool? ProtectContent { get; set; }
+
+ ///
+ /// Pass to copy the messages without their captions
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public bool? RemoveCaption { get; set; }
+
+ ///
+ /// Initializes a new request with chatId, fromChatId and messageIds
+ ///
+ /// 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)
+ ///
+ ///
+ /// Identifiers of 1-100 messages in the chat to copy.
+ /// The identifiers must be specified in a strictly increasing order.
+ ///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
+ public CopyMessagesRequest(ChatId chatId, ChatId fromChatId, int[] messageIds)
+ : this()
+ {
+ ChatId = chatId;
+ FromChatId = fromChatId;
+ MessageIds = messageIds;
+ }
+
+ ///
+ /// Initializes a new request
+ ///
+ public CopyMessagesRequest()
+ : base("copyMessages")
+ { }
+}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/ForwardMessageRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/ForwardMessageRequest.cs
index 994b22b41..b3fe4ee2d 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/ForwardMessageRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/ForwardMessageRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -14,26 +15,26 @@ public class ForwardMessageRequest : RequestBase, IChatTargetable
/// (in the format @channelusername)
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
-
- ///
- /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? MessageThreadId { get; set; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the chat where the original message was sent
/// (or channel username in the format @channelusername)
///
[JsonProperty(Required = Required.Always)]
- public ChatId FromChatId { get; }
+ public required ChatId FromChatId { get; init; }
///
/// Message identifier in the chat specified in
///
[JsonProperty(Required = Required.Always)]
- public int MessageId { get; }
+ public required int MessageId { get; init; }
+
+ ///
+ /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public int? MessageThreadId { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -56,11 +57,20 @@ public class ForwardMessageRequest : RequestBase, IChatTargetable
///
/// Message identifier in the chat specified in
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public ForwardMessageRequest(ChatId chatId, ChatId fromChatId, int messageId)
- : base("forwardMessage")
+ : this()
{
ChatId = chatId;
FromChatId = fromChatId;
MessageId = messageId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public ForwardMessageRequest()
+ : base("forwardMessage")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/ForwardMessagesRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/ForwardMessagesRequest.cs
new file mode 100644
index 000000000..74fb120f2
--- /dev/null
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/ForwardMessagesRequest.cs
@@ -0,0 +1,83 @@
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using Telegram.Bot.Requests.Abstractions;
+
+// ReSharper disable once CheckNamespace
+namespace Telegram.Bot.Requests;
+
+///
+/// Use this method to forward multiple messages of any kind. If some of the specified messages can't be found
+/// or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded.
+/// Album grouping is kept for forwarded messages.
+/// On success, an array of of the sent messages is returned.
+///
+[JsonObject(MemberSerialization.OptIn, NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
+public class ForwardMessagesRequest : RequestBase, IChatTargetable
+{
+ ///
+ /// Unique identifier for the target chat or username of the target channel
+ /// (in the format @channelusername)
+ ///
+ [JsonProperty(Required = Required.Always)]
+ public required ChatId ChatId { get; init; }
+
+ ///
+ /// Unique identifier for the chat where the original messages were sent
+ /// (or channel username in the format @channelusername)
+ ///
+ [JsonProperty(Required = Required.Always)]
+ public required ChatId FromChatId { get; init; }
+
+ ///
+ /// Identifiers of 1-100 messages in the chat from_chat_id to forward.
+ /// The identifiers must be specified in a strictly increasing order.
+ ///
+ [JsonProperty(Required = Required.Always)]
+ public required IEnumerable MessageIds { get; init; }
+
+ ///
+ /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public int? MessageThreadId { get; set; }
+
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public bool? DisableNotification { get; set; }
+
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public bool? ProtectContent { get; set; }
+
+ ///
+ /// Initializes a new request with chatId, fromChatId and messageIds
+ ///
+ ///
+ /// 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)
+ ///
+ ///
+ /// Identifiers of 1-100 messages in the chat from_chat_id to forward.
+ /// The identifiers must be specified in a strictly increasing order.
+ ///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
+ public ForwardMessagesRequest(ChatId chatId, ChatId fromChatId, IEnumerable messageIds)
+ : this()
+ {
+ ChatId = chatId;
+ FromChatId = fromChatId;
+ MessageIds = messageIds;
+ }
+
+ ///
+ /// Initializes a new request
+ ///
+ public ForwardMessagesRequest()
+ :base("forwardMessages")
+ { }
+}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/Location/EditInlineMessageLiveLocationRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/Location/EditInlineMessageLiveLocationRequest.cs
index fa8d1247c..147af9a5f 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/Location/EditInlineMessageLiveLocationRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/Location/EditInlineMessageLiveLocationRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Types.ReplyMarkups;
// ReSharper disable once CheckNamespace
@@ -13,19 +14,19 @@ public class EditInlineMessageLiveLocationRequest : RequestBase
{
///
[JsonProperty(Required = Required.Always)]
- public string InlineMessageId { get; }
+ public required string InlineMessageId { get; init; }
///
/// Latitude of new location
///
[JsonProperty(Required = Required.Always)]
- public double Latitude { get; }
+ public required double Latitude { get; init; }
///
/// Longitude of new location
///
[JsonProperty(Required = Required.Always)]
- public double Longitude { get; }
+ public required double Longitude { get; init; }
///
/// The radius of uncertainty for the location, measured in meters; 0-1500
@@ -56,11 +57,20 @@ public class EditInlineMessageLiveLocationRequest : RequestBase
/// Identifier of the inline message
/// Latitude of new location
/// Longitude of new location
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public EditInlineMessageLiveLocationRequest(string inlineMessageId, double latitude, double longitude)
- : base("editMessageLiveLocation")
+ : this()
{
InlineMessageId = inlineMessageId;
Latitude = latitude;
Longitude = longitude;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public EditInlineMessageLiveLocationRequest()
+ : base("editMessageLiveLocation")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/Location/EditMessageLiveLocationRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/Location/EditMessageLiveLocationRequest.cs
index 239653d94..9ad752e96 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/Location/EditMessageLiveLocationRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/Location/EditMessageLiveLocationRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.ReplyMarkups;
@@ -14,25 +15,25 @@ public class EditMessageLiveLocationRequest : RequestBase, IChatTargeta
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Identifier of the message to edit
///
[JsonProperty(Required = Required.Always)]
- public int MessageId { get; }
+ public required int MessageId { get; init; }
///
/// Latitude of new location
///
[JsonProperty(Required = Required.Always)]
- public double Latitude { get; }
+ public required double Latitude { get; init; }
///
/// Longitude of new location
///
[JsonProperty(Required = Required.Always)]
- public double Longitude { get; }
+ public required double Longitude { get; init; }
///
/// The radius of uncertainty for the location, measured in meters; 0-1500
@@ -67,12 +68,21 @@ public class EditMessageLiveLocationRequest : RequestBase, IChatTargeta
/// Identifier of the message to edit
/// Latitude of new location
/// Longitude of new location
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public EditMessageLiveLocationRequest(ChatId chatId, int messageId, double latitude, double longitude)
- : base("editMessageLiveLocation")
+ : this()
{
ChatId = chatId;
MessageId = messageId;
Latitude = latitude;
Longitude = longitude;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public EditMessageLiveLocationRequest()
+ : base("editMessageLiveLocation")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/Location/SendLocationRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/Location/SendLocationRequest.cs
index 60089f584..c0733db4d 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/Location/SendLocationRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/Location/SendLocationRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.ReplyMarkups;
@@ -12,7 +13,7 @@ public class SendLocationRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
@@ -24,13 +25,19 @@ public class SendLocationRequest : RequestBase, IChatTargetable
/// Latitude of the location
///
[JsonProperty(Required = Required.Always)]
- public double Latitude { get; }
+ public required double Latitude { get; init; }
///
/// Longitude of the location
///
[JsonProperty(Required = Required.Always)]
- public double Longitude { get; }
+ public required double Longitude { get; init; }
+
+ ///
+ /// The radius of uncertainty for the location, measured in meters; 0-1500
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public double? HorizontalAccuracy { get; set; }
///
/// Period in seconds for which the location will be updated, should be between 60 and 86400
@@ -62,17 +69,9 @@ public class SendLocationRequest : RequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
- /// If the message is a reply, ID of the original message
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- /// Pass , if the message should be sent even if the specified replied-to message is not found
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -86,11 +85,20 @@ public class SendLocationRequest : RequestBase, IChatTargetable
///
/// Latitude of the location
/// Longitude of the location
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendLocationRequest(ChatId chatId, double latitude, double longitude)
- : base("sendLocation")
+ : this()
{
ChatId = chatId;
Latitude = latitude;
Longitude = longitude;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SendLocationRequest()
+ : base("sendLocation")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/Location/SendVenueRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/Location/SendVenueRequest.cs
index 9b1613cf8..0558c9898 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/Location/SendVenueRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/Location/SendVenueRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.ReplyMarkups;
@@ -12,7 +13,7 @@ public class SendVenueRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
@@ -24,25 +25,25 @@ public class SendVenueRequest : RequestBase, IChatTargetable
/// Latitude of the venue
///
[JsonProperty(Required = Required.Always)]
- public double Latitude { get; }
+ public required double Latitude { get; init; }
///
/// Longitude of the venue
///
[JsonProperty(Required = Required.Always)]
- public double Longitude { get; }
+ public required double Longitude { get; init; }
///
/// Name of the venue
///
[JsonProperty(Required = Required.Always)]
- public string Title { get; }
+ public required string Title { get; init; }
///
/// Address of the venue
///
[JsonProperty(Required = Required.Always)]
- public string Address { get; }
+ public required string Address { get; init; }
///
/// Foursquare identifier of the venue
@@ -78,13 +79,9 @@ public class SendVenueRequest : RequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -100,12 +97,14 @@ public class SendVenueRequest : RequestBase, IChatTargetable
/// Longitude of the venue
/// Name of the venue
/// Address of the venue
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendVenueRequest(
ChatId chatId,
double latitude,
double longitude,
string title,
- string address) : base("sendVenue")
+ string address) : this()
{
ChatId = chatId;
Latitude = latitude;
@@ -113,4 +112,10 @@ public class SendVenueRequest : RequestBase, IChatTargetable
Title = title;
Address = address;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SendVenueRequest() : base("sendVenue")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/Location/StopInlineMessageLiveLocationRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/Location/StopInlineMessageLiveLocationRequest.cs
index cd15c54b9..8e0a1e6ad 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/Location/StopInlineMessageLiveLocationRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/Location/StopInlineMessageLiveLocationRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Types.ReplyMarkups;
// ReSharper disable once CheckNamespace
@@ -12,7 +13,7 @@ public class StopInlineMessageLiveLocationRequest : RequestBase
{
///
[JsonProperty(Required = Required.Always)]
- public string InlineMessageId { get; }
+ public required string InlineMessageId { get; init; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -22,9 +23,18 @@ public class StopInlineMessageLiveLocationRequest : RequestBase
/// Initializes a new request with inlineMessageId
///
/// Identifier of the inline message
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public StopInlineMessageLiveLocationRequest(string inlineMessageId)
- : base("stopMessageLiveLocation")
+ : this()
{
InlineMessageId = inlineMessageId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public StopInlineMessageLiveLocationRequest()
+ : base("stopMessageLiveLocation")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/Location/StopMessageLiveLocationRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/Location/StopMessageLiveLocationRequest.cs
index 2e7420b36..ed60f59f5 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/Location/StopMessageLiveLocationRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/Location/StopMessageLiveLocationRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.ReplyMarkups;
@@ -14,13 +15,13 @@ public class StopMessageLiveLocationRequest : RequestBase, IChatTargeta
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Identifier of the sent message
///
[JsonProperty(Required = Required.Always)]
- public int MessageId { get; }
+ public required int MessageId { get; init; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -33,10 +34,19 @@ public class StopMessageLiveLocationRequest : RequestBase, IChatTargeta
/// (in the format @channelusername)
///
/// Identifier of the sent message
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public StopMessageLiveLocationRequest(ChatId chatId, int messageId)
- : base("stopMessageLiveLocation")
+ : this()
{
ChatId = chatId;
MessageId = messageId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public StopMessageLiveLocationRequest()
+ : base("stopMessageLiveLocation")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/SendAnimationRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/SendAnimationRequest.cs
index 8a926e368..f3c7f81c3 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/SendAnimationRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/SendAnimationRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Extensions;
using Telegram.Bot.Requests.Abstractions;
@@ -18,13 +19,7 @@ public class SendAnimationRequest : FileRequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
-
- ///
- /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? MessageThreadId { get; set; }
+ public required ChatId ChatId { get; init; }
///
/// Animation to send. Pass a as String to send an animation
@@ -32,7 +27,13 @@ public class SendAnimationRequest : FileRequestBase, IChatTargetable
/// to get an animation from the Internet, or upload a new animation using multipart/form-data
///
[JsonProperty(Required = Required.Always)]
- public InputFile Animation { get; }
+ public required InputFile Animation { get; init; }
+
+ ///
+ /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public int? MessageThreadId { get; set; }
///
/// Duration of sent animation in seconds
@@ -85,13 +86,9 @@ public class SendAnimationRequest : FileRequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -108,13 +105,22 @@ public class SendAnimationRequest : FileRequestBase, IChatTargetable
/// 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
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendAnimationRequest(ChatId chatId, InputFile animation)
- : base("sendAnimation")
+ : this()
{
ChatId = chatId;
Animation = animation;
}
+ ///
+ /// Initializes a new request
+ ///
+ public SendAnimationRequest()
+ : base("sendAnimation")
+ { }
+
///
public override HttpContent? ToHttpContent() =>
Animation is InputFileStream || Thumbnail is InputFileStream
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/SendAudioRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/SendAudioRequest.cs
index 61f7e4857..5b4b09536 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/SendAudioRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/SendAudioRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Extensions;
using Telegram.Bot.Requests.Abstractions;
@@ -19,13 +20,7 @@ public class SendAudioRequest : FileRequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
-
- ///
- /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? MessageThreadId { get; set; }
+ public required ChatId ChatId { get; init; }
///
/// Audio file to send. Pass a as String to send an audio
@@ -33,7 +28,13 @@ public class SendAudioRequest : FileRequestBase, IChatTargetable
/// Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data
///
[JsonProperty(Required = Required.Always)]
- public InputFile Audio { get; }
+ public required InputFile Audio { get; init; }
+
+ ///
+ /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public int? MessageThreadId { get; set; }
///
/// Audio caption, 0-1024 characters after entities parsing
@@ -79,13 +80,9 @@ public class SendAudioRequest : FileRequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -102,13 +99,22 @@ public class SendAudioRequest : FileRequestBase, IChatTargetable
/// file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for
/// Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendAudioRequest(ChatId chatId, InputFile audio)
- : base("sendAudio")
+ : this()
{
ChatId = chatId;
Audio = audio;
}
+ ///
+ /// Initializes a new request
+ ///
+ public SendAudioRequest()
+ : base("sendAudio")
+ { }
+
///
public override HttpContent? ToHttpContent() =>
Audio is InputFileStream || Thumbnail is InputFileStream
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/SendChatActionRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/SendChatActionRequest.cs
index 9f10e73c2..ba251bd36 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/SendChatActionRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/SendChatActionRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.Enums;
@@ -25,13 +26,7 @@ public class SendChatActionRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
-
- ///
- /// Unique identifier for the target message thread; supergroups only
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? MessageThreadId { get; set; }
+ public required ChatId ChatId { get; init; }
///
/// Type of action to broadcast. Choose one, depending on what the user is about to receive:
@@ -46,7 +41,13 @@ public class SendChatActionRequest : RequestBase, IChatTargetable
/// video notes
///
[JsonProperty(Required = Required.Always)]
- public ChatAction Action { get; }
+ public required ChatAction Action { get; init; }
+
+ ///
+ /// Unique identifier for the target message thread; supergroups only
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public int? MessageThreadId { get; set; }
///
/// Initializes a new request chatId and action
@@ -57,10 +58,19 @@ public class SendChatActionRequest : RequestBase, IChatTargetable
///
/// Type of action to broadcast. Choose one, depending on what the user is about to receive
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendChatActionRequest(ChatId chatId, ChatAction action)
- : base("sendChatAction")
+ : this()
{
ChatId = chatId;
Action = action;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SendChatActionRequest()
+ : base("sendChatAction")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/SendContactRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/SendContactRequest.cs
index a3f219054..e4835d9b6 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/SendContactRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/SendContactRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.ReplyMarkups;
@@ -12,25 +13,25 @@ public class SendContactRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
-
- ///
- /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? MessageThreadId { get; set; }
+ public required ChatId ChatId { get; init; }
///
/// Contact's phone number
///
[JsonProperty(Required = Required.Always)]
- public string PhoneNumber { get; }
+ public required string PhoneNumber { get; init; }
///
/// Contact's first name
///
[JsonProperty(Required = Required.Always)]
- public string FirstName { get; }
+ public required string FirstName { get; init; }
+
+ ///
+ /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public int? MessageThreadId { get; set; }
///
/// Contact's last name
@@ -52,13 +53,9 @@ public class SendContactRequest : RequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -72,11 +69,20 @@ public class SendContactRequest : RequestBase, IChatTargetable
///
/// Contact's phone number
/// Contact's first name
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendContactRequest(ChatId chatId, string phoneNumber, string firstName)
- : base("sendContact")
+ : this()
{
ChatId = chatId;
PhoneNumber = phoneNumber;
FirstName = firstName;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SendContactRequest()
+ : base("sendContact")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/SendDiceRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/SendDiceRequest.cs
index 0f62b3489..7203cd83d 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/SendDiceRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/SendDiceRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
@@ -16,7 +17,7 @@ public class SendDiceRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
@@ -38,13 +39,9 @@ public class SendDiceRequest : RequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -55,9 +52,18 @@ public class SendDiceRequest : RequestBase, IChatTargetable
///
/// Unique identifier for the target chat or username of the target channel
/// (in the format @channelusername)
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendDiceRequest(ChatId chatId)
- : base("sendDice")
+ : this()
{
ChatId = chatId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SendDiceRequest()
+ : base("sendDice")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/SendDocumentRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/SendDocumentRequest.cs
index e0996bbd2..b9ac628a4 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/SendDocumentRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/SendDocumentRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Extensions;
using Telegram.Bot.Requests.Abstractions;
@@ -18,13 +19,7 @@ public class SendDocumentRequest : FileRequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
-
- ///
- /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? MessageThreadId { get; set; }
+ public required ChatId ChatId { get; init; }
///
/// File to send. Pass a as String to send a file that
@@ -32,7 +27,13 @@ public class SendDocumentRequest : FileRequestBase, IChatTargetable
/// to get a file from the Internet, or upload a new one using multipart/form-data
///
[JsonProperty(Required = Required.Always)]
- public InputFile Document { get; }
+ public required InputFile Document { get; init; }
+
+ ///
+ /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public int? MessageThreadId { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -67,13 +68,9 @@ public class SendDocumentRequest : FileRequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -90,13 +87,22 @@ public class SendDocumentRequest : FileRequestBase, IChatTargetable
/// 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
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendDocumentRequest(ChatId chatId, InputFile document)
- : base("sendDocument")
+ : this()
{
ChatId = chatId;
Document = document;
}
+ ///
+ /// Initializes a new request
+ ///
+ public SendDocumentRequest()
+ : base("sendDocument")
+ { }
+
///
public override HttpContent? ToHttpContent() =>
Document is InputFileStream || Thumbnail is InputFileStream
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/SendMediaGroupRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/SendMediaGroupRequest.cs
index 9283d291f..f51872725 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/SendMediaGroupRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/SendMediaGroupRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Extensions;
using Telegram.Bot.Requests.Abstractions;
@@ -16,7 +17,7 @@ public class SendMediaGroupRequest : FileRequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
@@ -28,7 +29,7 @@ public class SendMediaGroupRequest : FileRequestBase, IChatTargetable
/// An array describing messages to be sent, must include 2-10 items
///
[JsonProperty(Required = Required.Always)]
- public IEnumerable Media { get; }
+ public required IEnumerable Media { get; init; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -38,13 +39,9 @@ public class SendMediaGroupRequest : FileRequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
/// Initializes a request with chatId and media
@@ -54,13 +51,22 @@ public class SendMediaGroupRequest : FileRequestBase, IChatTargetable
/// (in the format @channelusername)
///
/// An array describing messages to be sent, must include 2-10 items
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendMediaGroupRequest(ChatId chatId, IEnumerable media)
- : base("sendMediaGroup")
+ : this()
{
ChatId = chatId;
Media = media;
}
+ ///
+ /// Initializes a request
+ ///
+ public SendMediaGroupRequest()
+ : base("sendMediaGroup")
+ { }
+
///
public override HttpContent ToHttpContent()
{
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/SendMessageRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/SendMessageRequest.cs
index 68ea39c0c..fdc09fbcf 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/SendMessageRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/SendMessageRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
@@ -14,19 +15,19 @@ public class SendMessageRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
- /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
+ /// Text of the message to be sent, 1-4096 characters after entities parsing
///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? MessageThreadId { get; set; }
+ [JsonProperty(Required = Required.Always)]
+ public required string Text { get; init; }
///
- /// Text of the message to be sent, 1-4096 characters after entities parsing
+ /// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
///
- [JsonProperty(Required = Required.Always)]
- public string Text { get; }
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public int? MessageThreadId { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -37,10 +38,10 @@ public class SendMessageRequest : RequestBase, IChatTargetable
public IEnumerable? Entities { get; set; }
///
- /// Disables link previews for links in this message
+ /// Link preview generation options for the message
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? DisableWebPagePreview { get; set; }
+ public LinkPreviewOptions? LinkPreviewOptions { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -50,13 +51,9 @@ public class SendMessageRequest : RequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -69,10 +66,19 @@ public class SendMessageRequest : RequestBase, IChatTargetable
/// (in the format @channelusername)
///
/// Text of the message to be sent, 1-4096 characters after entities parsing
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendMessageRequest(ChatId chatId, string text)
- : base("sendMessage")
+ : this()
{
ChatId = chatId;
Text = text;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SendMessageRequest()
+ : base("sendMessage")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/SendPhotoRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/SendPhotoRequest.cs
index a119f9cb0..a83ba5014 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/SendPhotoRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/SendPhotoRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.Enums;
@@ -15,7 +16,7 @@ public class SendPhotoRequest : FileRequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
@@ -31,7 +32,7 @@ public class SendPhotoRequest : FileRequestBase, IChatTargetable
/// Width and height ratio must be at most 20
///
[JsonProperty(Required = Required.Always)]
- public InputFile Photo { get; }
+ public required InputFile Photo { get; init; }
///
/// Photo caption (may also be used when resending photos by ),
@@ -62,13 +63,9 @@ public class SendPhotoRequest : FileRequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -86,18 +83,27 @@ public class SendPhotoRequest : FileRequestBase, IChatTargetable
/// get a photo from the Internet, or upload a new photo using multipart/form-data. The photo
/// must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total.
/// Width and height ratio must be at most 20
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendPhotoRequest(ChatId chatId, InputFile photo)
- : base("sendPhoto")
+ : this()
{
ChatId = chatId;
Photo = photo;
}
+ ///
+ /// Initializes a new request
+ ///
+ public SendPhotoRequest()
+ : base("sendPhoto")
+ { }
+
///
public override HttpContent? ToHttpContent() =>
Photo switch
{
InputFileStream photo => ToMultipartFormDataContent(fileParameterName: "photo", inputFile: photo),
- _ => base.ToHttpContent()
+ _ => base.ToHttpContent()
};
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/SendPollRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/SendPollRequest.cs
index acaeed7dd..4035913e8 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/SendPollRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/SendPollRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json.Converters;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.Enums;
@@ -15,7 +16,7 @@ public class SendPollRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
@@ -27,13 +28,13 @@ public class SendPollRequest : RequestBase, IChatTargetable
/// Poll question, 1-300 characters
///
[JsonProperty(Required = Required.Always)]
- public string Question { get; }
+ public required string Question { get; init; }
///
/// A list of answer options, 2-10 strings 1-100 characters each
///
[JsonProperty(Required = Required.Always)]
- public IEnumerable Options { get; }
+ public required IEnumerable Options { get; init; }
///
/// , if the poll needs to be anonymous, defaults to
@@ -111,13 +112,9 @@ public class SendPollRequest : RequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -131,11 +128,20 @@ public class SendPollRequest : RequestBase, IChatTargetable
///
/// Poll question, 1-300 characters
/// A list of answer options, 2-10 strings 1-100 characters each
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendPollRequest(ChatId chatId, string question, IEnumerable options)
- : base("sendPoll")
+ : this()
{
ChatId = chatId;
Question = question;
Options = options;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SendPollRequest()
+ : base("sendPoll")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/SendVideoNoteRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/SendVideoNoteRequest.cs
index df0c2f52e..a13af1c65 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/SendVideoNoteRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/SendVideoNoteRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Extensions;
using Telegram.Bot.Requests.Abstractions;
@@ -16,7 +17,7 @@ public class SendVideoNoteRequest : FileRequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
@@ -30,7 +31,7 @@ public class SendVideoNoteRequest : FileRequestBase, IChatTargetable
/// multipart/form-data. Sending video notes by a URL is currently unsupported
///
[JsonProperty(Required = Required.Always)]
- public InputFile VideoNote { get; }
+ public required InputFile VideoNote { get; init; }
///
/// Duration of sent video in seconds
@@ -56,13 +57,9 @@ public class SendVideoNoteRequest : FileRequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -79,13 +76,22 @@ public class SendVideoNoteRequest : FileRequestBase, IChatTargetable
/// note that exists on the Telegram servers (recommended) or upload a new video using
/// multipart/form-data. Sending video notes by a URL is currently unsupported
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendVideoNoteRequest(ChatId chatId, InputFile videoNote)
- : base("sendVideoNote")
+ : this()
{
ChatId = chatId;
VideoNote = videoNote;
}
+ ///
+ /// Initializes a new request
+ ///
+ public SendVideoNoteRequest()
+ : base("sendVideoNote")
+ { }
+
///
public override HttpContent? ToHttpContent() =>
VideoNote is InputFileStream || Thumbnail is InputFileStream
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/SendVideoRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/SendVideoRequest.cs
index 64747f53e..3d4a65786 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/SendVideoRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/SendVideoRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Extensions;
using Telegram.Bot.Requests.Abstractions;
@@ -18,7 +19,7 @@ public class SendVideoRequest : FileRequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
@@ -32,7 +33,7 @@ public class SendVideoRequest : FileRequestBase, IChatTargetable
/// get a video from the Internet, or upload a new video using multipart/form-data
///
[JsonProperty(Required = Required.Always)]
- public InputFile Video { get; }
+ public required InputFile Video { get; init; }
///
/// Duration of sent video in seconds
@@ -91,13 +92,9 @@ public class SendVideoRequest : FileRequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -114,13 +111,22 @@ public class SendVideoRequest : FileRequestBase, IChatTargetable
/// 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
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendVideoRequest(ChatId chatId, InputFile video)
- : base("sendVideo")
+ : this()
{
ChatId = chatId;
Video = video;
}
+ ///
+ /// Initializes a new request
+ ///
+ public SendVideoRequest()
+ : base("sendVideo")
+ { }
+
///
public override HttpContent? ToHttpContent() =>
Video is InputFileStream || Thumbnail is InputFileStream
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/SendVoiceRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/SendVoiceRequest.cs
index 8cbed9619..8c8ce6f85 100644
--- a/src/Telegram.Bot/Requests/Available methods/Messages/SendVoiceRequest.cs
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/SendVoiceRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.Enums;
@@ -19,7 +20,7 @@ public class SendVoiceRequest : FileRequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
@@ -33,7 +34,7 @@ public class SendVoiceRequest : FileRequestBase, IChatTargetable
/// a file from the Internet, or upload a new one using multipart/form-data
///
[JsonProperty(Required = Required.Always)]
- public InputFile Voice { get; }
+ public required InputFile Voice { get; init; }
///
/// Voice message caption, 0-1024 characters after entities parsing
@@ -63,13 +64,9 @@ public class SendVoiceRequest : FileRequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -86,13 +83,22 @@ public class SendVoiceRequest : FileRequestBase, IChatTargetable
/// 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
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendVoiceRequest(ChatId chatId, InputFile voice)
- : base("sendVoice")
+ : this()
{
ChatId = chatId;
Voice = voice;
}
+ ///
+ /// Initializes a new request
+ ///
+ public SendVoiceRequest()
+ : base("sendVoice")
+ { }
+
///
public override HttpContent? ToHttpContent() =>
Voice switch
diff --git a/src/Telegram.Bot/Requests/Available methods/Messages/SetMessageReactionRequest.cs b/src/Telegram.Bot/Requests/Available methods/Messages/SetMessageReactionRequest.cs
new file mode 100644
index 000000000..7ee9704bc
--- /dev/null
+++ b/src/Telegram.Bot/Requests/Available methods/Messages/SetMessageReactionRequest.cs
@@ -0,0 +1,68 @@
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using Telegram.Bot.Requests.Abstractions;
+
+// ReSharper disable once CheckNamespace
+namespace Telegram.Bot.Requests;
+
+///
+/// Use this method to change the chosen reactions on a message. Service messages can't be reacted to.
+/// Automatically forwarded messages from a channel to its discussion group have the same
+/// available reactions as messages in the channel.
+/// Returns on success.
+///
+[JsonObject(MemberSerialization.OptIn, NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
+public class SetMessageReactionRequest : RequestBase,
+ IChatTargetable
+{
+ ///
+ [JsonProperty(Required = Required.Always)]
+ public required ChatId ChatId { get; init; }
+
+ ///
+ /// Identifier of the target message. If the message belongs to a media group, the reaction
+ /// is set to the first non-deleted message in the group instead.
+ ///
+ [JsonProperty(Required = Required.Always)]
+ public required int MessageId { get; init; }
+
+ ///
+ /// New list of reaction types to set on the message. Currently, as non-premium users, bots can
+ /// set up to one reaction per message. A custom emoji reaction can be used if it is either
+ /// already present on the message or explicitly allowed by chat administrators.
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public IEnumerable? Reaction { get; set; }
+
+ ///
+ /// Pass to set the reaction with a big animation
+ ///
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
+ public bool? IsBig { get; set; }
+
+ ///
+ /// Initializes a new request with chatId and messageId
+ ///
+ /// Unique identifier for the target chat or username of the target channel
+ /// (in the format @channelusername)
+ ///
+ ///
+ /// Identifier of the target message. If the message belongs to a media group, the reaction
+ /// is set to the first non-deleted message in the group instead.
+ ///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
+ public SetMessageReactionRequest(ChatId chatId, int messageId)
+ : this()
+ {
+ ChatId = chatId;
+ MessageId = messageId;
+ }
+
+ ///
+ /// Initializes a new request
+ ///
+ public SetMessageReactionRequest()
+ : base("setMessageReaction")
+ { }
+}
diff --git a/src/Telegram.Bot/Requests/Games/GetGameHighScoresRequest.cs b/src/Telegram.Bot/Requests/Games/GetGameHighScoresRequest.cs
index d197a7907..f4c65e5ad 100644
--- a/src/Telegram.Bot/Requests/Games/GetGameHighScoresRequest.cs
+++ b/src/Telegram.Bot/Requests/Games/GetGameHighScoresRequest.cs
@@ -1,4 +1,5 @@
-using Telegram.Bot.Requests.Abstractions;
+using System.Diagnostics.CodeAnalysis;
+using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
@@ -18,13 +19,13 @@ public class GetGameHighScoresRequest : RequestBase, IUserTarge
{
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// Unique identifier for the target chat
///
[JsonProperty(Required = Required.Always)]
- public long ChatId { get; }
+ public required long ChatId { get; init; }
///
ChatId IChatTargetable.ChatId => ChatId;
@@ -33,7 +34,7 @@ public class GetGameHighScoresRequest : RequestBase, IUserTarge
/// Identifier of the sent message
///
[JsonProperty(Required = Required.Always)]
- public int MessageId { get; }
+ public required int MessageId { get; init; }
///
/// Initializes a new request with userId, chatId and messageId
@@ -41,11 +42,20 @@ public class GetGameHighScoresRequest : RequestBase, IUserTarge
/// Target user id
/// Unique identifier for the target chat
/// Identifier of the sent message
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public GetGameHighScoresRequest(long userId, long chatId, int messageId)
- : base("getGameHighScores")
+ : this()
{
UserId = userId;
ChatId = chatId;
MessageId = messageId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public GetGameHighScoresRequest()
+ : base("getGameHighScores")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Games/GetInlineGameHighScoresRequest.cs b/src/Telegram.Bot/Requests/Games/GetInlineGameHighScoresRequest.cs
index 495b6f48e..1e7536aa9 100644
--- a/src/Telegram.Bot/Requests/Games/GetInlineGameHighScoresRequest.cs
+++ b/src/Telegram.Bot/Requests/Games/GetInlineGameHighScoresRequest.cs
@@ -1,4 +1,5 @@
-using Telegram.Bot.Requests.Abstractions;
+using System.Diagnostics.CodeAnalysis;
+using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
@@ -18,21 +19,30 @@ public class GetInlineGameHighScoresRequest : RequestBase, IUse
{
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
[JsonProperty(Required = Required.Always)]
- public string InlineMessageId { get; }
+ public required string InlineMessageId { get; init; }
///
/// Initializes a new request with userId and inlineMessageId
///
/// User identifier
/// Identifier of the inline message
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public GetInlineGameHighScoresRequest(long userId, string inlineMessageId)
- : base("getGameHighScores")
+ : this()
{
UserId = userId;
InlineMessageId = inlineMessageId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public GetInlineGameHighScoresRequest()
+ : base("getGameHighScores")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Games/SendGameRequest.cs b/src/Telegram.Bot/Requests/Games/SendGameRequest.cs
index dc5a6d125..abb390577 100644
--- a/src/Telegram.Bot/Requests/Games/SendGameRequest.cs
+++ b/src/Telegram.Bot/Requests/Games/SendGameRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.ReplyMarkups;
@@ -14,7 +15,7 @@ public class SendGameRequest : RequestBase, IChatTargetable
/// Unique identifier for the target chat
///
[JsonProperty(Required = Required.Always)]
- public long ChatId { get; }
+ public required long ChatId { get; init; }
///
ChatId IChatTargetable.ChatId => ChatId;
@@ -30,7 +31,7 @@ public class SendGameRequest : RequestBase, IChatTargetable
/// via @BotFather
///
[JsonProperty(Required = Required.Always)]
- public string GameShortName { get; }
+ public required string GameShortName { get; init; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -40,13 +41,9 @@ public class SendGameRequest : RequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -60,10 +57,19 @@ public class SendGameRequest : RequestBase, IChatTargetable
/// Short name of the game, serves as the unique identifier for the game. Set up your games via
/// @BotFather
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendGameRequest(long chatId, string gameShortName)
- : base("sendGame")
+ : this()
{
ChatId = chatId;
GameShortName = gameShortName;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SendGameRequest()
+ : base("sendGame")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Games/SetGameScoreRequest.cs b/src/Telegram.Bot/Requests/Games/SetGameScoreRequest.cs
index 7cfd9d297..0e0c9f20a 100644
--- a/src/Telegram.Bot/Requests/Games/SetGameScoreRequest.cs
+++ b/src/Telegram.Bot/Requests/Games/SetGameScoreRequest.cs
@@ -1,4 +1,5 @@
-using Telegram.Bot.Requests.Abstractions;
+using System.Diagnostics.CodeAnalysis;
+using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
@@ -13,13 +14,13 @@ public class SetGameScoreRequest : RequestBase, IUserTargetable, IChatT
{
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// New score, must be non-negative
///
[JsonProperty(Required = Required.Always)]
- public int Score { get; }
+ public required int Score { get; init; }
///
/// Pass , if the high score is allowed to decrease. This can be useful when fixing mistakes
@@ -39,7 +40,7 @@ public class SetGameScoreRequest : RequestBase, IUserTargetable, IChatT
/// Unique identifier for the target chat
///
[JsonProperty(Required = Required.Always)]
- public long ChatId { get; }
+ public required long ChatId { get; init; }
///
ChatId IChatTargetable.ChatId => ChatId;
@@ -48,7 +49,7 @@ public class SetGameScoreRequest : RequestBase, IUserTargetable, IChatT
/// Identifier of the sent message
///
[JsonProperty(Required = Required.Always)]
- public int MessageId { get; }
+ public required int MessageId { get; init; }
///
/// Initializes a new request
@@ -57,12 +58,21 @@ public class SetGameScoreRequest : RequestBase, IUserTargetable, IChatT
/// New score, must be non-negative
/// Unique identifier for the target chat
/// Identifier of the sent message
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetGameScoreRequest(long userId, int score, long chatId, int messageId)
- : base("setGameScore")
+ : this()
{
UserId = userId;
Score = score;
ChatId = chatId;
MessageId = messageId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SetGameScoreRequest()
+ : base("setGameScore")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Games/SetInlineGameScoreRequest.cs b/src/Telegram.Bot/Requests/Games/SetInlineGameScoreRequest.cs
index 82dd80fab..1796949db 100644
--- a/src/Telegram.Bot/Requests/Games/SetInlineGameScoreRequest.cs
+++ b/src/Telegram.Bot/Requests/Games/SetInlineGameScoreRequest.cs
@@ -1,4 +1,5 @@
-using Telegram.Bot.Requests.Abstractions;
+using System.Diagnostics.CodeAnalysis;
+using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
@@ -13,13 +14,13 @@ public class SetInlineGameScoreRequest : RequestBase, IUserTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// New score, must be non-negative
///
[JsonProperty(Required = Required.Always)]
- public int Score { get; }
+ public required int Score { get; init; }
///
/// Pass , if the high score is allowed to decrease. This can be useful when fixing mistakes
@@ -37,7 +38,7 @@ public class SetInlineGameScoreRequest : RequestBase, IUserTargetable
///
[JsonProperty(Required = Required.Always)]
- public string InlineMessageId { get; }
+ public required string InlineMessageId { get; init; }
///
/// Initializes a new request with userId, inlineMessageId and new score
@@ -45,11 +46,20 @@ public class SetInlineGameScoreRequest : RequestBase, IUserTargetable
/// User identifier
/// New score, must be non-negative
/// Identifier of the inline message
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetInlineGameScoreRequest(long userId, int score, string inlineMessageId)
- : base("setGameScore")
+ : this()
{
UserId = userId;
Score = score;
InlineMessageId = inlineMessageId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SetInlineGameScoreRequest()
+ : base("setGameScore")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Getting Updates/SetWebhookRequest.cs b/src/Telegram.Bot/Requests/Getting Updates/SetWebhookRequest.cs
index 9cab0c1b7..aa52c998f 100644
--- a/src/Telegram.Bot/Requests/Getting Updates/SetWebhookRequest.cs
+++ b/src/Telegram.Bot/Requests/Getting Updates/SetWebhookRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Types.Enums;
@@ -40,7 +41,7 @@ public class SetWebhookRequest : FileRequestBase
/// HTTPS URL to send updates to. Use an empty string to remove webhook integration
///
[JsonProperty(Required = Required.Always)]
- public string Url { get; }
+ public required string Url { get; init; }
///
/// Upload your public key certificate so that the root certificate in use can be checked. See
@@ -100,9 +101,16 @@ public class SetWebhookRequest : FileRequestBase
///
/// HTTPS url to send updates to. Use an empty string to remove webhook integration
///
- public SetWebhookRequest(string url)
- : base("setWebhook") =>
- Url = url;
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
+ public SetWebhookRequest(string url) : base("setWebhook")
+ => Url = url;
+
+ ///
+ /// Initializes a new request
+ ///
+ public SetWebhookRequest() : base("setWebhook")
+ { }
///
public override HttpContent? ToHttpContent() =>
diff --git a/src/Telegram.Bot/Requests/Inline Mode/AnswerInlineQueryRequest.cs b/src/Telegram.Bot/Requests/Inline Mode/AnswerInlineQueryRequest.cs
index 5bc0bcbe4..4b2265397 100644
--- a/src/Telegram.Bot/Requests/Inline Mode/AnswerInlineQueryRequest.cs
+++ b/src/Telegram.Bot/Requests/Inline Mode/AnswerInlineQueryRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Types.InlineQueryResults;
// ReSharper disable once CheckNamespace
@@ -17,13 +18,13 @@ public class AnswerInlineQueryRequest : RequestBase
/// Unique identifier for the answered query
///
[JsonProperty(Required = Required.Always)]
- public string InlineQueryId { get; }
+ public required string InlineQueryId { get; init; }
///
/// An array of results for the inline query
///
[JsonProperty(Required = Required.Always)]
- public IEnumerable Results { get; }
+ public required IEnumerable Results { get; init; }
///
/// The maximum amount of time in seconds that the result of the
@@ -58,10 +59,19 @@ public class AnswerInlineQueryRequest : RequestBase
///
/// Unique identifier for the answered query
/// An array of results for the inline query
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public AnswerInlineQueryRequest(string inlineQueryId, IEnumerable results)
- : base("answerInlineQuery")
+ : this()
{
InlineQueryId = inlineQueryId;
Results = results;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public AnswerInlineQueryRequest()
+ : base("answerInlineQuery")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Inline Mode/AnswerWebAppQueryRequest.cs b/src/Telegram.Bot/Requests/Inline Mode/AnswerWebAppQueryRequest.cs
index a4b14f194..320cb4457 100644
--- a/src/Telegram.Bot/Requests/Inline Mode/AnswerWebAppQueryRequest.cs
+++ b/src/Telegram.Bot/Requests/Inline Mode/AnswerWebAppQueryRequest.cs
@@ -1,4 +1,5 @@
-using Telegram.Bot.Types.InlineQueryResults;
+using System.Diagnostics.CodeAnalysis;
+using Telegram.Bot.Types.InlineQueryResults;
// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
@@ -15,23 +16,32 @@ public class AnswerWebAppQueryRequest : RequestBase
/// Unique identifier for the query to be answered
///
[JsonProperty(Required = Required.Always)]
- public string WebAppQueryId { get; }
+ public required string WebAppQueryId { get; init; }
///
/// An object describing the message to be sent
///
[JsonProperty(Required = Required.Always)]
- public InlineQueryResult Result { get; }
+ public required InlineQueryResult Result { get; init; }
///
/// Initializes a new request with and a
///
/// Unique identifier for the query to be answered
/// An object describing the message to be sent
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public AnswerWebAppQueryRequest(string webAppQueryId, InlineQueryResult result)
- : base("answerWebAppQuery")
+ : this()
{
WebAppQueryId = webAppQueryId;
Result = result;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public AnswerWebAppQueryRequest()
+ : base("answerWebAppQuery")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/ParameterlessRequest.cs b/src/Telegram.Bot/Requests/ParameterlessRequest.cs
index 1c9cd5fd7..e0a2bff02 100644
--- a/src/Telegram.Bot/Requests/ParameterlessRequest.cs
+++ b/src/Telegram.Bot/Requests/ParameterlessRequest.cs
@@ -7,13 +7,13 @@ namespace Telegram.Bot.Requests;
///
///
[JsonObject(MemberSerialization.OptIn, NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
-public class ParameterlessRequest : RequestBase
+public abstract class ParameterlessRequest : RequestBase
{
///
/// Initializes an instance of
///
/// Name of request method
- public ParameterlessRequest(string methodName)
+ protected ParameterlessRequest(string methodName)
: base(methodName)
{ }
@@ -22,7 +22,7 @@ public ParameterlessRequest(string methodName)
///
/// Name of request method
/// HTTP request method
- public ParameterlessRequest(string methodName, HttpMethod method)
+ protected ParameterlessRequest(string methodName, HttpMethod method)
: base(methodName, method)
{ }
diff --git a/src/Telegram.Bot/Requests/Payments/AnswerPreCheckoutQueryRequest.cs b/src/Telegram.Bot/Requests/Payments/AnswerPreCheckoutQueryRequest.cs
index 7f62bbc09..3e20680ca 100644
--- a/src/Telegram.Bot/Requests/Payments/AnswerPreCheckoutQueryRequest.cs
+++ b/src/Telegram.Bot/Requests/Payments/AnswerPreCheckoutQueryRequest.cs
@@ -1,4 +1,6 @@
-// ReSharper disable once CheckNamespace
+using System.Diagnostics.CodeAnalysis;
+
+// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
///
@@ -17,14 +19,14 @@ public class AnswerPreCheckoutQueryRequest : RequestBase
/// Unique identifier for the query to be answered
///
[JsonProperty(Required = Required.Always)]
- public string PreCheckoutQueryId { get; }
+ public required string PreCheckoutQueryId { get; init; }
///
/// Specify if everything is alright (goods are available, etc.) and the
/// bot is ready to proceed with the order. Use if there are any problems.
///
[JsonProperty(Required = Required.Always)]
- public bool Ok { get; }
+ public required bool Ok { get; init; }
///
/// Required if is . Error message in human readable form that explains
@@ -33,14 +35,15 @@ public class AnswerPreCheckoutQueryRequest : RequestBase
/// Please choose a different color or garment!"). Telegram will display this message to the user.
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public string? ErrorMessage { get; }
+ public string? ErrorMessage { get; set; }
///
/// Initializes a new successful answerPreCheckoutQuery request
///
/// Unique identifier for the query to be answered
+ [SetsRequiredMembers]
public AnswerPreCheckoutQueryRequest(string preCheckoutQueryId)
- : base("answerPreCheckoutQuery")
+ : this()
{
PreCheckoutQueryId = preCheckoutQueryId;
Ok = true;
@@ -56,11 +59,19 @@ public AnswerPreCheckoutQueryRequest(string preCheckoutQueryId)
/// our amazing black T-shirts while you were busy filling out your payment details. Please
/// choose a different color or garment!"). Telegram will display this message to the user.
///
+ [SetsRequiredMembers]
public AnswerPreCheckoutQueryRequest(string preCheckoutQueryId, string errorMessage)
- : base("answerPreCheckoutQuery")
+ : this()
{
PreCheckoutQueryId = preCheckoutQueryId;
Ok = false;
ErrorMessage = errorMessage;
}
+
+ ///
+ /// Initializes a new failing answerPreCheckoutQuery request with error message
+ ///
+ public AnswerPreCheckoutQueryRequest()
+ : base("answerPreCheckoutQuery")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Payments/AnswerShippingQueryRequest.cs b/src/Telegram.Bot/Requests/Payments/AnswerShippingQueryRequest.cs
index 64d07c70e..7f973b710 100644
--- a/src/Telegram.Bot/Requests/Payments/AnswerShippingQueryRequest.cs
+++ b/src/Telegram.Bot/Requests/Payments/AnswerShippingQueryRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Types.Payments;
// ReSharper disable once CheckNamespace
@@ -17,20 +18,20 @@ public class AnswerShippingQueryRequest : RequestBase
/// Unique identifier for the query to be answered
///
[JsonProperty(Required = Required.Always)]
- public string ShippingQueryId { get; }
+ public required string ShippingQueryId { get; init; }
///
/// Specify if delivery to the specified address is possible and
/// if there are any problems (for example, if delivery to the specified address is not possible)
///
[JsonProperty(Required = Required.Always)]
- public bool Ok { get; }
+ public required bool Ok { get; init; }
///
/// Required if is . An array of available shipping options.
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public IEnumerable? ShippingOptions { get; }
+ public IEnumerable? ShippingOptions { get; init; }
///
/// Required if is . Error message in human readable form that explains
@@ -38,15 +39,16 @@ public class AnswerShippingQueryRequest : RequestBase
/// is unavailable'). Telegram will display this message to the user.
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public string? ErrorMessage { get; }
+ public string? ErrorMessage { get; set; }
///
/// Initializes a new failing answerShippingQuery request with error message
///
/// Unique identifier for the query to be answered
/// Error message in human readable form
+ [SetsRequiredMembers]
public AnswerShippingQueryRequest(string shippingQueryId, string errorMessage)
- : base("answerShippingQuery")
+ : this()
{
ShippingQueryId = shippingQueryId;
Ok = false;
@@ -58,12 +60,20 @@ public AnswerShippingQueryRequest(string shippingQueryId, string errorMessage)
///
/// Unique identifier for the query to be answered
/// A JSON-serialized array of available shipping options
+ [SetsRequiredMembers]
public AnswerShippingQueryRequest(
string shippingQueryId,
- IEnumerable shippingOptions) : base("answerShippingQuery")
+ IEnumerable shippingOptions) : this()
{
ShippingQueryId = shippingQueryId;
Ok = true;
ShippingOptions = shippingOptions;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public AnswerShippingQueryRequest()
+ : base("answerShippingQuery")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Payments/CreateInvoiceLinkRequest.cs b/src/Telegram.Bot/Requests/Payments/CreateInvoiceLinkRequest.cs
index 7d4c3b715..5252145a1 100644
--- a/src/Telegram.Bot/Requests/Payments/CreateInvoiceLinkRequest.cs
+++ b/src/Telegram.Bot/Requests/Payments/CreateInvoiceLinkRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Types.Payments;
// ReSharper disable once CheckNamespace
@@ -14,40 +15,40 @@ public class CreateInvoiceLinkRequest : RequestBase
/// Product name, 1-32 characters
///
[JsonProperty(Required = Required.Always)]
- public string Title { get; }
+ public required string Title { get; init; }
///
/// Product description, 1-255 characters
///
[JsonProperty(Required = Required.Always)]
- public string Description { get; }
+ public required string Description { get; init; }
///
/// Bot-defined invoice payload, 1-128 bytes.This will not be displayed to the user,
/// use for your internal processes.
///
[JsonProperty(Required = Required.Always)]
- public string Payload { get; }
+ public required string Payload { get; init; }
///
/// Payments provider token, obtained via @BotFather
///
[JsonProperty(Required = Required.Always)]
- public string ProviderToken { get; }
+ public required string ProviderToken { get; init; }
///
/// Three-letter ISO 4217 currency code, see
/// more on currencies
///
[JsonProperty(Required = Required.Always)]
- public string Currency { get; }
+ public required string Currency { get; init; }
///
/// Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost,
/// delivery tax, bonus, etc.)
///
[JsonProperty(Required = Required.Always)]
- public IEnumerable Prices { get; }
+ public required IEnumerable Prices { get; init; }
///
/// The maximum accepted amount for tips in the smallest units of the currency.
@@ -160,13 +161,16 @@ public class CreateInvoiceLinkRequest : RequestBase
/// Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost,
/// delivery tax, bonus, etc.)
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public CreateInvoiceLinkRequest(
string title,
string description,
string payload,
string providerToken,
string currency,
- IEnumerable prices) : base("createInvoiceLink")
+ IEnumerable prices)
+ : this()
{
Title = title;
Description = description;
@@ -175,4 +179,11 @@ public class CreateInvoiceLinkRequest : RequestBase
Currency = currency;
Prices = prices;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public CreateInvoiceLinkRequest()
+ : base("createInvoiceLink")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Payments/SendInvoiceRequest.cs b/src/Telegram.Bot/Requests/Payments/SendInvoiceRequest.cs
index 89d81738d..d681cf4b0 100644
--- a/src/Telegram.Bot/Requests/Payments/SendInvoiceRequest.cs
+++ b/src/Telegram.Bot/Requests/Payments/SendInvoiceRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.Payments;
using Telegram.Bot.Types.ReplyMarkups;
@@ -17,7 +18,7 @@ public class SendInvoiceRequest : RequestBase, IChatTargetable
/// (in the format @channelusername)
///
[JsonProperty(Required = Required.Always)]
- public long ChatId { get; }
+ public required long ChatId { get; init; }
///
ChatId IChatTargetable.ChatId => ChatId;
@@ -32,40 +33,40 @@ public class SendInvoiceRequest : RequestBase, IChatTargetable
/// Product name, 1-32 characters
///
[JsonProperty(Required = Required.Always)]
- public string Title { get; }
+ public required string Title { get; init; }
///
/// Product description, 1-255 characters
///
[JsonProperty(Required = Required.Always)]
- public string Description { get; }
+ public required string Description { get; init; }
///
/// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user,
/// use for your internal processes
///
[JsonProperty(Required = Required.Always)]
- public string Payload { get; }
+ public required string Payload { get; init; }
///
/// Payments provider token, obtained via @BotFather
///
[JsonProperty(Required = Required.Always)]
- public string ProviderToken { get; }
+ public required string ProviderToken { get; init; }
///
/// Three-letter ISO 4217 currency code, see
/// more on currencies
///
[JsonProperty(Required = Required.Always)]
- public string Currency { get; }
+ public required string Currency { get; init; }
///
/// Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost,
/// delivery tax, bonus, etc.)
///
[JsonProperty(Required = Required.Always)]
- public IEnumerable Prices { get; }
+ public required IEnumerable Prices { get; init; }
///
/// The maximum accepted amount for tips in the smallest units of the currency.
@@ -178,13 +179,9 @@ public class SendInvoiceRequest : RequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -212,6 +209,8 @@ public class SendInvoiceRequest : RequestBase, IChatTargetable
/// Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost,
/// delivery tax, bonus, etc.)
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendInvoiceRequest(
long chatId,
string title,
@@ -219,7 +218,7 @@ public class SendInvoiceRequest : RequestBase, IChatTargetable
string payload,
string providerToken,
string currency,
- IEnumerable prices) : base("sendInvoice")
+ IEnumerable prices) : this()
{
ChatId = chatId;
Title = title;
@@ -229,4 +228,11 @@ public class SendInvoiceRequest : RequestBase, IChatTargetable
Currency = currency;
Prices = prices;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SendInvoiceRequest()
+ : base("sendInvoice")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Stickers/AddStickerToSetRequest.cs b/src/Telegram.Bot/Requests/Stickers/AddStickerToSetRequest.cs
index fe4267fa5..e7e8e12cc 100644
--- a/src/Telegram.Bot/Requests/Stickers/AddStickerToSetRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/AddStickerToSetRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Requests.Abstractions;
@@ -25,20 +26,20 @@ public class AddStickerToSetRequest : FileRequestBase, IUserTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// Sticker set name
///
[JsonProperty(Required = Required.Always)]
- public string Name { get; }
+ public required string Name { get; init; }
///
/// A JSON-serialized object with information about the added sticker.
/// If exactly the same sticker had already been added to the set, then the set isn't changed.
///
[JsonProperty(Required = Required.Always)]
- public InputSticker Sticker { get; }
+ public required InputSticker Sticker { get; init; }
///
/// Initializes a new request with userId, name and sticker
@@ -53,17 +54,26 @@ public class AddStickerToSetRequest : FileRequestBase, IUserTargetable
/// A JSON-serialized object with information about the added sticker.
/// If exactly the same sticker had already been added to the set, then the set isn't changed.
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public AddStickerToSetRequest(
long userId,
string name,
InputSticker sticker)
- : base("addStickerToSet")
+ : this()
{
UserId = userId;
Name = name;
Sticker = sticker;
}
+ ///
+ /// Initializes a new request
+ ///
+ public AddStickerToSetRequest()
+ : base("addStickerToSet")
+ { }
+
///
public override HttpContent? ToHttpContent()
=>
diff --git a/src/Telegram.Bot/Requests/Stickers/CreateNewStickerSetRequest.cs b/src/Telegram.Bot/Requests/Stickers/CreateNewStickerSetRequest.cs
index a4294d61c..629312d5f 100644
--- a/src/Telegram.Bot/Requests/Stickers/CreateNewStickerSetRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/CreateNewStickerSetRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Extensions;
using Telegram.Bot.Requests.Abstractions;
@@ -17,7 +18,7 @@ public class CreateNewStickerSetRequest : FileRequestBase, IUserTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals).
@@ -26,25 +27,25 @@ public class CreateNewStickerSetRequest : FileRequestBase, IUserTargetable
/// <bot_username> is case insensitive. 1-64 characters
///
[JsonProperty(Required = Required.Always)]
- public string Name { get; }
+ public required string Name { get; init; }
///
/// Sticker set title, 1-64 characters
///
[JsonProperty(Required = Required.Always)]
- public string Title { get; }
+ public required string Title { get; init; }
///
/// A JSON-serialized list of 1-50 initial stickers to be added to the sticker set
///
[JsonProperty(Required = Required.Always)]
- public IEnumerable Stickers { get; }
+ public required IEnumerable Stickers { get; init; }
///
/// Format of stickers in the set.
///
[JsonProperty(Required = Required.Always)]
- public StickerFormat StickerFormat { get; }
+ public required StickerFormat StickerFormat { get; init; }
///
/// Type of stickers in the set.
@@ -83,13 +84,15 @@ public class CreateNewStickerSetRequest : FileRequestBase, IUserTargetable
///
/// Format of stickers in the set.
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public CreateNewStickerSetRequest(
long userId,
string name,
string title,
IEnumerable stickers,
StickerFormat stickerFormat)
- : base("createNewStickerSet")
+ : this()
{
UserId = userId;
Name = name;
@@ -98,6 +101,13 @@ public class CreateNewStickerSetRequest : FileRequestBase, IUserTargetable
StickerFormat = stickerFormat;
}
+ ///
+ /// Initializes a new request
+ ///
+ public CreateNewStickerSetRequest()
+ : base("createNewStickerSet")
+ { }
+
///
public override HttpContent ToHttpContent()
{
diff --git a/src/Telegram.Bot/Requests/Stickers/DeleteStickerFromSetRequest.cs b/src/Telegram.Bot/Requests/Stickers/DeleteStickerFromSetRequest.cs
index 5c0956669..7082e5f42 100644
--- a/src/Telegram.Bot/Requests/Stickers/DeleteStickerFromSetRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/DeleteStickerFromSetRequest.cs
@@ -1,3 +1,5 @@
+using System.Diagnostics.CodeAnalysis;
+
// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
@@ -11,7 +13,7 @@ public class DeleteStickerFromSetRequest : RequestBase
/// File identifier of the sticker
///
[JsonProperty(Required = Required.Always)]
- public InputFileId Sticker { get; }
+ public required InputFileId Sticker { get; init; }
///
/// Initializes a new request with sticker
@@ -19,9 +21,18 @@ public class DeleteStickerFromSetRequest : RequestBase
///
/// File identifier of the sticker
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public DeleteStickerFromSetRequest(InputFileId sticker)
- : base("deleteStickerFromSet")
+ : this()
{
Sticker = sticker;
}
+
+ ///
+ /// Initializes a new request with sticker
+ ///
+ public DeleteStickerFromSetRequest()
+ : base("deleteStickerFromSet")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Stickers/DeleteStickerSetRequest.cs b/src/Telegram.Bot/Requests/Stickers/DeleteStickerSetRequest.cs
index 2efd192e7..d7d467e26 100644
--- a/src/Telegram.Bot/Requests/Stickers/DeleteStickerSetRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/DeleteStickerSetRequest.cs
@@ -1,3 +1,6 @@
+using System.Diagnostics.CodeAnalysis;
+
+// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
///
@@ -11,7 +14,7 @@ namespace Telegram.Bot.Requests;
/// Sticker set name
///
[JsonProperty(Required = Required.Always)]
- public string Name { get; }
+ public required string Name { get; init; }
///
/// Initializes a new request with name
@@ -19,9 +22,18 @@ namespace Telegram.Bot.Requests;
///
/// Sticker set name
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public DeleteStickerSetRequest(string name)
- : base("deleteStickerSet")
+ : this()
{
Name = name;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public DeleteStickerSetRequest()
+ : base("deleteStickerSet")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Stickers/GetCustomEmojiStickersRequest.cs b/src/Telegram.Bot/Requests/Stickers/GetCustomEmojiStickersRequest.cs
index c9a641e25..9a339ba6e 100644
--- a/src/Telegram.Bot/Requests/Stickers/GetCustomEmojiStickersRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/GetCustomEmojiStickersRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
@@ -14,16 +15,26 @@ public class GetCustomEmojiStickersRequest : RequestBase
/// List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
///
[JsonProperty(Required = Required.Always)]
- public IEnumerable CustomEmojiIds { get; }
+ public required IEnumerable CustomEmojiIds { get; init; }
///
/// Initializes a new request with name
///
- /// List of custom emoji identifiers. At most 200 custom emoji
- /// identifiers can be specified.
+ ///
+ /// List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
+ ///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public GetCustomEmojiStickersRequest(IEnumerable customEmojiIds)
- : base("getCustomEmojiStickers")
+ : this()
{
CustomEmojiIds = customEmojiIds;
}
+
+ ///
+ /// Initializes a new request with name
+ ///
+ public GetCustomEmojiStickersRequest()
+ : base("getCustomEmojiStickers")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Stickers/GetStickerSetRequest.cs b/src/Telegram.Bot/Requests/Stickers/GetStickerSetRequest.cs
index 261a3bca6..0715a00d9 100644
--- a/src/Telegram.Bot/Requests/Stickers/GetStickerSetRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/GetStickerSetRequest.cs
@@ -1,3 +1,5 @@
+using System.Diagnostics.CodeAnalysis;
+
// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
@@ -11,15 +13,24 @@ public class GetStickerSetRequest : RequestBase
/// Name of the sticker set
///
[JsonProperty(Required = Required.Always)]
- public string Name { get; }
+ public required string Name { get; init; }
///
/// Initializes a new request with name
///
/// Name of the sticker set
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public GetStickerSetRequest(string name)
- : base("getStickerSet")
+ : this()
{
Name = name;
}
+
+ ///
+ /// Initializes a new request with name
+ ///
+ public GetStickerSetRequest()
+ : base("getStickerSet")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Stickers/SendStickerRequest.cs b/src/Telegram.Bot/Requests/Stickers/SendStickerRequest.cs
index 02790c5da..12f581792 100644
--- a/src/Telegram.Bot/Requests/Stickers/SendStickerRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/SendStickerRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.ReplyMarkups;
@@ -14,7 +15,7 @@ public class SendStickerRequest : FileRequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
@@ -31,7 +32,7 @@ public class SendStickerRequest : FileRequestBase, IChatTargetable
/// Animated stickers can't be sent via an HTTP URL.
///
[JsonProperty(Required = Required.Always)]
- public InputFile Sticker { get; }
+ public required InputFile Sticker { get; init; }
///
/// Optional. Emoji associated with the sticker; only for just uploaded stickers
@@ -47,13 +48,9 @@ public class SendStickerRequest : FileRequestBase, IChatTargetable
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool? ProtectContent { get; set; }
- ///
+ ///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public int? ReplyToMessageId { get; set; }
-
- ///
- [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? AllowSendingWithoutReply { get; set; }
+ public ReplyParameters? ReplyParameters { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -74,13 +71,22 @@ public class SendStickerRequest : FileRequestBase, IChatTargetable
/// Video stickers can only be sent by a .
/// Animated stickers can't be sent via an HTTP URL.
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SendStickerRequest(ChatId chatId, InputFile sticker)
- : base("sendSticker")
+ : this()
{
ChatId = chatId;
Sticker = sticker;
}
+ ///
+ /// Initializes a new request chatId and sticker
+ ///
+ public SendStickerRequest()
+ : base("sendSticker")
+ { }
+
///
public override HttpContent? ToHttpContent() =>
Sticker switch
diff --git a/src/Telegram.Bot/Requests/Stickers/SetCustomEmojiStickerSetThumbnailRequest.cs b/src/Telegram.Bot/Requests/Stickers/SetCustomEmojiStickerSetThumbnailRequest.cs
index a4f33948c..c4b0f983d 100644
--- a/src/Telegram.Bot/Requests/Stickers/SetCustomEmojiStickerSetThumbnailRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/SetCustomEmojiStickerSetThumbnailRequest.cs
@@ -1,3 +1,6 @@
+using System.Diagnostics.CodeAnalysis;
+
+// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
///
@@ -11,7 +14,7 @@ public class SetCustomEmojiStickerSetThumbnailRequest : RequestBase
/// Sticker set name
///
[JsonProperty(Required = Required.Always)]
- public string Name { get; }
+ public required string Name { get; init; }
///
/// Optional. Custom emoji identifier of a from the ;
@@ -26,9 +29,18 @@ public class SetCustomEmojiStickerSetThumbnailRequest : RequestBase
///
/// Sticker set name
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetCustomEmojiStickerSetThumbnailRequest(string name)
- : base("setCustomEmojiStickerSetThumbnail")
+ : this()
{
Name = name;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SetCustomEmojiStickerSetThumbnailRequest()
+ : base("setCustomEmojiStickerSetThumbnail")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Stickers/SetStickerEmojiListRequest.cs b/src/Telegram.Bot/Requests/Stickers/SetStickerEmojiListRequest.cs
index 3b88db490..a063aabcd 100644
--- a/src/Telegram.Bot/Requests/Stickers/SetStickerEmojiListRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/SetStickerEmojiListRequest.cs
@@ -1,5 +1,7 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
///
@@ -14,13 +16,13 @@ public class SetStickerEmojiListRequest : RequestBase
/// File identifier of the sticker
///
[JsonProperty(Required = Required.Always)]
- public InputFileId Sticker { get; }
+ public required InputFileId Sticker { get; init; }
///
/// A JSON-serialized list of 1-20 emoji associated with the sticker
///
[JsonProperty(Required = Required.Always)]
- public IEnumerable EmojiList { get; }
+ public required IEnumerable EmojiList { get; init; }
///
/// Initializes a new request with sticker and emojiList
@@ -31,10 +33,19 @@ public class SetStickerEmojiListRequest : RequestBase
///
/// A JSON-serialized list of 1-20 emoji associated with the sticker
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetStickerEmojiListRequest(InputFileId sticker, IEnumerable emojiList)
- : base("setStickerEmojiList")
+ : this()
{
Sticker = sticker;
EmojiList = emojiList;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SetStickerEmojiListRequest()
+ : base("setStickerEmojiList")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Stickers/SetStickerKeywordsRequest.cs b/src/Telegram.Bot/Requests/Stickers/SetStickerKeywordsRequest.cs
index 28b66a993..222c680b2 100644
--- a/src/Telegram.Bot/Requests/Stickers/SetStickerKeywordsRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/SetStickerKeywordsRequest.cs
@@ -1,5 +1,7 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
///
@@ -14,7 +16,7 @@ public class SetStickerKeywordsRequest : RequestBase
/// File identifier of the sticker
///
[JsonProperty(Required = Required.Always)]
- public InputFileId Sticker { get; }
+ public required InputFileId Sticker { get; init; }
///
/// Optional. A JSON-serialized list of 0-20 search keywords for the sticker
@@ -29,9 +31,18 @@ public class SetStickerKeywordsRequest : RequestBase
///
/// File identifier of the sticker
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetStickerKeywordsRequest(InputFileId sticker)
- : base("setStickerKeywords")
+ : this()
{
Sticker = sticker;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SetStickerKeywordsRequest()
+ : base("setStickerKeywords")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Stickers/SetStickerMaskPositionRequest.cs b/src/Telegram.Bot/Requests/Stickers/SetStickerMaskPositionRequest.cs
index 277f35d14..651c12fd9 100644
--- a/src/Telegram.Bot/Requests/Stickers/SetStickerMaskPositionRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/SetStickerMaskPositionRequest.cs
@@ -1,3 +1,6 @@
+using System.Diagnostics.CodeAnalysis;
+
+// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
///
@@ -13,7 +16,7 @@ public class SetStickerMaskPositionRequest : RequestBase
/// File identifier of the sticker
///
[JsonProperty(Required = Required.Always)]
- public InputFileId Sticker { get; }
+ public required InputFileId Sticker { get; init; }
///
/// A JSON-serialized object with the position where the mask should be placed on faces.
@@ -28,9 +31,18 @@ public class SetStickerMaskPositionRequest : RequestBase
///
/// File identifier of the sticker
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetStickerMaskPositionRequest(InputFileId sticker)
- : base("setStickerMaskPosition")
+ : this()
{
Sticker = sticker;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SetStickerMaskPositionRequest()
+ : base("setStickerMaskPosition")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Stickers/SetStickerPositionInSetRequest.cs b/src/Telegram.Bot/Requests/Stickers/SetStickerPositionInSetRequest.cs
index 83676b6ec..d6ea2baaa 100644
--- a/src/Telegram.Bot/Requests/Stickers/SetStickerPositionInSetRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/SetStickerPositionInSetRequest.cs
@@ -1,3 +1,5 @@
+using System.Diagnostics.CodeAnalysis;
+
// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
@@ -12,13 +14,13 @@ public class SetStickerPositionInSetRequest : RequestBase
/// File identifier of the sticker
///
[JsonProperty(Required = Required.Always)]
- public InputFileId Sticker { get; }
+ public required InputFileId Sticker { get; init; }
///
/// New sticker position in the set, zero-based
///
[JsonProperty(Required = Required.Always)]
- public int Position { get; }
+ public required int Position { get; init; }
///
/// Initializes a new request with sticker and position
@@ -27,10 +29,19 @@ public class SetStickerPositionInSetRequest : RequestBase
/// File identifier of the sticker
///
/// New sticker position in the set, zero-based
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetStickerPositionInSetRequest(InputFileId sticker, int position)
- : base("setStickerPositionInSet")
+ : this()
{
Sticker = sticker;
Position = position;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SetStickerPositionInSetRequest()
+ : base("setStickerPositionInSet")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Stickers/SetStickerSetThumbnailRequest.cs b/src/Telegram.Bot/Requests/Stickers/SetStickerSetThumbnailRequest.cs
index 34e7d8ad0..6945d85bc 100644
--- a/src/Telegram.Bot/Requests/Stickers/SetStickerSetThumbnailRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/SetStickerSetThumbnailRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Requests.Abstractions;
@@ -16,11 +17,11 @@ public class SetStickerSetThumbnailRequest : FileRequestBase, IUserTargeta
/// Sticker set name
///
[JsonProperty(Required = Required.Always)]
- public string Name { get; }
+ public required string Name { get; init; }
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have
@@ -41,13 +42,22 @@ public class SetStickerSetThumbnailRequest : FileRequestBase, IUserTargeta
///
/// Sticker set name
/// User identifier of the sticker set owner
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetStickerSetThumbnailRequest(string name, long userId)
- : base("setStickerSetThumbnail")
+ : this()
{
Name = name;
UserId = userId;
}
+ ///
+ /// Initializes a new request
+ ///
+ public SetStickerSetThumbnailRequest()
+ : base("setStickerSetThumbnail")
+ { }
+
///
public override HttpContent? ToHttpContent() =>
Thumbnail switch
diff --git a/src/Telegram.Bot/Requests/Stickers/SetStickerSetTitleRequest.cs b/src/Telegram.Bot/Requests/Stickers/SetStickerSetTitleRequest.cs
index 130546cc1..3f970c79f 100644
--- a/src/Telegram.Bot/Requests/Stickers/SetStickerSetTitleRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/SetStickerSetTitleRequest.cs
@@ -1,3 +1,6 @@
+using System.Diagnostics.CodeAnalysis;
+
+// ReSharper disable once CheckNamespace
namespace Telegram.Bot.Requests;
///
@@ -11,13 +14,13 @@ public class SetStickerSetTitleRequest : RequestBase
/// Sticker set name
///
[JsonProperty(Required = Required.Always)]
- public string Name { get; }
+ public required string Name { get; init; }
///
/// Sticker set title, 1-64 characters
///
[JsonProperty(Required = Required.Always)]
- public string Title { get; }
+ public required string Title { get; init; }
///
/// Initializes a new request with name and title
@@ -28,10 +31,19 @@ public class SetStickerSetTitleRequest : RequestBase
///
/// Sticker set title, 1-64 characters
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public SetStickerSetTitleRequest(string name, string title)
- : base("setStickerSetTitle")
+ : this()
{
Name = name;
Title = title;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public SetStickerSetTitleRequest()
+ : base("setStickerSetTitle")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Stickers/UploadStickerFileRequest.cs b/src/Telegram.Bot/Requests/Stickers/UploadStickerFileRequest.cs
index 8d7250a4c..1e31a0eb4 100644
--- a/src/Telegram.Bot/Requests/Stickers/UploadStickerFileRequest.cs
+++ b/src/Telegram.Bot/Requests/Stickers/UploadStickerFileRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.Enums;
@@ -17,19 +18,19 @@ public class UploadStickerFileRequest : FileRequestBase, IUserTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public long UserId { get; }
+ public required long UserId { get; init; }
///
/// A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format.
///
[JsonProperty(Required = Required.Always)]
- public InputFileStream Sticker { get; }
+ public required InputFileStream Sticker { get; init; }
///
/// Format of the sticker
///
[JsonProperty(Required = Required.Always)]
- public StickerFormat StickerFormat { get; }
+ public required StickerFormat StickerFormat { get; init; }
///
/// Initializes a new request with userId, sticker and stickerFormat
@@ -43,14 +44,23 @@ public class UploadStickerFileRequest : FileRequestBase, IUserTargetable
///
/// Format of the sticker
///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public UploadStickerFileRequest(long userId, InputFileStream sticker, StickerFormat stickerFormat)
- : base("uploadStickerFile")
+ : this()
{
UserId = userId;
Sticker = sticker;
StickerFormat = stickerFormat;
}
+ ///
+ /// Initializes a new request
+ ///
+ public UploadStickerFileRequest()
+ : base("uploadStickerFile")
+ { }
+
///
public override HttpContent? ToHttpContent()
=> ToMultipartFormDataContent(fileParameterName: "sticker", inputFile: Sticker);
diff --git a/src/Telegram.Bot/Requests/Updating messages/DeleteMessageRequest.cs b/src/Telegram.Bot/Requests/Updating messages/DeleteMessageRequest.cs
index a4d3b2c88..fe7780bee 100644
--- a/src/Telegram.Bot/Requests/Updating messages/DeleteMessageRequest.cs
+++ b/src/Telegram.Bot/Requests/Updating messages/DeleteMessageRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
// ReSharper disable once CheckNamespace
@@ -24,13 +25,13 @@ public class DeleteMessageRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Identifier of the message to delete
///
[JsonProperty(Required = Required.Always)]
- public int MessageId { get; }
+ public required int MessageId { get; init; }
///
/// Initializes a new request with chatId and messageId
@@ -40,10 +41,19 @@ public class DeleteMessageRequest : RequestBase, IChatTargetable
/// (in the format @channelusername)
///
/// Identifier of the message to delete
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public DeleteMessageRequest(ChatId chatId, int messageId)
- : base("deleteMessage")
+ : this()
{
ChatId = chatId;
MessageId = messageId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public DeleteMessageRequest()
+ : base("deleteMessage")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Updating messages/DeleteMessagesRequest.cs b/src/Telegram.Bot/Requests/Updating messages/DeleteMessagesRequest.cs
new file mode 100644
index 000000000..5f4e67797
--- /dev/null
+++ b/src/Telegram.Bot/Requests/Updating messages/DeleteMessagesRequest.cs
@@ -0,0 +1,53 @@
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using Telegram.Bot.Requests.Abstractions;
+
+// ReSharper disable once CheckNamespace
+namespace Telegram.Bot.Requests;
+
+///
+/// Use this method to delete multiple messages simultaneously.
+/// If some of the specified messages can't be found, they are skipped.
+/// Returns on success.
+///
+[JsonObject(MemberSerialization.OptIn, NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
+public class DeleteMessagesRequest : RequestBase, IChatTargetable
+{
+ ///
+ [JsonProperty(Required = Required.Always)]
+ public required ChatId ChatId { get; init; }
+
+ ///
+ /// Identifiers of 1-100 messages to delete. See
+ /// for limitations on which messages can be deleted
+ ///
+ [JsonProperty(Required = Required.Always)]
+ public required IEnumerable MessageIds { get; init; }
+
+ ///
+ /// Initializes a new request with chatId and messageIds
+ ///
+ ///
+ /// Unique identifier for the target chat or username of the target channel
+ /// (in the format @channelusername)
+ ///
+ ///
+ /// Identifiers of 1-100 messages to delete. See
+ /// for limitations on which messages can be deleted
+ ///
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
+ public DeleteMessagesRequest(ChatId chatId, IEnumerable messageIds)
+ : this()
+ {
+ ChatId = chatId;
+ MessageIds = messageIds;
+ }
+
+ ///
+ /// Initializes a new request with chatId and messageIds
+ ///
+ public DeleteMessagesRequest()
+ : base("deleteMessages")
+ { }
+}
diff --git a/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageCaptionRequest.cs b/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageCaptionRequest.cs
index a2e2899a2..660291d1a 100644
--- a/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageCaptionRequest.cs
+++ b/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageCaptionRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
@@ -14,7 +15,7 @@ public class EditInlineMessageCaptionRequest : RequestBase
{
///
[JsonProperty(Required = Required.Always)]
- public string InlineMessageId { get; }
+ public required string InlineMessageId { get; init; }
///
/// New caption of the message, 0-1024 characters after entities parsing
@@ -38,9 +39,18 @@ public class EditInlineMessageCaptionRequest : RequestBase
/// Initializes a new request with inlineMessageId and new caption
///
/// Identifier of the inline message
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public EditInlineMessageCaptionRequest(string inlineMessageId)
- : base("editMessageCaption")
+ : this()
{
InlineMessageId = inlineMessageId;
}
+
+ ///
+ /// Initializes a new request with inlineMessageId and new caption
+ ///
+ public EditInlineMessageCaptionRequest()
+ : base("editMessageCaption")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageMediaRequest.cs b/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageMediaRequest.cs
index b54ce9e58..e918dd761 100644
--- a/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageMediaRequest.cs
+++ b/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageMediaRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.ReplyMarkups;
@@ -16,13 +17,13 @@ public class EditInlineMessageMediaRequest : RequestBase
{
///
[JsonProperty(Required = Required.Always)]
- public string InlineMessageId { get; }
+ public required string InlineMessageId { get; init; }
///
/// A new media content of the message
///
[JsonProperty(Required = Required.Always)]
- public InputMedia Media { get; }
+ public required InputMedia Media { get; init; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -33,10 +34,19 @@ public class EditInlineMessageMediaRequest : RequestBase
///
/// Identifier of the inline message
/// A new media content of the message
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public EditInlineMessageMediaRequest(string inlineMessageId, InputMedia media)
- : base("editMessageMedia")
+ : this()
{
InlineMessageId = inlineMessageId;
Media = media;
}
+
+ ///
+ /// Initializes a new request with inlineMessageId and new media
+ ///
+ public EditInlineMessageMediaRequest()
+ : base("editMessageMedia")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageReplyMarkupRequest.cs b/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageReplyMarkupRequest.cs
index cd8bdd2a2..3d6d10f96 100644
--- a/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageReplyMarkupRequest.cs
+++ b/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageReplyMarkupRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.ReplyMarkups;
@@ -12,7 +13,7 @@ public class EditInlineMessageReplyMarkupRequest : RequestBase
{
///
[JsonProperty(Required = Required.Always)]
- public string InlineMessageId { get; }
+ public required string InlineMessageId { get; init; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -22,9 +23,18 @@ public class EditInlineMessageReplyMarkupRequest : RequestBase
/// Initializes a new request with inlineMessageId and new inline keyboard
///
/// Identifier of the inline message
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public EditInlineMessageReplyMarkupRequest(string inlineMessageId)
- : base("editMessageReplyMarkup")
+ : this()
{
InlineMessageId = inlineMessageId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public EditInlineMessageReplyMarkupRequest()
+ : base("editMessageReplyMarkup")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageTextRequest.cs b/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageTextRequest.cs
index a44308bb4..727dd7bcc 100644
--- a/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageTextRequest.cs
+++ b/src/Telegram.Bot/Requests/Updating messages/EditInlineMessageTextRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
@@ -14,13 +15,13 @@ public class EditInlineMessageTextRequest : RequestBase
{
///
[JsonProperty(Required = Required.Always)]
- public string InlineMessageId { get; }
+ public required string InlineMessageId { get; init; }
///
/// New text of the message, 1-4096 characters after entities parsing
///
[JsonProperty(Required = Required.Always)]
- public string Text { get; }
+ public required string Text { get; init; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -31,10 +32,10 @@ public class EditInlineMessageTextRequest : RequestBase
public IEnumerable? Entities { get; set; }
///
- /// Disables link previews for links in this message
+ /// Link preview generation options for the message
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? DisableWebPagePreview { get; set; }
+ public LinkPreviewOptions? LinkPreviewOptions { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -45,10 +46,19 @@ public class EditInlineMessageTextRequest : RequestBase
///
/// Identifier of the inline message
/// New text of the message, 1-4096 characters after entities parsing
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public EditInlineMessageTextRequest(string inlineMessageId, string text)
- : base("editMessageText")
+ : this()
{
InlineMessageId = inlineMessageId;
Text = text;
}
+
+ ///
+ /// Initializes a new request with inlineMessageId and new text
+ ///
+ public EditInlineMessageTextRequest()
+ : base("editMessageText")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Updating messages/EditMessageCaptionRequest.cs b/src/Telegram.Bot/Requests/Updating messages/EditMessageCaptionRequest.cs
index ba67b17cf..a0ad5b8f3 100644
--- a/src/Telegram.Bot/Requests/Updating messages/EditMessageCaptionRequest.cs
+++ b/src/Telegram.Bot/Requests/Updating messages/EditMessageCaptionRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
@@ -14,13 +15,13 @@ public class EditMessageCaptionRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Identifier of the message to edit
///
[JsonProperty(Required = Required.Always)]
- public int MessageId { get; }
+ public required int MessageId { get; init; }
///
/// New caption of the message, 0-1024 characters after entities parsing
@@ -47,10 +48,19 @@ public class EditMessageCaptionRequest : RequestBase, IChatTargetable
/// (in the format @channelusername)
///
/// Identifier of the message to edit
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public EditMessageCaptionRequest(ChatId chatId, int messageId)
- : base("editMessageCaption")
+ : this()
{
ChatId = chatId;
MessageId = messageId;
}
+
+ ///
+ /// Initializes a new request with chatId and messageIdn
+ ///
+ public EditMessageCaptionRequest()
+ : base("editMessageCaption")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Updating messages/EditMessageMediaRequest.cs b/src/Telegram.Bot/Requests/Updating messages/EditMessageMediaRequest.cs
index c7396d401..ae3bc83cd 100644
--- a/src/Telegram.Bot/Requests/Updating messages/EditMessageMediaRequest.cs
+++ b/src/Telegram.Bot/Requests/Updating messages/EditMessageMediaRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using Telegram.Bot.Extensions;
using Telegram.Bot.Requests.Abstractions;
@@ -19,19 +20,19 @@ public class EditMessageMediaRequest : FileRequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Identifier of the message to edit
///
[JsonProperty(Required = Required.Always)]
- public int MessageId { get; }
+ public required int MessageId { get; init; }
///
/// A new media content of the message
///
[JsonProperty(Required = Required.Always)]
- public InputMedia Media { get; }
+ public required InputMedia Media { get; init; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -46,14 +47,23 @@ public class EditMessageMediaRequest : FileRequestBase, IChatTargetable
///
/// Identifier of the message to edit
/// A new media content of the message
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public EditMessageMediaRequest(ChatId chatId, int messageId, InputMedia media)
- : base("editMessageMedia")
+ : this()
{
ChatId = chatId;
MessageId = messageId;
Media = media;
}
+ ///
+ /// Initializes a new
+ ///
+ public EditMessageMediaRequest()
+ : base("editMessageMedia")
+ { }
+
///
public override HttpContent? ToHttpContent()
{
diff --git a/src/Telegram.Bot/Requests/Updating messages/EditMessageReplyMarkupRequest.cs b/src/Telegram.Bot/Requests/Updating messages/EditMessageReplyMarkupRequest.cs
index 7335fbf35..a8c7a7158 100644
--- a/src/Telegram.Bot/Requests/Updating messages/EditMessageReplyMarkupRequest.cs
+++ b/src/Telegram.Bot/Requests/Updating messages/EditMessageReplyMarkupRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.ReplyMarkups;
@@ -13,13 +14,13 @@ public class EditMessageReplyMarkupRequest : RequestBase, IChatTargetab
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Identifier of the message to edit
///
[JsonProperty(Required = Required.Always)]
- public int MessageId { get; }
+ public required int MessageId { get; init; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -33,10 +34,19 @@ public class EditMessageReplyMarkupRequest : RequestBase, IChatTargetab
/// (in the format @channelusername)
///
/// Identifier of the message to edit
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public EditMessageReplyMarkupRequest(ChatId chatId, int messageId)
- : base("editMessageReplyMarkup")
+ : this()
{
ChatId = chatId;
MessageId = messageId;
}
+
+ ///
+ /// Initializes a new request with chatId and messageId
+ ///
+ public EditMessageReplyMarkupRequest()
+ : base("editMessageReplyMarkup")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Updating messages/EditMessageTextRequest.cs b/src/Telegram.Bot/Requests/Updating messages/EditMessageTextRequest.cs
index b3bbba159..cab8edc66 100644
--- a/src/Telegram.Bot/Requests/Updating messages/EditMessageTextRequest.cs
+++ b/src/Telegram.Bot/Requests/Updating messages/EditMessageTextRequest.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
@@ -14,19 +15,19 @@ public class EditMessageTextRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Identifier of the message to edit
///
[JsonProperty(Required = Required.Always)]
- public int MessageId { get; }
+ public required int MessageId { get; init; }
///
/// New text of the message, 1-4096 characters after entities parsing
///
[JsonProperty(Required = Required.Always)]
- public string Text { get; }
+ public required string Text { get; init; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -37,10 +38,10 @@ public class EditMessageTextRequest : RequestBase, IChatTargetable
public IEnumerable? Entities { get; set; }
///
- /// Disables link previews for links in this message
+ /// Link preview generation options for the message
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
- public bool? DisableWebPagePreview { get; set; }
+ public LinkPreviewOptions? LinkPreviewOptions { get; set; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -55,11 +56,20 @@ public class EditMessageTextRequest : RequestBase, IChatTargetable
///
/// Identifier of the message to edit
/// New text of the message, 1-4096 characters after entities parsing
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public EditMessageTextRequest(ChatId chatId, int messageId, string text)
- : base("editMessageText")
+ : this()
{
ChatId = chatId;
MessageId = messageId;
Text = text;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public EditMessageTextRequest()
+ : base("editMessageText")
+ { }
}
diff --git a/src/Telegram.Bot/Requests/Updating messages/StopPollRequest.cs b/src/Telegram.Bot/Requests/Updating messages/StopPollRequest.cs
index 0eadcf287..0c9dbe1f0 100644
--- a/src/Telegram.Bot/Requests/Updating messages/StopPollRequest.cs
+++ b/src/Telegram.Bot/Requests/Updating messages/StopPollRequest.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics.CodeAnalysis;
using Telegram.Bot.Requests.Abstractions;
using Telegram.Bot.Types.ReplyMarkups;
@@ -14,13 +15,13 @@ public class StopPollRequest : RequestBase, IChatTargetable
{
///
[JsonProperty(Required = Required.Always)]
- public ChatId ChatId { get; }
+ public required ChatId ChatId { get; init; }
///
/// Identifier of the original message with the poll
///
[JsonProperty(Required = Required.Always)]
- public int MessageId { get; }
+ public required int MessageId { get; init; }
///
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
@@ -34,10 +35,19 @@ public class StopPollRequest : RequestBase, IChatTargetable
/// @channelusername)
///
/// Identifier of the original message with the poll
+ [SetsRequiredMembers]
+ [Obsolete("Use parameterless constructor with required properties")]
public StopPollRequest(ChatId chatId, int messageId)
- : base("stopPoll")
+ : this()
{
ChatId = chatId;
MessageId = messageId;
}
+
+ ///
+ /// Initializes a new request
+ ///
+ public StopPollRequest()
+ : base("stopPoll")
+ { }
}
diff --git a/src/Telegram.Bot/Telegram.Bot.csproj b/src/Telegram.Bot/Telegram.Bot.csproj
index 883305b5a..23caa6dc8 100644
--- a/src/Telegram.Bot/Telegram.Bot.csproj
+++ b/src/Telegram.Bot/Telegram.Bot.csproj
@@ -2,9 +2,8 @@
netstandard2.0;net6.0
- 11
+ 12
enable
- 7
True
AllEnabledByDefault
latest-recommended
@@ -24,6 +23,7 @@
RoundRobin,Poulad,tuscen
Copyright © Robin Müller 2016
package-icon.png
+ README.md
https://github.com/TelegramBots/telegram.bot
MIT
https://github.com/TelegramBots/telegram.bot.git
@@ -52,7 +52,12 @@
'HttpClient.GetAsync(Uri, HttpCompletionOption, CancellationToken)' instead
of 'HttpClient.GetAsync(string, HttpCompletionOption, CancellationToken)' -->
$(NoWarn);CA1031
- $(NoWarn);MA0046;MA0048;MA0051
+ $(NoWarn);CA1716
+ $(NoWarn);CA1510
+ $(NoWarn);MA0046
+ $(NoWarn);MA0048;MA0051
@@ -60,6 +65,7 @@
true
/
+
@@ -70,7 +76,7 @@
-
+
@@ -79,9 +85,11 @@
-
-
-
+
+
+
+
+
diff --git a/src/Telegram.Bot/TelegramBotClient.cs b/src/Telegram.Bot/TelegramBotClient.cs
index d3b0adfd7..bdf77b08c 100644
--- a/src/Telegram.Bot/TelegramBotClient.cs
+++ b/src/Telegram.Bot/TelegramBotClient.cs
@@ -149,7 +149,7 @@ public TimeSpan Timeout
var apiResponse = await httpResponse
.DeserializeContentAsync>(
- guard: response => response.Ok == false ||
+ guard: response => !response.Ok ||
response.Result is null
)
.ConfigureAwait(false);
@@ -253,8 +253,13 @@ await MakeRequestAsync(request: new GetMeRequest(), cancellationToken: cancellat
try
{
+#if NET6_0_OR_GREATER
+ await httpResponse.Content.CopyToAsync(destination, cancellationToken)
+ .ConfigureAwait(false);
+#else
await httpResponse.Content.CopyToAsync(destination)
.ConfigureAwait(false);
+#endif
}
catch (Exception exception)
{
diff --git a/src/Telegram.Bot/TelegramBotClientExtensions.ApiMethods.Requests.cs b/src/Telegram.Bot/TelegramBotClientExtensions.ApiMethods.Requests.cs
new file mode 100644
index 000000000..0ecc34fae
--- /dev/null
+++ b/src/Telegram.Bot/TelegramBotClientExtensions.ApiMethods.Requests.cs
@@ -0,0 +1,2529 @@
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+using Telegram.Bot.Extensions;
+using Telegram.Bot.Requests;
+using Telegram.Bot.Types.Enums;
+using Telegram.Bot.Types.Payments;
+using Telegram.Bot.Types.ReplyMarkups;
+using File = Telegram.Bot.Types.File;
+
+namespace Telegram.Bot;
+
+///
+/// Extension methods that map to requests from Bot API documentation
+///
+public static partial class TelegramBotClientExtensions
+{
+ ///
+ /// Use this method to send answers to callback queries sent from
+ /// inline keyboards. The answer will be displayed
+ /// to the user as a notification at the top of the chat screen or as an alert
+ ///
+ ///
+ /// Alternatively, the user can be redirected to the specified Game URL.For this option to work, you must
+ /// first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use
+ /// links like t.me/your_bot?start=XXXX that open your bot with a parameter
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task AnswerCallbackQueryAsync(
+ this ITelegramBotClient botClient,
+ AnswerCallbackQueryRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to delete the list of the bot’s commands for the given
+ /// and user language. After deletion,
+ /// higher level commands
+ /// will be shown to affected users
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task DeleteMyCommandsAsync(
+ this ITelegramBotClient botClient,
+ DeleteMyCommandsRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to get the current list of the bot’s commands for the given
+ /// and user language
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ ///
+ /// Returns Array of on success. If commands aren't set, an empty list is returned
+ ///
+ public static async Task GetMyCommandsAsync(
+ this ITelegramBotClient botClient,
+ GetMyCommandsRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to change the list of the bot’s commands.
+ /// See for more details about bot commands
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task SetMyCommandsAsync(
+ this ITelegramBotClient botClient,
+ SetMyCommandsRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to get the current bot description
+ /// for the given user language.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ ///
+ /// Returns on success.
+ ///
+ public static async Task GetMyDescriptionAsync(
+ this ITelegramBotClient botClient,
+ GetMyDescriptionRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to change the bot's description, which is shown in the chat
+ /// with the bot if the chat is empty.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task SetMyDescriptionAsync(
+ this ITelegramBotClient botClient,
+ SetMyDescriptionRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can
+ /// download files of up to 20MB in size. The file can then be downloaded via the link
+ /// https://api.telegram.org/file/bot<token>/<file_path>, where <file_path>
+ /// is taken from the response. It is guaranteed that the link will be valid for at least 1 hour.
+ /// When the link expires, a new one can be requested by calling
+ /// GetFileAsync again.
+ ///
+ ///
+ /// You can use or
+ /// methods to download the file
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, a object is returned.
+ public static async Task GetFileAsync(
+ this ITelegramBotClient botClient,
+ GetFileRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to get basic info about a file download it. For the moment, bots can download files
+ /// of up to 20MB in size.
+ ///
+ /// An instance of
+ /// File identifier to get info about
+ /// Destination stream to write file to
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, a object is returned.
+ public static async Task GetInfoAndDownloadFileAsync(
+ this ITelegramBotClient botClient,
+ string fileId,
+ Stream destination,
+ CancellationToken cancellationToken = default)
+ {
+ var file = await botClient.ThrowIfNull()
+ .MakeRequestAsync(new GetFileRequest { FileId = fileId }, cancellationToken)
+ .ConfigureAwait(false);
+
+ await botClient.DownloadFileAsync(filePath: file.FilePath!, destination, cancellationToken)
+ .ConfigureAwait(false);
+
+ return file;
+ }
+
+ ///
+ /// Use this method to get a list of profile pictures for a user.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// Returns a object
+ public static async Task GetUserProfilePhotosAsync(
+ this ITelegramBotClient botClient,
+ GetUserProfilePhotosRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to get the current value of the bot’s menu button in a private chat,
+ /// or the default menu button.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// set for the given chat id or a default one
+ public static async Task GetChatMenuButtonAsync(
+ this ITelegramBotClient botClient,
+ GetChatMenuButtonRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// A simple method for testing your bot’s auth token.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// Returns basic information about the bot in form of a object.
+ public static async Task GetMeAsync(
+ this ITelegramBotClient botClient,
+ GetMeRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to get the current default administrator rights of the bot.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// Default or channel
+ public static async Task GetMyDefaultAdministratorRightsAsync(
+ this ITelegramBotClient botClient,
+ GetMyDefaultAdministratorRightsRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to get the current bot name for the given user language.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ ///
+ /// Returns on success.
+ ///
+ public static async Task GetMyNameAsync(
+ this ITelegramBotClient botClient,
+ GetMyNameRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to get the list of boosts added to a chat by a user.
+ /// Requires administrator rights in the chat.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// Returns a object.
+ public static async Task GetUserChatBoostsAsync(
+ this ITelegramBotClient botClient,
+ GetUserChatBoostsRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to close the bot instance before moving it from one local server to another. You need to
+ /// delete the webhook before calling this method to ensure that the bot isn't launched again after server
+ /// restart. The method will return error 429 in the first 10 minutes after the bot is launched.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task CloseAsync(
+ this ITelegramBotClient botClient,
+ CloseRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to log out from the cloud Bot API server before launching the bot locally. You must
+ /// log out the bot before running it locally, otherwise there is no guarantee that the bot will receive
+ /// updates. After a successful call, you can immediately log in on a local server, but will not be able to
+ /// log in back to the cloud Bot API server for 10 minutes.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task LogOutAsync(
+ this ITelegramBotClient botClient,
+ LogOutRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and
+ /// channels, the user will not be able to return to the chat on their own using invite links, etc., unless
+ /// unbanned
+ /// first. The bot must be an administrator in the chat for this to work and must have the appropriate
+ /// admin rights.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task BanChatMemberAsync(
+ this ITelegramBotClient botClient,
+ BanChatMemberRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ ///
+ public static async Task BanChatSenderChatAsync(
+ this ITelegramBotClient botClient,
+ BanChatSenderChatRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to approve a chat join request. The bot must be an administrator in the chat for this to
+ /// work and must have the administrator right.
+ /// Returns on success.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task ApproveChatJoinRequestAsync(
+ this ITelegramBotClient botClient,
+ ApproveChatJoinRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to create an additional invite link for a chat. The bot must be an administrator
+ /// in the chat for this to work and must have the appropriate admin rights. The link can be revoked
+ /// using the method
+ /// RevokeChatInviteLinkAsync
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// Returns the new invite link as object.
+ public static async Task CreateChatInviteLinkAsync(
+ this ITelegramBotClient botClient,
+ CreateChatInviteLinkRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to decline a chat join request. The bot must be an administrator in the chat for this to
+ /// work and must have the administrator right.
+ /// Returns on success.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task DeclineChatJoinRequestAsync(
+ this ITelegramBotClient botClient,
+ DeclineChatJoinRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to edit a non-primary invite link created by the bot. The bot must be an
+ /// administrator in the chat for this to work and must have the appropriate admin rights
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// Returns the edited invite link as a object.
+ public static async Task EditChatInviteLinkAsync(
+ this ITelegramBotClient botClient,
+ EditChatInviteLinkRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to generate a new primary invite link for a chat; any previously generated primary
+ /// link is revoked. The bot must be an administrator in the chat for this to work and must have the
+ /// appropriate admin rights
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task ExportChatInviteLinkAsync(
+ this ITelegramBotClient botClient,
+ ExportChatInviteLinkRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new
+ /// link is automatically generated. The bot must be an administrator in the chat for this to work and
+ /// must have the appropriate admin rights
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// Returns the revoked invite link as object.
+ public static async Task RevokeChatInviteLinkAsync(
+ this ITelegramBotClient botClient,
+ RevokeChatInviteLinkRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat
+ /// for this to work and must have the administrator rights,
+ /// unless it is the creator of the topic. Returns on success.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task CloseForumTopicAsync(
+ this ITelegramBotClient botClient,
+ CloseForumTopicRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator
+ /// in the chat for this to work and must have the
+ /// administrator rights. Returns on success.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task CloseGeneralForumTopicAsync(
+ this ITelegramBotClient botClient,
+ CloseGeneralForumTopicRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for
+ /// this to work and must have the administrator rights.
+ /// Returns information about the created topic as a object.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ ///
+ /// Returns information about the created topic as a object.
+ ///
+ public static async Task CreateForumTopicAsync(
+ this ITelegramBotClient botClient,
+ CreateForumTopicRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an
+ /// administrator in the chat for this to work and must have the appropriate admin rights
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task DeleteChatPhotoAsync(
+ this ITelegramBotClient botClient,
+ DeleteChatPhotoRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the
+ /// chat for this to work and must have the appropriate admin rights. Use the field
+ /// optionally returned in
+ /// GetChatAsync
+ /// requests to check if the bot can use this method
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task DeleteChatStickerSetAsync(
+ this ITelegramBotClient botClient,
+ DeleteChatStickerSetRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be
+ /// an administrator in the chat for this to work and must have the
+ /// administrator rights. Returns
+ /// on success.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task DeleteForumTopicAsync(
+ this ITelegramBotClient botClient,
+ DeleteForumTopicRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator
+ /// in the chat for this to work and must have administrator
+ /// rights, unless it is the creator of the topic. Returns on success.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task EditForumTopicAsync(
+ this ITelegramBotClient botClient,
+ EditForumTopicRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an
+ /// administrator in the chat for this to work and must have
+ /// administrator rights. Returns on success.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task EditGeneralForumTopicAsync(
+ this ITelegramBotClient botClient,
+ EditGeneralForumTopicRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to get a list of administrators in a chat.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ ///
+ /// On success, returns an Array of objects that contains information about all chat
+ /// administrators except other bots. If the chat is a group or a supergroup and no administrators were
+ /// appointed, only the creator will be returned
+ ///
+ public static async Task GetChatAdministratorsAsync(
+ this ITelegramBotClient botClient,
+ GetChatAdministratorsRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to get the number of members in a chat.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// Returns on success.
+ public static async Task GetChatMemberCountAsync(
+ this ITelegramBotClient botClient,
+ GetChatMemberCountRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to get information about a member of a chat.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// Returns a object on success.
+ public static async Task GetChatMemberAsync(
+ this ITelegramBotClient botClient,
+ GetChatMemberRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to get up to date information about the chat (current name of the user for one-on-one
+ /// conversations, current username of a user, group or channel, etc.)
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// Returns a object on success.
+ public static async Task GetChatAsync(
+ this ITelegramBotClient botClient,
+ GetChatRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the
+ /// chat for this to work and must have the administrator
+ /// rights. The topic will be automatically closed if it was open. Returns on success.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task HideGeneralForumTopicAsync(
+ this ITelegramBotClient botClient,
+ HideGeneralForumTopicRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method for your bot to leave a group, supergroup or channel.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task LeaveChatAsync(
+ this ITelegramBotClient botClient,
+ LeaveChatRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ ///
+ public static async Task PinChatMessageAsync(
+ this ITelegramBotClient botClient,
+ PinChatMessageRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in
+ /// the chat for this to work and must have the appropriate admin rights. Pass for
+ /// all boolean parameters to demote a user.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task PromoteChatMemberAsync(
+ this ITelegramBotClient botClient,
+ PromoteChatMemberRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the
+ /// chat for this to work and must have the administrator
+ /// rights, unless it is the creator of the topic. Returns on success.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task ReopenForumTopicAsync(
+ this ITelegramBotClient botClient,
+ ReopenForumTopicRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an
+ /// administrator in the chat for this to work and must have the
+ /// administrator rights. The topic will be automatically
+ /// unhidden if it was hidden. Returns on success.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task ReopenGeneralForumTopicAsync(
+ this ITelegramBotClient botClient,
+ ReopenGeneralForumTopicRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup
+ /// for this to work and must have the appropriate admin rights. Pass for all permissions to
+ /// lift restrictions from a user.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task RestrictChatMemberAsync(
+ this ITelegramBotClient botClient,
+ RestrictChatMemberRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to set a custom title for an administrator in a supergroup promoted by the bot.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task SetChatAdministratorCustomTitleAsync(
+ this ITelegramBotClient botClient,
+ SetChatAdministratorCustomTitleRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to change the description of a group, a supergroup or a channel. The bot must
+ /// be an administrator in the chat for this to work and must have the appropriate admin rights
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task SetChatDescriptionAsync(
+ this ITelegramBotClient botClient,
+ SetChatDescriptionRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to set default chat permissions for all members. The bot must be an administrator
+ /// in the group or a supergroup for this to work and must have the
+ /// admin rights
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task SetChatPermissionsAsync(
+ this ITelegramBotClient botClient,
+ SetChatPermissionsRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to set a new profile photo for the chat. Photos can't be changed for private chats.
+ /// The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task SetChatPhotoAsync(
+ this ITelegramBotClient botClient,
+ SetChatPhotoRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the
+ /// chat for this to work and must have the appropriate admin rights. Use the field
+ /// optionally returned in
+ /// GetChatAsync
+ /// request to check if the bot can use this method.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task SetChatStickerSetAsync(
+ this ITelegramBotClient botClient,
+ SetChatStickerSetRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to change the title of a chat. Titles can't be changed for private chats. The bot
+ /// must be an administrator in the chat for this to work and must have the appropriate admin rights
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task SetChatTitleAsync(
+ this ITelegramBotClient botClient,
+ SetChatTitleRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to unban a previously banned user in a supergroup or channel. The user will not
+ /// return to the group or channel automatically, but will be able to join via link, etc. The bot must be an
+ /// administrator for this to work. By default, this method guarantees that after the call the user is not a
+ /// member of the chat, but will be able to join it. So if the user is a member of the chat they will also be
+ /// removed from the chat.
+ /// If you don't want this, use the property
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task UnbanChatMemberAsync(
+ this ITelegramBotClient botClient,
+ UnbanChatMemberRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be
+ /// an administrator for this to work and must have the appropriate administrator rights.
+ /// Returns on success.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task UnbanChatSenderChatAsync(
+ this ITelegramBotClient botClient,
+ UnbanChatSenderChatRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to uhhide the 'General' topic in a forum supergroup chat. The bot must be an administrator
+ /// in the chat for this to work and must have the
+ /// administrator rights. Returns on success.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task UnhideGeneralForumTopicAsync(
+ this ITelegramBotClient botClient,
+ UnhideGeneralForumTopicRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat,
+ /// the bot must be an administrator in the chat for this to work and must have the
+ /// '' admin right in a supergroup or
+ /// '' admin right in a channel
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task UnpinAllChatMessagesAsync(
+ this ITelegramBotClient botClient,
+ UnpinAllChatMessagesRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the
+ /// chat for this to work and must have the administrator
+ /// right in the supergroup. Returns on success.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task UnpinAllForumTopicMessagesAsync(
+ this ITelegramBotClient botClient,
+ UnpinAllForumTopicMessagesRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator
+ /// in the chat for this to work and must have the
+ /// administrator right in the supergroup.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task UnpinAllGeneralForumTopicMessagesAsync(
+ this ITelegramBotClient botClient,
+ UnpinAllGeneralForumTopicMessagesRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to remove a message from the list of pinned messages in a chat. If the chat is not
+ /// a private chat, the bot must be an administrator in the chat for this to work and must have the
+ /// '' admin right in a supergroup or
+ /// '' admin right in a channel
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task UnpinChatMessageAsync(
+ this ITelegramBotClient botClient,
+ UnpinChatMessageRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to copy messages of any kind. Service messages and invoice messages can't be copied.
+ /// The method is analogous to the method
+ /// , but the
+ /// copied message doesn't have a link to the original message.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// Returns the of the sent message on success.
+ public static async Task CopyMessageAsync(
+ this ITelegramBotClient botClient,
+ CopyMessageRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, 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
+ /// , but the
+ /// copied messages don't have a link to the original message. Album grouping is kept for copied messages.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, an array of of the sent messages is returned.
+ public static async Task CopyMessagesAsync(
+ this ITelegramBotClient botClient,
+ CopyMessagesRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to forward messages of any kind. Service messages can't be forwarded.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, the sent is returned.
+ public static async Task ForwardMessageAsync(
+ this ITelegramBotClient botClient,
+ ForwardMessageRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to forward multiple messages of any kind. If some of the specified messages can't be found
+ /// or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded.
+ /// Album grouping is kept for forwarded messages.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, an array of of the sent messages is returned.
+ public static async Task ForwardMessagesAsync(
+ this ITelegramBotClient botClient,
+ ForwardMessagesRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to edit live location messages. A location can be edited until its
+ /// expires or editing is explicitly disabled by a call to
+ /// .
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task EditInlineMessageLiveLocationAsync(
+ this ITelegramBotClient botClient,
+ EditInlineMessageLiveLocationRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to edit live location messages. A location can be edited until its
+ /// expires or editing is explicitly disabled by a call to
+ /// .
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success the edited is returned.
+ public static async Task EditMessageLiveLocationAsync(
+ this ITelegramBotClient botClient,
+ EditMessageLiveLocationRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to send point on the map.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, the sent is returned.
+ public static async Task SendLocationAsync(
+ this ITelegramBotClient botClient,
+ SendLocationRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to send information about a venue.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, the sent is returned.
+ ///
+ public static async Task SendVenueAsync(
+ this ITelegramBotClient botClient,
+ SendVenueRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to stop updating a live location message before
+ /// expires.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task StopInlineMessageLiveLocationAsync(
+ this ITelegramBotClient botClient,
+ StopInlineMessageLiveLocationRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to stop updating a live location message before
+ /// expires.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success the sent is returned.
+ public static async Task StopMessageLiveLocationAsync(
+ this ITelegramBotClient botClient,
+ StopMessageLiveLocationRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). Bots can currently
+ /// send animation files of up to 50 MB in size, this limit may be changed in the future.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, the sent is returned.
+ public static async Task SendAnimationAsync(
+ this ITelegramBotClient botClient,
+ SendAnimationRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to send audio files, if you want Telegram clients to display them in the music player.
+ /// Your audio must be in the .MP3 or .M4A format. Bots can currently send audio files of up to 50 MB in size,
+ /// this limit may be changed in the future.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, the sent is returned.
+ public static async Task SendAudioAsync(
+ this ITelegramBotClient botClient,
+ SendAudioRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method when you need to tell the user that something is happening on the bot’s side. The status is
+ /// set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
+ ///
+ ///
+ ///
+ /// The ImageBot needs some time to process a request and upload the
+ /// image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use
+ /// SendChatActionAsync
+ /// with = . The user will see a
+ /// “sending photo” status for the bot.
+ ///
+ ///
+ /// We only recommend using this method when a response from the bot will take a noticeable amount of
+ /// time to arrive.
+ ///
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task SendChatActionAsync(
+ this ITelegramBotClient botClient,
+ SendChatActionRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to send phone contacts.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, the sent is returned.
+ public static async Task SendContactAsync(
+ this ITelegramBotClient botClient,
+ SendContactRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to send an animated emoji that will display a random value.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, the sent is returned.
+ public static async Task SendDiceAsync(
+ this ITelegramBotClient botClient,
+ SendDiceRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to send general files. Bots can currently send files of any type of up to 50 MB in size,
+ /// this limit may be changed in the future.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, the sent is returned.
+ public static async Task SendDocumentAsync(
+ this ITelegramBotClient botClient,
+ SendDocumentRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, 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
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, an array of s that were sent is returned.
+ public static async Task SendMediaGroupAsync(
+ this ITelegramBotClient botClient,
+ SendMediaGroupRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to send text messages.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, the sent is returned.
+ public static async Task SendMessageAsync(
+ this ITelegramBotClient botClient,
+ SendMessageRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to send photos.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, the sent is returned.
+ public static async Task SendPhotoAsync(
+ this ITelegramBotClient botClient,
+ SendPhotoRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to send a native poll.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, the sent is returned.
+ public static async Task SendPollAsync(
+ this ITelegramBotClient botClient,
+ SendPollRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// As of v.4.0, Telegram clients
+ /// support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, the sent is returned.
+ public static async Task SendVideoNoteAsync(
+ this ITelegramBotClient botClient,
+ SendVideoNoteRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as
+ /// ). Bots can currently send video files of up to 50 MB in size, this limit may be
+ /// changed in the future.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, the sent is returned.
+ public static async Task SendVideoAsync(
+ this ITelegramBotClient botClient,
+ SendVideoRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to send audio files, if you want Telegram clients to display the file as a playable voice
+ /// message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent
+ /// as or ). Bots can currently send voice messages of up to 50 MB
+ /// in size, this limit may be changed in the future.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ /// On success, the sent is returned.
+ public static async Task SendVoiceAsync(
+ this ITelegramBotClient botClient,
+ SendVoiceRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to change the chosen reactions on a message. Service messages can't be reacted to.
+ /// Automatically forwarded messages from a channel to its discussion group have the same
+ /// available reactions as messages in the channel.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task SetMessageReactionAsync(
+ this ITelegramBotClient botClient,
+ SetMessageReactionRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///
+ /// Use this method to change the bot’s menu button in a private chat, or the default menu button.
+ ///
+ /// An instance of
+ /// Request parameters
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation
+ ///
+ public static async Task SetChatMenuButtonAsync(
+ this ITelegramBotClient botClient,
+ SetChatMenuButtonRequest request,
+ CancellationToken cancellationToken = default
+ ) =>
+ await botClient.ThrowIfNull()
+ .MakeRequestAsync(request, cancellationToken)
+ .ConfigureAwait(false);
+
+ ///