Skip to content
Open
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 8.3 (as at February 12, 2025).
RxTelegram.Bot supports Telegram Bot API 9.0 (as at April 11, 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
8 changes: 8 additions & 0 deletions src/RxTelegram.Bot/ITelegramBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1299,4 +1299,12 @@ Task<PreparedInlineMessage> SavePreparedInlineMessage(
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>Returns True on success.</returns>
Task<bool> SendGift(SendGift sendGift, CancellationToken cancellationToken = default);

/// <summary>
/// Gifts a Telegram Premium subscription to the given user.
/// </summary>
/// <param name="giftPremiumSubscription">Details for the premium subscription to gift.</param>
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
/// <returns>Returns True on success.</returns>
Task<bool> GiftPremiumSubscription(GiftPremiumSubscription giftPremiumSubscription, CancellationToken cancellationToken = default);
}
27 changes: 27 additions & 0 deletions src/RxTelegram.Bot/Interface/BaseTypes/AccpetedGiftTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace RxTelegram.Bot.Interface.BaseTypes;

/// <summary>
/// This object describes the types of gifts that can be gifted to a user or a chat.
/// </summary>
public class AccpetedGiftTypes
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class name 'AccpetedGiftTypes' contains a typo. It should be 'AcceptedGiftTypes' (missing 'c').

Suggested change
public class AccpetedGiftTypes
public class AcceptedGiftTypes

Copilot uses AI. Check for mistakes.

{
/// <summary>
/// True, if unlimited regular gifts are accepted
/// </summary>
public bool UnlimitedGifts { get; set; }

/// <summary>
/// True, if limited regular gifts are accepted
/// </summary>
public bool LimitedGifts { get; set; }

/// <summary>
/// True, if unique gifts or gifts that can be upgraded to unique for free are accepted
/// </summary>
public bool UniqueGifts { get; set; }

/// <summary>
/// True, if a Telegram Premium subscription is accepted
/// </summary>
public bool PremiumSubscription { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums;

public enum InputProfilePhotoTypes
{
Static,
Animated
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums;

public enum InputStoryContentTypes
{
Photo,
Video
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums;

namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia;

public interface InputProfilePhoto
{
/// <summary>
/// Type of the result
/// </summary>
public abstract InputProfilePhotoTypes Type { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums;

/// <summary>
/// An animated profile photo in the MPEG4 format.
/// </summary>
public class InputProfilePhotoAnimated : InputProfilePhoto
{
/// <summary>
/// Type of the result
/// </summary>
public InputProfilePhotoTypes Type { get; set; } = InputProfilePhotoTypes.Animated;

/// <summary>
/// The animated profile photo. Profile photos can't be reused and can only be uploaded as a new file,
/// so you can pass “attach://<file_attach_name>” if the photo was uploaded using multipart/form-data under <file_attach_name>.
/// </summary>
public string Animation { get; set; }

/// <summary>
/// Optional.
/// Timestamp in seconds of the frame that will be used as the static profile photo.
/// Defaults to 0.0.
/// </summary>
public double FrameTimestamp { get; set; } = 0.0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums;

namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia;

/// <summary>
/// A static profile photo in the .JPG format.
/// </summary>
public class InputProfilePhotoStatic : InputProfilePhoto
{
/// <summary>
/// Type of the profile photo, must be static
/// </summary>
public InputProfilePhotoTypes Type { get; set; } = InputProfilePhotoTypes.Static;

/// <summary>
/// The static profile photo. Profile photos can't be reused and can only be uploaded as a new file,
/// so you can pass “attach://file_attach_name” if the photo was uploaded using multipart/form-data under file_attach_name.
/// </summary>
public string Photo { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums;

namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia;

public interface InputStoryContent
{
/// <summary>
/// Type of the result
/// </summary>
public abstract InputStoryContentTypes Type { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums;

namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia;

/// <summary>
/// Describes a photo to post as a story.
/// </summary>
public class InputStoryContentPhoto : InputStoryContent
{
public InputStoryContentTypes Type { get; set; } = InputStoryContentTypes.Photo;

/// <summary>
/// The photo to post as a story. The photo must be of the size 1080x1920 and must not exceed 10 MB.
/// The photo can't be reused and can only be uploaded as a new file,
/// so you can pass “attach://<file_attach_name>” if the photo was uploaded using multipart/form-data under <file_attach_name>.
/// </summary>
public string Photo { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums;

namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia;

/// <summary>
/// Describes a video to post as a story.
/// </summary>
public class InputStoryContentVideo : InputStoryContent
{
public InputStoryContentTypes Type { get; set; } = InputStoryContentTypes.Video;

/// <summary>
/// The video to post as a story. The video must be of the size 720x1280, streamable, encoded with H.265 codec,
/// with key frames added each second in the MPEG4 format, and must not exceed 30 MB.
/// The video can't be reused and can only be uploaded as a new file, so you can pass “attach://<file_attach_name>”
/// if the video was uploaded using multipart/form-data under <file_attach_name>.
/// </summary>
public string Video { get; set; }

/// <summary>
/// Optional. Precise duration of the video in seconds; 0-60
/// </summary>
public double Duration { get; set; }

/// <summary>
/// Optional. Timestamp in seconds of the frame that will be used as the static cover for the story. Defaults to 0.0.
/// </summary>
public double CoverFrameTimestamp { get; set; } = 0.0;

/// <summary>
/// Optional. Pass True if the video has no sound
/// </summary>
public bool NoSound { get; set; } = false;
}
10 changes: 10 additions & 0 deletions src/RxTelegram.Bot/Interface/BaseTypes/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ public class Message
/// </summary>
public string AuthorSignature { get; set; }

/// <summary>
/// Optional. The number of Telegram Stars that were paid by the sender of the message to send it
/// </summary>
public long PaidStarCount { get; set; }

/// <summary>
/// Optional. For text messages, the actual UTF-8 text of the message
/// </summary>
Expand Down Expand Up @@ -416,6 +421,11 @@ public class Message
/// </summary>
public GiveawayCompleted GiveawayCompleted { get; set; }

/// <summary>
/// Optional. Service message: the price for paid messages has changed in the chat
/// </summary>
public PaidMessagePriceChanged PaidMessagePriceChanged { get; set; }

/// <summary>
/// Optional. Service message: video chat scheduled
/// </summary>
Expand Down
24 changes: 24 additions & 0 deletions src/RxTelegram.Bot/Interface/BaseTypes/OwnedGifts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Collections.Generic;

namespace RxTelegram.Bot.Interface.BaseTypes;

/// <summary>
/// Contains the list of gifts received and owned by a user or a chat.
/// </summary>
public class OwnedGifts
{
/// <summary>
/// The total number of gifts owned by the user or the chat
/// </summary>
public int TotalCount { get; set; }

/// <summary>
/// The list of gifts
/// </summary>
public List<OwnedGift> Gifts { get; set; }

/// <summary>
/// Offset for the next request. If empty, then there are no more results
/// </summary>
public string? NextOffset { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using RxTelegram.Bot.Interface.Validation;

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

public abstract class BaseBusinessRequest : BaseValidation
{
/// <summary>
/// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
/// </summary>
public string BusinessConnectionId { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Collections.Generic;
using RxTelegram.Bot.Interface.BaseTypes.Enums;
using RxTelegram.Bot.Interface.Validation;
using RxTelegram.Bot.Validation;

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

/// <summary>
/// Gifts a Telegram Premium subscription to the given user. Returns True on success.
/// </summary>
public class GiftPremiumSubscription : BaseValidation
{
/// <summary>
/// Unique identifier of the target user who will receive a Telegram Premium subscription
/// </summary>
public long UserId { get; set; }

/// <summary>
/// Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12
/// </summary>
public int MonthCount { get; set; }

/// <summary>
/// Number of Telegram Stars to pay for the Telegram Premium subscription;
/// must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months
/// </summary>
public int StarCount { get; set; }

/// <summary>
/// Text that will be shown along with the service message about the subscription; 0-128 characters
/// </summary>
public string Text { get; set; }

/// <summary>
/// Mode for parsing entities in the text. See formatting options for more details.
/// Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
/// </summary>
public ParseMode TextParseMode { get; set; }

/// <summary>
/// A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode.
/// Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
/// </summary>
public List<MessageEntity> TextEntities { get; set; }

protected override IValidationResult Validate() => this.CreateValidation();
}
18 changes: 18 additions & 0 deletions src/RxTelegram.Bot/Interface/BaseTypes/StarAmount.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace RxTelegram.Bot.Interface.BaseTypes;

/// <summary>
/// Describes an amount of Telegram Stars.
/// </summary>
public class StarAmount
{
/// <summary>
/// Integer amount of Telegram Stars, rounded to 0; can be negative
/// </summary>
public int Amount { get; set; }

/// <summary>
/// Optional. The number of 1/1000000000 shares of Telegram Stars;
/// from -999999999 to 999999999; can be negative if and only if amount is non-positive
/// </summary>
public int NanostarAmount { get; set; }
}
77 changes: 77 additions & 0 deletions src/RxTelegram.Bot/Interface/Business/BusinessBotRights.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
namespace RxTelegram.Bot.Interface.Business;

/// <summary>
/// Represents the rights of a business bot.
/// </summary>
public class BusinessBotRights
{
/// <summary>
/// Optional. True, if the bot can send and edit messages in the private chats that had incoming messages in the last 24 hours
/// </summary>
public bool? CanReply { get; set; }

/// <summary>
/// Optional. True, if the bot can mark incoming private messages as read
/// </summary>
public bool? CanReadMessages { get; set; }

/// <summary>
/// Optional. True, if the bot can delete messages sent by the bot
/// </summary>
public bool? CanDeleteSentMessages { get; set; }

/// <summary>
/// Optional. True, if the bot can delete all private messages in managed chats
/// </summary>
public bool? CanDeleteAllMessages { get; set; }

/// <summary>
/// Optional. True, if the bot can edit the first and last name of the business account
/// </summary>
public bool? CanEditName { get; set; }

/// <summary>
/// Optional. True, if the bot can edit the bio of the business account
/// </summary>
public bool? CanEditBio { get; set; }

/// <summary>
/// Optional. True, if the bot can edit the profile photo of the business account
/// </summary>
public bool? CanEditProfilePhoto { get; set; }

/// <summary>
/// Optional. True, if the bot can edit the username of the business account
/// </summary>
public bool? CanEditUsername { get; set; }

/// <summary>
/// Optional. True, if the bot can change the privacy settings pertaining to gifts for the business account
/// </summary>
public bool? CanChangeGiftSettings { get; set; }

/// <summary>
/// Optional. True, if the bot can view gifts and the amount of Telegram Stars owned by the business account
/// </summary>
public bool? CanViewGiftsAndStars { get; set; }

/// <summary>
/// Optional. True, if the bot can convert regular gifts owned by the business account to Telegram Stars
/// </summary>
public bool? CanConvertGiftsToStars { get; set; }

/// <summary>
/// Optional. True, if the bot can transfer and upgrade gifts owned by the business account
/// </summary>
public bool? CanTransferAndUpgradeGifts { get; set; }

/// <summary>
/// Optional. True, if the bot can transfer Telegram Stars received by the business account to its own account, or use them to upgrade and transfer gifts
/// </summary>
public bool? CanTransferStars { get; set; }

/// <summary>
/// Optional. True, if the bot can post, edit and delete stories on behalf of the business account
/// </summary>
public bool? CanManageStories { get; set; }
}
Loading
Loading