Skip to content

Commit

Permalink
Merge pull request #1405 from TelegramBots/develop
Browse files Browse the repository at this point in the history
added options.RetryThreshold & RetryCount (default 60s / 3 times) for automatic retry on 429
  • Loading branch information
wiz0u committed Aug 3, 2024
2 parents 67149b8 + 1d4810c commit 0f8afb4
Show file tree
Hide file tree
Showing 122 changed files with 115 additions and 1,281 deletions.
4 changes: 2 additions & 2 deletions .azure-pipelines/variables.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
variables:
variables:
- group: Integration Tests Variables
- name: versionPrefix
value: 21.8.0
value: 21.9.0
- name: versionSuffix
value: ''
- name: ciVersionSuffix
Expand Down
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: wiz0u
custom: ["https://www.buymeacoffee.com/wizou", "http://t.me/WTelegramBot?start=donate"]
8 changes: 0 additions & 8 deletions src/Telegram.Bot/Extend.Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,6 @@ public partial class BotCommandScope
public static BotCommandScopeChatMember ChatMember(ChatId chatId, long userId) => new() { ChatId = chatId, UserId = userId };
}

public partial class CallbackQuery
{
/// <summary>Indicates if the User requests a Game</summary>
[JsonIgnore]
[Obsolete("Use GameShortName != null")]
public bool IsGameQuery => GameShortName != default;
}

namespace ReplyMarkups
{
public partial class ReplyKeyboardMarkup
Expand Down
13 changes: 2 additions & 11 deletions src/Telegram.Bot/Polling/Abstractions/ReceiverOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public sealed class ReceiverOptions

/// <summary>
/// Indicates which <see cref="UpdateType"/>s are allowed to be received.
/// In case of <c>null</c> the previous setting will be used
/// In case of <see langword="null"/> the previous setting will be used
/// </summary>
public UpdateType[]? AllowedUpdates { get; set; }

/// <summary>
/// Limits the number of updates to be retrieved. Values between 1-100 are accepted.
/// Defaults to 100 when is set to <c>null</c>.
/// Defaults to 100 when is set to <see langword="null"/>.
/// </summary>
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown when the value doesn't satisfies constraints
Expand All @@ -47,15 +47,6 @@ public int? Limit
}
}

/// <summary>
/// Indicates if all pending <see cref="Update"/>s should be thrown out before start
/// polling. If set to <see langword="true"/> <see cref="AllowedUpdates"/> should be set to not
/// <c>null</c>, otherwise <see cref="AllowedUpdates"/> will effectively be set to
/// receive all <see cref="Update"/>s.
/// </summary>
[Obsolete($"This property will be removed in future updates, use {nameof(DropPendingUpdates)} instead")]
public bool ThrowPendingUpdates { get => DropPendingUpdates; set => DropPendingUpdates = value; }

/// <summary>
/// Indicates if all pending <see cref="Update"/>s should be thrown out before start
/// polling. If set to <see langword="true"/> <see cref="AllowedUpdates"/> should be set to not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ public partial class AnswerCallbackQueryRequest : RequestBase<bool>
/// <summary>The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.</summary>
public int? CacheTime { get; set; }

/// <summary>Initializes an instance of <see cref="AnswerCallbackQueryRequest"/></summary>
/// <param name="callbackQueryId">Unique identifier for the query to be answered</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public AnswerCallbackQueryRequest(string callbackQueryId) : this() => CallbackQueryId = callbackQueryId;

/// <summary>Instantiates a new <see cref="AnswerCallbackQueryRequest"/></summary>
public AnswerCallbackQueryRequest() : base("answerCallbackQuery") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ public partial class SetMyCommandsRequest : RequestBase<bool>
/// <summary>A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands</summary>
public string? LanguageCode { get; set; }

/// <summary>Initializes an instance of <see cref="SetMyCommandsRequest"/></summary>
/// <param name="commands">A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public SetMyCommandsRequest(IEnumerable<BotCommand> commands) : this() => Commands = commands;

