Skip to content

Commit

Permalink
Merge pull request #67 from RxTelegram/v8.2.0
Browse files Browse the repository at this point in the history
Add support for api v8.2
  • Loading branch information
niklasweimann authored Jan 4, 2025
2 parents 20f621b + 479ab5c commit 2e8492b
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=RxTelegram_RxTelegram.Bot&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=RxTelegram_RxTelegram.Bot)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=RxTelegram_RxTelegram.Bot&metric=coverage)](https://sonarcloud.io/summary/new_code?id=RxTelegram_RxTelegram.Bot)

RxTelegram.Bot supports Telegram Bot API 8.1 (as at December 4, 2024).
RxTelegram.Bot supports Telegram Bot API 8.2 (as at January 1, 2025).

This is a reactive designed .NET Library for the Telegram Bot API. It works with the official [Reactive Extentions](https://github.com/dotnet/reactive).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ public class InlineQueryResultArticle : BaseInlineQueryResultMedia
/// </summary>
public string Url { get; set; }

/// <summary>
/// Optional.
/// Pass True, if you don't want the URL to be shown in the message
/// </summary>
public bool? HideUrl { get; set; }

/// <summary>
/// Optional.
/// Short description of the result
Expand All @@ -46,4 +40,4 @@ public class InlineQueryResultArticle : BaseInlineQueryResultMedia
public int? ThumbnailHeight { get; set; }

protected override IValidationResult Validate() => this.CreateValidation();
}
}
5 changes: 5 additions & 0 deletions src/RxTelegram.Bot/Interface/Stickers/Gift.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public class Gift
/// </summary>
public int StarCount { get; set; }

/// <summary>
/// Optional. The number of Telegram Stars that must be paid to upgrade the gift to a unique one
/// </summary>
public int? UpgradeStarCount { get; set; }

/// <summary>
/// Optional. The total number of the gifts of this type that can be sent; for limited gifts only
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using RxTelegram.Bot.Interface.BaseTypes;
using RxTelegram.Bot.Interface.Validation;
using RxTelegram.Bot.Validation;

namespace RxTelegram.Bot.Interface.Stickers.Requests;

