Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for v7.9 #53

Merged
merged 2 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 7.8 (as at July 31, 2024).
RxTelegram.Bot supports Telegram Bot API 7.9 (as at August 14, 2024).

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
49 changes: 49 additions & 0 deletions src/RxTelegram.Bot/ITelegramBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using RxTelegram.Bot.Interface.Games.Requests;
using RxTelegram.Bot.Interface.InlineMode;
using RxTelegram.Bot.Interface.Passport.Requests;
using RxTelegram.Bot.Interface.Payments;
using RxTelegram.Bot.Interface.Payments.Requests;
using RxTelegram.Bot.Interface.Reaction.Requests;
using RxTelegram.Bot.Interface.Setup;
Expand Down Expand Up @@ -1207,4 +1208,52 @@ Task<BusinessConnection> GetBusinessConnection(
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>Returns an array of <see cref="MessageIdObject"/> on success.</returns>
Task<MessageIdObject[]> CopyMessages(CopyMessages copyMessages, CancellationToken cancellationToken = default);

/// <summary>
/// Refunds a successful payment in Telegram Stars.
/// </summary>
/// <param name="refundStarPayment">Information about the payment</param>
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>Returns True on success.</returns>
Task<bool> RefundStarPayment(RefundStarPayment refundStarPayment, CancellationToken cancellationToken = default);

/// <summary>
/// Returns the bot's Telegram Star transactions in chronological order.
/// </summary>
/// <param name="getStarTransactions">Information about the transactions</param>
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>On success, returns a <see cref="StarTransactions"/> object.</returns>
Task<StarTransactions> GetStarTransactions(
GetStarTransactions getStarTransactions,
CancellationToken cancellationToken = default);

/// <summary>
/// Use this method to send paid media to channel chats.
/// </summary>
/// <param name="sendPaidMedia">Details for the media to send</param>
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>On success, the sent <see cref="Message"/> is returned.</returns>
Task<Message> SendPaidMedia(SendPaidMedia sendPaidMedia, CancellationToken cancellationToken = default);

/// <summary>
/// Use this method to create a subscription invite link for a channel chat.
/// The bot must have the can_invite_users administrator rights.
/// The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method <see cref="TelegramBot.RevokeChatInviteLink"/>.
/// </summary>
/// <param name="createChatSubscriptionInviteLink">Details for the invite link</param>
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>Returns the new invite link as a <see cref="ChatInviteLink"/> object.</returns>
Task<ChatInviteLink> CreateChatSubscriptionInviteLink(
CreateChatSubscriptionInviteLink createChatSubscriptionInviteLink,
CancellationToken cancellationToken = default);

/// <summary>
/// Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights
/// </summary>
/// <param name="editChatSubscriptionInviteLink">Details for the invite link</param>
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>Returns the new invite link as a <see cref="ChatInviteLink"/> object.</returns>
Task<ChatInviteLink> EditChatSubscriptionInviteLink(
EditChatSubscriptionInviteLink editChatSubscriptionInviteLink,
CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using RxTelegram.Bot.Interface.BaseTypes.Requests.Base;
using RxTelegram.Bot.Validation;

namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Chats;

/// <summary>
/// Use this method to create a subscription invite link for a channel chat.
/// The bot must have the can_invite_users administrator rights.
/// The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method <see cref="RevokeChatInviteLink"/>.
/// Returns the new invite link as a ChatInviteLink object.
/// </summary>
public class CreateChatSubscriptionInviteLink : BaseRequest
{
/// <summary>
/// Invite link name; 0-32 characters
/// </summary>
public string Name { get; set; }

/// <summary>
/// The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
/// </summary>
public int SubscriptionPeriod { get; set; }

/// <summary>
/// The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500
/// </summary>
public int SubscriptionPrice { get; set; }

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

namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Chats;

/// <summary>
/// Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights.
/// </summary>
public class EditChatSubscriptionInviteLink : BaseRequest
{
/// <summary>
/// The invite link to edit
/// </summary>
public string InviteLink { get; set; }

/// <summary>
/// Invite link name; 0-32 characters
/// </summary>
public string Name { get; set; }

protected override IValidationResult Validate() => this.CreateValidation();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Messages;
/// </summary>
public class SendPaidMedia : BaseTextRequest
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// The number of Telegram Stars that must be paid to buy access to the media
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using RxTelegram.Bot.Interface.BaseTypes;
using RxTelegram.Bot.Interface.BaseTypes.Enums;

Expand All @@ -22,4 +23,6 @@ public class TransactionPartnerUser : TransactionPartner
/// Optional. Bot-specified invoice payload
/// </summary>
public string InvoicePayload { get; set; }

public List<PaidMedia> PaidMedia { get; set; }
}
5 changes: 4 additions & 1 deletion src/RxTelegram.Bot/Interface/Reaction/Enums/ReactionType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ public enum ReactionType
Emoji,

[ImplementationType(typeof(ReactionTypeCustomEmoji))]
CustomEmoji
CustomEmoji,

[ImplementationType(typeof(ReactionTypePaid))]
Paid
}
6 changes: 6 additions & 0 deletions src/RxTelegram.Bot/Interface/Reaction/ReactionTypePaid.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace RxTelegram.Bot.Interface.Reaction;

public class ReactionTypePaid : ReactionType
{
public override Enums.ReactionType Type { get; set; } = Enums.ReactionType.Paid;
}
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>7.8.0</PackageVersion>
<PackageVersion>7.9.0</PackageVersion>
<PackageIcon>icon.png</PackageIcon>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
Expand Down
28 changes: 27 additions & 1 deletion src/RxTelegram.Bot/TelegramBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,9 @@ public Task<bool> RefundStarPayment(RefundStarPayment refundStarPayment, Cancell
/// <param name="getStarTransactions">Information about the transactions</param>
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>On success, returns a <see cref="StarTransactions"/> object.</returns>
public Task<StarTransactions> GetStarTransactions(GetStarTransactions getStarTransactions, CancellationToken cancellationToken = default) =>
public Task<StarTransactions> GetStarTransactions(
GetStarTransactions getStarTransactions,
CancellationToken cancellationToken = default) =>
Post<StarTransactions>("getStarTransactions", getStarTransactions, cancellationToken);

/// <summary>
Expand All @@ -1358,4 +1360,28 @@ public Task<StarTransactions> GetStarTransactions(GetStarTransactions getStarTra
/// <returns>On success, the sent <see cref="Message"/> is returned.</returns>
public Task<Message> SendPaidMedia(SendPaidMedia sendPaidMedia, CancellationToken cancellationToken = default) =>
Post<Message>("sendPaidMedia", sendPaidMedia, cancellationToken);

/// <summary>
/// Use this method to create a subscription invite link for a channel chat.
/// The bot must have the can_invite_users administrator rights.
/// The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method <see cref="RevokeChatInviteLink"/>.
/// </summary>
/// <param name="createChatSubscriptionInviteLink">Details for the invite link</param>
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>Returns the new invite link as a <see cref="ChatInviteLink"/> object.</returns>
public Task<ChatInviteLink> CreateChatSubscriptionInviteLink(
CreateChatSubscriptionInviteLink createChatSubscriptionInviteLink,
CancellationToken cancellationToken = default) =>
Post<ChatInviteLink>("createChatSubscriptionInviteLink", createChatSubscriptionInviteLink, cancellationToken);

/// <summary>
/// Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights
/// </summary>
/// <param name="editChatSubscriptionInviteLink">Details for the invite link</param>
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>Returns the new invite link as a <see cref="ChatInviteLink"/> object.</returns>
public Task<ChatInviteLink> EditChatSubscriptionInviteLink(
EditChatSubscriptionInviteLink editChatSubscriptionInviteLink,
CancellationToken cancellationToken = default) =>
Post<ChatInviteLink>("editChatSubscriptionInviteLink", editChatSubscriptionInviteLink, cancellationToken);
}
10 changes: 10 additions & 0 deletions src/RxTelegram.Bot/Validation/ValidationResultFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -655,4 +655,14 @@ public static ValidationResult<RefundStarPayment> CreateValidation(this RefundSt
public static ValidationResult<SendPaidMedia> CreateValidation(this SendPaidMedia value) =>
new ValidationResult<SendPaidMedia>(value).ValidateRequired(x => x.StarCount)
.ValidateRequired(x => x.Media);

public static ValidationResult<CreateChatSubscriptionInviteLink> CreateValidation(this CreateChatSubscriptionInviteLink value) =>
new ValidationResult<CreateChatSubscriptionInviteLink>(value).ValidateRequired(x => x.ChatId)
.ValidateRequired(x => x.Name)
.ValidateRequired(x => x.SubscriptionPeriod)
.ValidateRequired(x => x.SubscriptionPrice);

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