/// <summary>Instantiates a new <see cref="SetMyCommandsRequest"/></summary>
public SetMyCommandsRequest() : base("setMyCommands") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ public partial class GetFileRequest : RequestBase<File>
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public required string FileId { get; set; }

/// <summary>Initializes an instance of <see cref="GetFileRequest"/></summary>
/// <param name="fileId">File identifier to get information about</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public GetFileRequest(string fileId) : this() => FileId = fileId;

/// <summary>Instantiates a new <see cref="GetFileRequest"/></summary>
public GetFileRequest() : base("getFile") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ public partial class GetUserProfilePhotosRequest : RequestBase<UserProfilePhotos
/// <summary>Limits the number of photos to be retrieved. Values between 1-100 are accepted. Defaults to 100.</summary>
public int? Limit { get; set; }

/// <summary>Initializes an instance of <see cref="GetUserProfilePhotosRequest"/></summary>
/// <param name="userId">Unique identifier of the target user</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public GetUserProfilePhotosRequest(long userId) : this() => UserId = userId;

/// <summary>Instantiates a new <see cref="GetUserProfilePhotosRequest"/></summary>
public GetUserProfilePhotosRequest() : base("getUserProfilePhotos") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ public partial class GetBusinessConnectionRequest : RequestBase<BusinessConnecti
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public required string BusinessConnectionId { get; set; }

/// <summary>Initializes an instance of <see cref="GetBusinessConnectionRequest"/></summary>
/// <param name="businessConnectionId">Unique identifier of the business connection</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public GetBusinessConnectionRequest(string businessConnectionId) : this() => BusinessConnectionId = businessConnectionId;

/// <summary>Instantiates a new <see cref="GetBusinessConnectionRequest"/></summary>
public GetBusinessConnectionRequest() : base("getBusinessConnection") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ public partial class GetUserChatBoostsRequest : RequestBase<UserChatBoosts>, ICh
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public required long UserId { get; set; }

/// <summary>Initializes an instance of <see cref="GetUserChatBoostsRequest"/></summary>
/// <param name="chatId">Unique identifier for the chat or username of the channel (in the format <c>@channelusername</c>)</param>
/// <param name="userId">Unique identifier of the target user</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public GetUserChatBoostsRequest(ChatId chatId, long userId) : this()
{
ChatId = chatId;
UserId = userId;
}

/// <summary>Instantiates a new <see cref="GetUserChatBoostsRequest"/></summary>
public GetUserChatBoostsRequest() : base("getUserChatBoosts") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ public partial class BanChatMemberRequest : RequestBase<bool>, IChatTargetable,
/// <summary>Pass <see langword="true"/> to delete all messages from the chat for the user that is being removed. If <see langword="false"/>, the user will be able to see messages in the group that were sent before the user was removed. Always <see langword="true"/> for supergroups and channels.</summary>
public bool RevokeMessages { get; set; }

/// <summary>Initializes an instance of <see cref="BanChatMemberRequest"/></summary>
/// <param name="chatId">Unique identifier for the target group or username of the target supergroup or channel (in the format <c>@channelusername</c>)</param>
/// <param name="userId">Unique identifier of the target user</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public BanChatMemberRequest(ChatId chatId, long userId) : this()
{
ChatId = chatId;
UserId = userId;
}

/// <summary>Instantiates a new <see cref="BanChatMemberRequest"/></summary>
public BanChatMemberRequest() : base("banChatMember") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ public partial class BanChatSenderChatRequest : RequestBase<bool>, IChatTargetab
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public required long SenderChatId { get; set; }

/// <summary>Initializes an instance of <see cref="BanChatSenderChatRequest"/></summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <c>@channelusername</c>)</param>
/// <param name="senderChatId">Unique identifier of the target sender chat</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public BanChatSenderChatRequest(ChatId chatId, long senderChatId) : this()
{
ChatId = chatId;
SenderChatId = senderChatId;
}