/// <summary>
/// Removes verification from a chat that is currently verified on behalf of the organization represented by the bot.
/// Returns True on success.
/// </summary>
public class RemoveChatVerification : BaseValidation
{
/// <summary>
/// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
/// </summary>
public ChatId ChatId { get; set; }

protected override IValidationResult Validate() => this.CreateValidation();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using RxTelegram.Bot.Interface.Validation;
using RxTelegram.Bot.Validation;

namespace RxTelegram.Bot.Interface.Stickers.Requests;

/// <summary>
/// Removes verification from a user who is currently verified on behalf of the organization represented by the bot.
/// Returns True on success.
/// </summary>
public class RemoveUserVerification : BaseValidation
{
/// <summary>
/// User identifier of the user to be removed
/// </summary>
public long UserId { get; set; }

protected override IValidationResult Validate() => this.CreateValidation();
}
5 changes: 5 additions & 0 deletions src/RxTelegram.Bot/Interface/Stickers/Requests/SendGift.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public class SendGift : BaseValidation
/// </summary>
public string GiftId { get; set; }

/// <summary>
/// Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver
/// </summary>
public bool PayForUpgrade { get; set; }

/// <summary>
/// Text that will be shown along with the gift; 0-255 characters
/// </summary>
Expand Down
24 changes: 24 additions & 0 deletions src/RxTelegram.Bot/Interface/Stickers/Requests/VerifyChat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using RxTelegram.Bot.Interface.BaseTypes;
using RxTelegram.Bot.Interface.Validation;
using RxTelegram.Bot.Validation;

namespace RxTelegram.Bot.Interface.Stickers.Requests;

/// <summary>
/// Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success.
/// </summary>
public class VerifyChat : BaseValidation
{
/// <summary>
/// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
/// </summary>
public ChatId ChatId { get; set; }

/// <summary>
/// Custom description for the verification; 0-70 characters.
/// Must be empty if the organization isn't allowed to provide a custom verification description.
/// </summary>
public string CustomDescription { get; set; }

protected override IValidationResult Validate() => this.CreateValidation();
}
23 changes: 23 additions & 0 deletions src/RxTelegram.Bot/Interface/Stickers/Requests/VerifyUser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using RxTelegram.Bot.Interface.Validation;
using RxTelegram.Bot.Validation;

namespace RxTelegram.Bot.Interface.Stickers.Requests;

/// <summary>
/// Verifies a user on behalf of the organization which is represented by the bot. Returns True on success.
/// </summary>
public class VerifyUser : BaseValidation
{
/// <summary>
/// User identifier of the user to be verified
/// </summary>
public long UserId { get; set; }

/// <summary>
/// Custom description for the verification; 0-70 characters.
/// Must be empty if the organization isn't allowed to provide a custom verification description.
/// </summary>
public string CustomDescription { get; set; }

protected override IValidationResult Validate() => this.CreateValidation();
}
2 changes: 1 addition & 1 deletion src/RxTelegram.Bot/RxTelegram.Bot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<RepositoryUrl>https://github.com/RxTelegram/RxTelegram.Bot</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>Telegram;Bot;Api;Rx;Reactive;Observable;RxTelegram;RxTelegram.Bot</PackageTags>
<PackageVersion>8.1.0</PackageVersion>
<PackageVersion>8.2.0</PackageVersion>
<PackageIcon>icon.png</PackageIcon>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
Expand Down
38 changes: 38 additions & 0 deletions src/RxTelegram.Bot/TelegramBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1432,4 +1432,42 @@ public Task<GiftsObject> GetAvailableGifts(CancellationToken cancellationToken =
/// <returns>Returns True on success.</returns>
public Task<bool> SendGift(SendGift sendGift, CancellationToken cancellationToken = default) =>
Post<bool>("sendGift", sendGift, cancellationToken);

/// <summary>
/// Verifies a user on behalf of the organization which is represented by the bot. Returns True on success.
/// </summary>
/// <param name="verifyUser">The user to verify</param>
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>Returns True on success.</returns>
public Task<bool> VerifyUser(VerifyUser verifyUser, CancellationToken cancellationToken = default) =>
Post<bool>("verifyUser", verifyUser, cancellationToken);

/// <summary>
/// Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success.
/// </summary>
/// <param name="verifyChat">The chat to verify</param>
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>Returns True on success.</returns>
public Task<bool> VerifyChat(VerifyChat verifyChat, CancellationToken cancellationToken = default) =>
Post<bool>("verifyChat", verifyChat, cancellationToken);

/// <summary>
/// Removes verification from a user who is currently verified on behalf of the organization represented by the bot.
/// Returns True on success.
/// </summary>
/// <param name="removeUserVerification">The user to remove verification from</param>
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>Returns True on success.</returns>
public Task<bool> RemoveUserVerification(RemoveUserVerification removeUserVerification, CancellationToken cancellationToken = default) =>
Post<bool>("removeUserVerification", removeUserVerification, cancellationToken);

/// <summary>
/// Removes verification from a chat that is currently verified on behalf of the organization represented by the bot.
/// Returns True on success.
/// </summary>
/// <param name="removeChatVerification">The chat to remove verification from</param>
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>Returns True on success.</returns>
public Task<bool> RemoveChatVerification(RemoveChatVerification removeChatVerification, CancellationToken cancellationToken = default) =>
Post<bool>("removeChatVerification", removeChatVerification, cancellationToken);
}
12 changes: 12 additions & 0 deletions src/RxTelegram.Bot/Validation/ValidationResultFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -684,4 +684,16 @@ public static ValidationResult<SavePreparedInlineMessage> CreateValidation(this
public static ValidationResult<SendGift> CreateValidation(this SendGift value) => new ValidationResult<SendGift>(value)
.ValidateRequired(x => x.UserId)
.ValidateRequired(x => x.GiftId);

public static ValidationResult<VerifyUser> CreateValidation(this VerifyUser value) =>
new ValidationResult<VerifyUser>(value).ValidateRequired(x => x.UserId);

public static ValidationResult<VerifyChat> CreateValidation(this VerifyChat value) =>
new ValidationResult<VerifyChat>(value).ValidateRequired(x => x.ChatId);

public static ValidationResult<RemoveUserVerification> CreateValidation(this RemoveUserVerification value) =>
new ValidationResult<RemoveUserVerification>(value).ValidateRequired(x => x.UserId);

public static ValidationResult<RemoveChatVerification> CreateValidation(this RemoveChatVerification value) =>
new ValidationResult<RemoveChatVerification>(value).ValidateRequired(x => x.ChatId);
}

0 comments on commit 2e8492b

Please sign in to comment.