/// <summary>Instantiates a new <see cref="BanChatSenderChatRequest"/></summary>
public BanChatSenderChatRequest() : base("banChatSenderChat") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ public partial class ApproveChatJoinRequest : RequestBase<bool>, IChatTargetable
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public required long UserId { get; set; }

/// <summary>Initializes an instance of <see cref="ApproveChatJoinRequest"/></summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <c>@channelusername</c>)</param>
/// <param name="userId">Unique identifier of the target user</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public ApproveChatJoinRequest(ChatId chatId, long userId) : this()
{
ChatId = chatId;
UserId = userId;
}

/// <summary>Instantiates a new <see cref="ApproveChatJoinRequest"/></summary>
public ApproveChatJoinRequest() : base("approveChatJoinRequest") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ public partial class CreateChatInviteLinkRequest : RequestBase<ChatInviteLink>,
/// <summary><see langword="true"/>, if users joining the chat via the link need to be approved by chat administrators. If <see langword="true"/>, <see cref="MemberLimit">MemberLimit</see> can't be specified</summary>
public bool CreatesJoinRequest { get; set; }

/// <summary>Initializes an instance of <see cref="CreateChatInviteLinkRequest"/></summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <c>@channelusername</c>)</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public CreateChatInviteLinkRequest(ChatId chatId) : this() => ChatId = chatId;

/// <summary>Instantiates a new <see cref="CreateChatInviteLinkRequest"/></summary>
public CreateChatInviteLinkRequest() : base("createChatInviteLink") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ public partial class DeclineChatJoinRequest : RequestBase<bool>, IChatTargetable
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public required long UserId { get; set; }

/// <summary>Initializes an instance of <see cref="DeclineChatJoinRequest"/></summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <c>@channelusername</c>)</param>
/// <param name="userId">Unique identifier of the target user</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public DeclineChatJoinRequest(ChatId chatId, long userId) : this()
{
ChatId = chatId;
UserId = userId;
}

/// <summary>Instantiates a new <see cref="DeclineChatJoinRequest"/></summary>
public DeclineChatJoinRequest() : base("declineChatJoinRequest") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@ public partial class EditChatInviteLinkRequest : RequestBase<ChatInviteLink>, IC
/// <summary><see langword="true"/>, if users joining the chat via the link need to be approved by chat administrators. If <see langword="true"/>, <see cref="MemberLimit">MemberLimit</see> can't be specified</summary>
public bool CreatesJoinRequest { get; set; }

/// <summary>Initializes an instance of <see cref="EditChatInviteLinkRequest"/></summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <c>@channelusername</c>)</param>
/// <param name="inviteLink">The invite link to edit</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public EditChatInviteLinkRequest(ChatId chatId, string inviteLink) : this()
{
ChatId = chatId;
InviteLink = inviteLink;
}

/// <summary>Instantiates a new <see cref="EditChatInviteLinkRequest"/></summary>
public EditChatInviteLinkRequest() : base("editChatInviteLink") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ public partial class ExportChatInviteLinkRequest : RequestBase<string>, IChatTar
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public required ChatId ChatId { get; set; }

/// <summary>Initializes an instance of <see cref="ExportChatInviteLinkRequest"/></summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <c>@channelusername</c>)</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public ExportChatInviteLinkRequest(ChatId chatId) : this() => ChatId = chatId;

/// <summary>Instantiates a new <see cref="ExportChatInviteLinkRequest"/></summary>
public ExportChatInviteLinkRequest() : base("exportChatInviteLink") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ public partial class RevokeChatInviteLinkRequest : RequestBase<ChatInviteLink>,
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public required string InviteLink { get; set; }

/// <summary>Initializes an instance of <see cref="RevokeChatInviteLinkRequest"/></summary>
/// <param name="chatId">Unique identifier of the target chat or username of the target channel (in the format <c>@channelusername</c>)</param>
/// <param name="inviteLink">The invite link to revoke</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public RevokeChatInviteLinkRequest(ChatId chatId, string inviteLink) : this()
{
ChatId = chatId;
InviteLink = inviteLink;
}

/// <summary>Instantiates a new <see cref="RevokeChatInviteLinkRequest"/></summary>
public RevokeChatInviteLinkRequest() : base("revokeChatInviteLink") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ public partial class CloseForumTopicRequest : RequestBase<bool>, IChatTargetable
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public required int MessageThreadId { get; set; }

/// <summary>Initializes an instance of <see cref="CloseForumTopicRequest"/></summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target supergroup (in the format <c>@supergroupusername</c>)</param>
/// <param name="messageThreadId">Unique identifier for the target message thread of the forum topic</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public CloseForumTopicRequest(ChatId chatId, int messageThreadId) : this()
{
ChatId = chatId;
MessageThreadId = messageThreadId;
}

/// <summary>Instantiates a new <see cref="CloseForumTopicRequest"/></summary>
public CloseForumTopicRequest() : base("closeForumTopic") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ public partial class CloseGeneralForumTopicRequest : RequestBase<bool>, IChatTar
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public required ChatId ChatId { get; set; }

/// <summary>Initializes an instance of <see cref="CloseGeneralForumTopicRequest"/></summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target supergroup (in the format <c>@supergroupusername</c>)</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public CloseGeneralForumTopicRequest(ChatId chatId) : this() => ChatId = chatId;

/// <summary>Instantiates a new <see cref="CloseGeneralForumTopicRequest"/></summary>
public CloseGeneralForumTopicRequest() : base("closeGeneralForumTopic") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@ public partial class CreateForumTopicRequest : RequestBase<ForumTopic>, IChatTar
/// <summary>Unique identifier of the custom emoji shown as the topic icon. Use <see cref="TelegramBotClientExtensions.GetForumTopicIconStickersAsync">GetForumTopicIconStickers</see> to get all allowed custom emoji identifiers.</summary>
public string? IconCustomEmojiId { get; set; }

/// <summary>Initializes an instance of <see cref="CreateForumTopicRequest"/></summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target supergroup (in the format <c>@supergroupusername</c>)</param>
/// <param name="name">Topic name, 1-128 characters</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public CreateForumTopicRequest(ChatId chatId, string name) : this()
{
ChatId = chatId;
Name = name;
}

/// <summary>Instantiates a new <see cref="CreateForumTopicRequest"/></summary>
public CreateForumTopicRequest() : base("createForumTopic") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ public partial class DeleteChatPhotoRequest : RequestBase<bool>, IChatTargetable
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public required ChatId ChatId { get; set; }

/// <summary>Initializes an instance of <see cref="DeleteChatPhotoRequest"/></summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target channel (in the format <c>@channelusername</c>)</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public DeleteChatPhotoRequest(ChatId chatId) : this() => ChatId = chatId;

/// <summary>Instantiates a new <see cref="DeleteChatPhotoRequest"/></summary>
public DeleteChatPhotoRequest() : base("deleteChatPhoto") { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ public partial class DeleteChatStickerSetRequest : RequestBase<bool>, IChatTarge
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public required ChatId ChatId { get; set; }

/// <summary>Initializes an instance of <see cref="DeleteChatStickerSetRequest"/></summary>
/// <param name="chatId">Unique identifier for the target chat or username of the target supergroup (in the format <c>@supergroupusername</c>)</param>
[Obsolete("Use parameterless constructor with required properties")]
[SetsRequiredMembers]
public DeleteChatStickerSetRequest(ChatId chatId) : this() => ChatId = chatId;

/// <summary>Instantiates a new <see cref="DeleteChatStickerSetRequest"/></summary>
public DeleteChatStickerSetRequest() : base("deleteChatStickerSet") { }
}
Loading

0 comments on commit 0f8afb4

Please sign in to comment.