diff --git a/README.md b/README.md index bdf770c..9e4acd6 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/src/RxTelegram.Bot/ITelegramBot.cs b/src/RxTelegram.Bot/ITelegramBot.cs index d31c7d5..ddfd62e 100644 --- a/src/RxTelegram.Bot/ITelegramBot.cs +++ b/src/RxTelegram.Bot/ITelegramBot.cs @@ -1299,4 +1299,12 @@ Task SavePreparedInlineMessage( /// Propagates notification that operations should be canceled. /// Returns True on success. Task SendGift(SendGift sendGift, CancellationToken cancellationToken = default); + + /// + /// Gifts a Telegram Premium subscription to the given user. + /// + /// Details for the premium subscription to gift. + /// Propagates notification that operations should be canceled. + /// Returns True on success. + Task GiftPremiumSubscription(GiftPremiumSubscription giftPremiumSubscription, CancellationToken cancellationToken = default); } diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/AccpetedGiftTypes.cs b/src/RxTelegram.Bot/Interface/BaseTypes/AccpetedGiftTypes.cs new file mode 100644 index 0000000..329d38f --- /dev/null +++ b/src/RxTelegram.Bot/Interface/BaseTypes/AccpetedGiftTypes.cs @@ -0,0 +1,27 @@ +namespace RxTelegram.Bot.Interface.BaseTypes; + +/// +/// This object describes the types of gifts that can be gifted to a user or a chat. +/// +public class AccpetedGiftTypes +{ + /// + /// True, if unlimited regular gifts are accepted + /// + public bool UnlimitedGifts { get; set; } + + /// + /// True, if limited regular gifts are accepted + /// + public bool LimitedGifts { get; set; } + + /// + /// True, if unique gifts or gifts that can be upgraded to unique for free are accepted + /// + public bool UniqueGifts { get; set; } + + /// + /// True, if a Telegram Premium subscription is accepted + /// + public bool PremiumSubscription { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/Enums/InputProfilePhotoTypes.cs b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/Enums/InputProfilePhotoTypes.cs new file mode 100644 index 0000000..c79a236 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/Enums/InputProfilePhotoTypes.cs @@ -0,0 +1,7 @@ +namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums; + +public enum InputProfilePhotoTypes +{ + Static, + Animated +} diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/Enums/InputStoryContentTypes.cs b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/Enums/InputStoryContentTypes.cs new file mode 100644 index 0000000..820fbc0 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/Enums/InputStoryContentTypes.cs @@ -0,0 +1,7 @@ +namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums; + +public enum InputStoryContentTypes +{ + Photo, + Video +} diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputProfilePhoto.cs b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputProfilePhoto.cs new file mode 100644 index 0000000..0995604 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputProfilePhoto.cs @@ -0,0 +1,11 @@ +using RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums; + +namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia; + +public interface InputProfilePhoto +{ + /// + /// Type of the result + /// + public abstract InputProfilePhotoTypes Type { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputProfilePhotoAnimated.cs b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputProfilePhotoAnimated.cs new file mode 100644 index 0000000..dd1dad1 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputProfilePhotoAnimated.cs @@ -0,0 +1,25 @@ +namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums; + +/// +/// An animated profile photo in the MPEG4 format. +/// +public class InputProfilePhotoAnimated : InputProfilePhoto +{ + /// + /// Type of the result + /// + public InputProfilePhotoTypes Type { get; set; } = InputProfilePhotoTypes.Animated; + + /// + /// The animated profile photo. Profile photos can't be reused and can only be uploaded as a new file, + /// so you can pass “attach://” if the photo was uploaded using multipart/form-data under . + /// + public string Animation { get; set; } + + /// + /// Optional. + /// Timestamp in seconds of the frame that will be used as the static profile photo. + /// Defaults to 0.0. + /// + public double FrameTimestamp { get; set; } = 0.0; +} diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputProfilePhotoStatic.cs b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputProfilePhotoStatic.cs new file mode 100644 index 0000000..f95bf30 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputProfilePhotoStatic.cs @@ -0,0 +1,20 @@ +using RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums; + +namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia; + +/// +/// A static profile photo in the .JPG format. +/// +public class InputProfilePhotoStatic : InputProfilePhoto +{ + /// + /// Type of the profile photo, must be static + /// + public InputProfilePhotoTypes Type { get; set; } = InputProfilePhotoTypes.Static; + + /// + /// 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. + /// + public string Photo { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputStoryContent.cs b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputStoryContent.cs new file mode 100644 index 0000000..a25ae3c --- /dev/null +++ b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputStoryContent.cs @@ -0,0 +1,11 @@ +using RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums; + +namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia; + +public interface InputStoryContent +{ + /// + /// Type of the result + /// + public abstract InputStoryContentTypes Type { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputStoryContentPhoto.cs b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputStoryContentPhoto.cs new file mode 100644 index 0000000..891b011 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputStoryContentPhoto.cs @@ -0,0 +1,18 @@ +using RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums; + +namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia; + +/// +/// Describes a photo to post as a story. +/// +public class InputStoryContentPhoto : InputStoryContent +{ + public InputStoryContentTypes Type { get; set; } = InputStoryContentTypes.Photo; + + /// + /// 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://” if the photo was uploaded using multipart/form-data under . + /// + public string Photo { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputStoryContentVideo.cs b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputStoryContentVideo.cs new file mode 100644 index 0000000..a43042b --- /dev/null +++ b/src/RxTelegram.Bot/Interface/BaseTypes/InputMedia/InputStoryContentVideo.cs @@ -0,0 +1,34 @@ +using RxTelegram.Bot.Interface.BaseTypes.InputMedia.Enums; + +namespace RxTelegram.Bot.Interface.BaseTypes.InputMedia; + +/// +/// Describes a video to post as a story. +/// +public class InputStoryContentVideo : InputStoryContent +{ + public InputStoryContentTypes Type { get; set; } = InputStoryContentTypes.Video; + + /// + /// 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://” + /// if the video was uploaded using multipart/form-data under . + /// + public string Video { get; set; } + + /// + /// Optional. Precise duration of the video in seconds; 0-60 + /// + public double Duration { get; set; } + + /// + /// Optional. Timestamp in seconds of the frame that will be used as the static cover for the story. Defaults to 0.0. + /// + public double CoverFrameTimestamp { get; set; } = 0.0; + + /// + /// Optional. Pass True if the video has no sound + /// + public bool NoSound { get; set; } = false; +} diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/Message.cs b/src/RxTelegram.Bot/Interface/BaseTypes/Message.cs index 1254a06..b026f62 100644 --- a/src/RxTelegram.Bot/Interface/BaseTypes/Message.cs +++ b/src/RxTelegram.Bot/Interface/BaseTypes/Message.cs @@ -139,6 +139,11 @@ public class Message /// public string AuthorSignature { get; set; } + /// + /// Optional. The number of Telegram Stars that were paid by the sender of the message to send it + /// + public long PaidStarCount { get; set; } + /// /// Optional. For text messages, the actual UTF-8 text of the message /// @@ -416,6 +421,11 @@ public class Message /// public GiveawayCompleted GiveawayCompleted { get; set; } + /// + /// Optional. Service message: the price for paid messages has changed in the chat + /// + public PaidMessagePriceChanged PaidMessagePriceChanged { get; set; } + /// /// Optional. Service message: video chat scheduled /// diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/OwnedGifts.cs b/src/RxTelegram.Bot/Interface/BaseTypes/OwnedGifts.cs new file mode 100644 index 0000000..da9820c --- /dev/null +++ b/src/RxTelegram.Bot/Interface/BaseTypes/OwnedGifts.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; + +namespace RxTelegram.Bot.Interface.BaseTypes; + +/// +/// Contains the list of gifts received and owned by a user or a chat. +/// +public class OwnedGifts +{ + /// + /// The total number of gifts owned by the user or the chat + /// + public int TotalCount { get; set; } + + /// + /// The list of gifts + /// + public List Gifts { get; set; } + + /// + /// Offset for the next request. If empty, then there are no more results + /// + public string? NextOffset { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/Requests/Base/BaseBusinessRequest.cs b/src/RxTelegram.Bot/Interface/BaseTypes/Requests/Base/BaseBusinessRequest.cs new file mode 100644 index 0000000..34d108b --- /dev/null +++ b/src/RxTelegram.Bot/Interface/BaseTypes/Requests/Base/BaseBusinessRequest.cs @@ -0,0 +1,11 @@ +using RxTelegram.Bot.Interface.Validation; + +namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Base; + +public abstract class BaseBusinessRequest : BaseValidation +{ + /// + /// Unique identifier for the target chat or username of the target channel (in the format @channelusername) + /// + public string BusinessConnectionId { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/Requests/Messages/GiftPremiumSubscription.cs b/src/RxTelegram.Bot/Interface/BaseTypes/Requests/Messages/GiftPremiumSubscription.cs new file mode 100644 index 0000000..d989c04 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/BaseTypes/Requests/Messages/GiftPremiumSubscription.cs @@ -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; + +/// +/// Gifts a Telegram Premium subscription to the given user. Returns True on success. +/// +public class GiftPremiumSubscription : BaseValidation +{ + /// + /// Unique identifier of the target user who will receive a Telegram Premium subscription + /// + public long UserId { get; set; } + + /// + /// Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12 + /// + public int MonthCount { get; set; } + + /// + /// 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 + /// + public int StarCount { get; set; } + + /// + /// Text that will be shown along with the service message about the subscription; 0-128 characters + /// + public string Text { get; set; } + + /// + /// 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. + /// + public ParseMode TextParseMode { get; set; } + + /// + /// 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. + /// + public List TextEntities { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/BaseTypes/StarAmount.cs b/src/RxTelegram.Bot/Interface/BaseTypes/StarAmount.cs new file mode 100644 index 0000000..004b888 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/BaseTypes/StarAmount.cs @@ -0,0 +1,18 @@ +namespace RxTelegram.Bot.Interface.BaseTypes; + +/// +/// Describes an amount of Telegram Stars. +/// +public class StarAmount +{ + /// + /// Integer amount of Telegram Stars, rounded to 0; can be negative + /// + public int Amount { get; set; } + + /// + /// 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 + /// + public int NanostarAmount { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Business/BusinessBotRights.cs b/src/RxTelegram.Bot/Interface/Business/BusinessBotRights.cs new file mode 100644 index 0000000..e711ab6 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/BusinessBotRights.cs @@ -0,0 +1,77 @@ +namespace RxTelegram.Bot.Interface.Business; + +/// +/// Represents the rights of a business bot. +/// +public class BusinessBotRights +{ + /// + /// Optional. True, if the bot can send and edit messages in the private chats that had incoming messages in the last 24 hours + /// + public bool? CanReply { get; set; } + + /// + /// Optional. True, if the bot can mark incoming private messages as read + /// + public bool? CanReadMessages { get; set; } + + /// + /// Optional. True, if the bot can delete messages sent by the bot + /// + public bool? CanDeleteSentMessages { get; set; } + + /// + /// Optional. True, if the bot can delete all private messages in managed chats + /// + public bool? CanDeleteAllMessages { get; set; } + + /// + /// Optional. True, if the bot can edit the first and last name of the business account + /// + public bool? CanEditName { get; set; } + + /// + /// Optional. True, if the bot can edit the bio of the business account + /// + public bool? CanEditBio { get; set; } + + /// + /// Optional. True, if the bot can edit the profile photo of the business account + /// + public bool? CanEditProfilePhoto { get; set; } + + /// + /// Optional. True, if the bot can edit the username of the business account + /// + public bool? CanEditUsername { get; set; } + + /// + /// Optional. True, if the bot can change the privacy settings pertaining to gifts for the business account + /// + public bool? CanChangeGiftSettings { get; set; } + + /// + /// Optional. True, if the bot can view gifts and the amount of Telegram Stars owned by the business account + /// + public bool? CanViewGiftsAndStars { get; set; } + + /// + /// Optional. True, if the bot can convert regular gifts owned by the business account to Telegram Stars + /// + public bool? CanConvertGiftsToStars { get; set; } + + /// + /// Optional. True, if the bot can transfer and upgrade gifts owned by the business account + /// + public bool? CanTransferAndUpgradeGifts { get; set; } + + /// + /// 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 + /// + public bool? CanTransferStars { get; set; } + + /// + /// Optional. True, if the bot can post, edit and delete stories on behalf of the business account + /// + public bool? CanManageStories { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Business/BusinessConnection.cs b/src/RxTelegram.Bot/Interface/Business/BusinessConnection.cs index 39be229..0114837 100644 --- a/src/RxTelegram.Bot/Interface/Business/BusinessConnection.cs +++ b/src/RxTelegram.Bot/Interface/Business/BusinessConnection.cs @@ -32,7 +32,7 @@ public class BusinessConnection /// /// True, if the bot can act on behalf of the business account in chats that were active in the last 24 hours /// - public bool CanReply { get; set; } + public BusinessBotRights Rights { get; set; } /// /// True, if the connection is active diff --git a/src/RxTelegram.Bot/Interface/Business/Requests/ConvertGiftToStars.cs b/src/RxTelegram.Bot/Interface/Business/Requests/ConvertGiftToStars.cs new file mode 100644 index 0000000..bfef953 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/Requests/ConvertGiftToStars.cs @@ -0,0 +1,17 @@ +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Business.Requests; + +/// +/// Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success. +/// +public class ConvertGiftToStars : BaseBusinessRequest +{ + /// + /// Unique identifier of the regular gift that should be converted to Telegram Stars + /// + public string OwnedGiftId { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Business/Requests/DeleteBusinessMessages.cs b/src/RxTelegram.Bot/Interface/Business/Requests/DeleteBusinessMessages.cs new file mode 100644 index 0000000..886cbc5 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/Requests/DeleteBusinessMessages.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Interface.Validation; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Business.Requests; + +/// +/// Delete messages on behalf of a business account. +/// Requires the can_delete_sent_messages business bot right to delete messages sent by the bot itself, +/// or the can_delete_all_messages business bot right to delete any message. +/// +public class DeleteBusinessMessages : BaseBusinessRequest +{ + /// + /// Required + /// A JSON-serialized list of 1-100 identifiers of messages to delete. + /// All messages must be from the same chat. See for limitations on which messages can be deleted + /// + public List MessageIds { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Business/Requests/GetBusinessAccountGifts.cs b/src/RxTelegram.Bot/Interface/Business/Requests/GetBusinessAccountGifts.cs new file mode 100644 index 0000000..9b3371b --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/Requests/GetBusinessAccountGifts.cs @@ -0,0 +1,53 @@ +namespace RxTelegram.Bot.Interface.Business.Requests; + +/// +/// Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. +/// Returns OwnedGifts on success. +/// +public class GetBusinessAccountGifts +{ + /// + /// Unique identifier of the business connection + /// + public string BusinessConnectionId { get; set; } + + /// + /// Pass True to exclude gifts that aren't saved to the account's profile page + /// + public bool? ExcludeUnsaved { get; set; } + + /// + /// Pass True to exclude gifts that are saved to the account's profile page + /// + public bool? ExcludeSaved { get; set; } + + /// + /// Pass True to exclude gifts that can be purchased an unlimited number of times + /// + public bool? ExcludeUnlimited { get; set; } + + /// + /// Pass True to exclude gifts that can be purchased a limited number of times + /// + public bool? ExcludeLimited { get; set; } + + /// + /// Pass True to exclude unique gifts + /// + public bool? ExcludeUnique { get; set; } + + /// + /// Pass True to sort results by gift price instead of send date. Sorting is applied before pagination. + /// + public bool? SortByPrice { get; set; } + + /// + /// Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results + /// + public string Offset { get; set; } + + /// + /// The maximum number of gifts to be returned; 1-100. Defaults to 100 + /// + public int? Limit { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Business/Requests/GetBusinessAccountStarBalance.cs b/src/RxTelegram.Bot/Interface/Business/Requests/GetBusinessAccountStarBalance.cs new file mode 100644 index 0000000..a4ecd14 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/Requests/GetBusinessAccountStarBalance.cs @@ -0,0 +1,14 @@ +using RxTelegram.Bot.Interface.BaseTypes; +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Business.Requests; + +/// +/// Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. +/// Returns on success. +/// +public class GetBusinessAccountStarBalance : BaseBusinessRequest +{ + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Business/Requests/ReadBusinessMessage.cs b/src/RxTelegram.Bot/Interface/Business/Requests/ReadBusinessMessage.cs new file mode 100644 index 0000000..3c13b2e --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/Requests/ReadBusinessMessage.cs @@ -0,0 +1,25 @@ +using RxTelegram.Bot.Interface.BaseTypes; +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Business.Requests; + +/// +/// Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success. +/// +public class ReadBusinessMessage : BaseBusinessRequest +{ + /// + /// Required + /// Unique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours. + /// + public ChatId ChatId { get; set; } + + /// + /// Required + /// Unique identifier of the message to mark as read + /// + public int MessageId { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Business/Requests/RemoveBusinessAccountProfilePhoto.cs b/src/RxTelegram.Bot/Interface/Business/Requests/RemoveBusinessAccountProfilePhoto.cs new file mode 100644 index 0000000..1983217 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/Requests/RemoveBusinessAccountProfilePhoto.cs @@ -0,0 +1,17 @@ +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Business.Requests; + +/// +/// Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. +/// +public class RemoveBusinessAccountProfilePhoto : BaseBusinessRequest +{ + /// + /// Pass True to remove the public photo, which will be visible even if the main photo is hidden by the business account's privacy settings. + /// + public bool? IsPublic { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountBio.cs b/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountBio.cs new file mode 100644 index 0000000..97a5385 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountBio.cs @@ -0,0 +1,17 @@ +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Business.Requests; + +/// +/// Changes the bio of a managed business account. Requires the can_change_bio business bot right. +/// +public class SetBusinessAccountBio : BaseBusinessRequest +{ + /// + /// The new value of the bio for the business account; 0-140 characters + /// + public string Bio { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountGiftSettings.cs b/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountGiftSettings.cs new file mode 100644 index 0000000..6af2617 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountGiftSettings.cs @@ -0,0 +1,24 @@ +using RxTelegram.Bot.Interface.BaseTypes; +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Business.Requests; + +/// +/// Changes the privacy settings pertaining to incoming gifts in a managed business account. +/// Requires the can_change_gift_settings business bot right. +/// +public class SetBusinessAccountGiftSettings : BaseBusinessRequest +{ + /// + /// Pass True, if a button for sending a gift to the user or by the business account must always be shown in the input field + /// + public bool ShowGiftButton { get; set; } + + /// + /// Types of gifts accepted by the business account + /// + public AccpetedGiftTypes AccpetedGiftTypes { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountName.cs b/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountName.cs new file mode 100644 index 0000000..7fdf6d4 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountName.cs @@ -0,0 +1,23 @@ +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Interface.Validation; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Business.Requests; + +/// +/// Changes the first and last name of a managed business account. Requires the can_change_name business bot right. +/// +public class SetBusinessAccountName : BaseBusinessRequest +{ + /// + /// The new value of the first name for the business account; 1-64 characters + /// + public string FirstName { get; set; } + + /// + /// The new value of the last name for the business account; 0-64 characters + /// + public string LastName { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountProfilePhoto.cs b/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountProfilePhoto.cs new file mode 100644 index 0000000..3909b09 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountProfilePhoto.cs @@ -0,0 +1,24 @@ +using RxTelegram.Bot.Interface.BaseTypes.InputMedia; +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Business.Requests; + +/// +/// Changes the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. +/// +public class SetBusinessAccountProfilePhoto : BaseBusinessRequest +{ + /// + /// The new profile photo to set + /// + public InputProfilePhoto Photo { get; set; } + + /// + /// Pass True to set the public photo, which will be visible even if the main photo is hidden by the business account's privacy settings. + /// An account can have only one public photo. + /// + public bool? IsPublic { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountUsername.cs b/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountUsername.cs new file mode 100644 index 0000000..b03c67e --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/Requests/SetBusinessAccountUsername.cs @@ -0,0 +1,17 @@ +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Business.Requests; + +/// +/// Changes the username of a managed business account. Requires the can_change_username business bot right. +/// +public class SetBusinessAccountUsername: BaseBusinessRequest +{ + /// + /// The new value of the username for the business account; 0-32 characters + /// + public string Username { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Business/Requests/TransferBusinessAccountStars.cs b/src/RxTelegram.Bot/Interface/Business/Requests/TransferBusinessAccountStars.cs new file mode 100644 index 0000000..8a77c7f --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/Requests/TransferBusinessAccountStars.cs @@ -0,0 +1,18 @@ +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Business.Requests; + +/// +/// Transfers Telegram Stars from the business account balance to the bot's balance. +/// Requires the can_transfer_stars business bot right. Returns True on success. +/// +public class TransferBusinessAccountStars : BaseBusinessRequest +{ + /// + /// Number of Telegram Stars to transfer; 1-10000 + /// + public int StarCount { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Business/Requests/TransferGift.cs b/src/RxTelegram.Bot/Interface/Business/Requests/TransferGift.cs new file mode 100644 index 0000000..81b07e5 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/Requests/TransferGift.cs @@ -0,0 +1,30 @@ +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Business.Requests; + +/// +/// Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right. +/// Requires can_transfer_stars business bot right if the transfer is paid. Returns True on success. +/// +public class TransferGift : BaseBusinessRequest +{ + + /// + /// Unique identifier of the regular gift that should be transferred + /// + public string OwnedGiftId { get; set; } + + /// + /// Unique identifier of the chat which will own the gift. The chat must be active in the last 24 hours. + /// + public long NewOwnerChatId { get; set; } + + /// + /// The amount of Telegram Stars that will be paid for the transfer from the business account balance. + /// If positive, then the can_transfer_stars business bot right is required. + /// + public int? StarCount { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Business/Requests/UpgradeGift.cs b/src/RxTelegram.Bot/Interface/Business/Requests/UpgradeGift.cs new file mode 100644 index 0000000..a98a01a --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Business/Requests/UpgradeGift.cs @@ -0,0 +1,29 @@ +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Business.Requests; + +/// +/// Upgrades a given regular gift to a unique gift. Requires the can_transfer_and_upgrade_gifts business bot right. +/// Additionally requires the can_transfer_stars business bot right if the upgrade is paid. Returns True on success. +/// +public class UpgradeGift : BaseBusinessRequest +{ + /// + /// Unique identifier of the regular gift that should be upgraded to a unique one + /// + public string OwnedGiftId { get; set; } + + /// + /// Pass True to keep the original gift text, sender and receiver in the upgraded gift + /// + public bool? KeepOriginalDetails { get; set; } + + /// + /// The amount of Telegram Stars that will be paid for the upgrade from the business account balance. + /// If gift.prepaid_upgrade_star_count > 0, then pass 0, otherwise, the can_transfer_stars business bot right is required and gift.upgrade_star_count must be passed. + /// + public int? StarCount { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Payments/PaidMessagePriceChanged.cs b/src/RxTelegram.Bot/Interface/Payments/PaidMessagePriceChanged.cs new file mode 100644 index 0000000..ef318ad --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Payments/PaidMessagePriceChanged.cs @@ -0,0 +1,12 @@ +namespace RxTelegram.Bot.Interface.Payments; + +/// +/// Describes a service message about a change in the price of paid messages within a chat. +/// +public class PaidMessagePriceChanged +{ + /// + /// The new number of Telegram Stars that must be paid by non-administrator users of the supergroup chat for each sent message + /// + public long PaidMessageStarCount { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerUser.cs b/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerUser.cs index 490d2ea..a1903c5 100644 --- a/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerUser.cs +++ b/src/RxTelegram.Bot/Interface/Payments/TransactionPartnerUser.cs @@ -46,4 +46,9 @@ public class TransactionPartnerUser : TransactionPartner /// Optional. The gift sent to the user by the bot /// public Gift Gift { get; set; } + + /// + /// Optional. Number of months the gifted Telegram Premium subscription will be active for; for “premium_purchase” transactions only + /// + public int PremiumSubscriptionDuration { get; set; } } diff --git a/src/RxTelegram.Bot/Interface/Story/Enums/InputStoryType.cs b/src/RxTelegram.Bot/Interface/Story/Enums/InputStoryType.cs new file mode 100644 index 0000000..3cc457d --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/Enums/InputStoryType.cs @@ -0,0 +1,7 @@ +namespace RxTelegram.Bot.Interface.Story.Enums; + +public enum InputStoryType +{ + Photo, + Video +} diff --git a/src/RxTelegram.Bot/Interface/Story/Enums/StoryAreaType.cs b/src/RxTelegram.Bot/Interface/Story/Enums/StoryAreaType.cs new file mode 100644 index 0000000..18f10e0 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/Enums/StoryAreaType.cs @@ -0,0 +1,10 @@ +namespace RxTelegram.Bot.Interface.Story.Enums; + +public enum StoryAreaType +{ + Link, + Location, + SuggestedReaction, + UniqueGift, + Weather +} diff --git a/src/RxTelegram.Bot/Interface/Story/InputStoryContentPhoto.cs b/src/RxTelegram.Bot/Interface/Story/InputStoryContentPhoto.cs new file mode 100644 index 0000000..935f228 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/InputStoryContentPhoto.cs @@ -0,0 +1,21 @@ +using RxTelegram.Bot.Interface.Story.Enums; + +namespace RxTelegram.Bot.Interface.Story; + +/// +/// Describes a photo to post as a story. +/// +public class InputStoryContentPhoto +{ + /// + /// Type of the content, must be "photo" + /// + public InputStoryType Type => InputStoryType.Photo; + + /// + /// 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>. + /// + public string Photo { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Story/InputStoryContentVideo.cs b/src/RxTelegram.Bot/Interface/Story/InputStoryContentVideo.cs new file mode 100644 index 0000000..dc0db2b --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/InputStoryContentVideo.cs @@ -0,0 +1,37 @@ +using RxTelegram.Bot.Interface.Story.Enums; + +namespace RxTelegram.Bot.Interface.Story; + +/// +/// Describes a video to post as a story. +/// +public class InputStoryContentVideo +{ + /// + /// Type of the content, must be "video" + /// + public InputStoryType Type => InputStoryType.Video; + + /// + /// 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>. + /// + public string Video { get; set; } + + /// + /// Optional. Precise duration of the video in seconds; 0-60 + /// + public float? Duration { get; set; } + + /// + /// Optional. Timestamp in seconds of the frame that will be used as the static cover for the story. Defaults to 0.0. + /// + public float? CoverFrameTimestamp { get; set; } + + /// + /// Optional. Pass True if the video has no sound + /// + public bool? IsAnimation { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Story/LocationAddress.cs b/src/RxTelegram.Bot/Interface/Story/LocationAddress.cs new file mode 100644 index 0000000..6e2fc54 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/LocationAddress.cs @@ -0,0 +1,24 @@ +namespace RxTelegram.Bot.Interface.Story; + +public class LocationAddress +{ + /// + /// The two-letter ISO 3166-1 alpha-2 country code of the country where the location is located + /// + public string CountryCode { get; set; } + + /// + /// Optional. State of the location + /// + public string? State { get; set; } + + /// + /// Optional. City of the location + /// + public string? City { get; set; } + + /// + /// Optional. Street address of the location + /// + public string? Street { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Story/Requests/DeleteStory.cs b/src/RxTelegram.Bot/Interface/Story/Requests/DeleteStory.cs new file mode 100644 index 0000000..13dd100 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/Requests/DeleteStory.cs @@ -0,0 +1,19 @@ +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Story.Requests; + +/// +/// Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. +/// Returns True on success. +/// +public class DeleteStory : BaseBusinessRequest +{ + + /// + /// Unique identifier of the story to delete + /// + public long StoryId { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Story/Requests/EditStory.cs b/src/RxTelegram.Bot/Interface/Story/Requests/EditStory.cs new file mode 100644 index 0000000..b19928a --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/Requests/EditStory.cs @@ -0,0 +1,47 @@ +using RxTelegram.Bot.Interface.BaseTypes.InputMedia; +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Story.Requests; + +using System.Collections.Generic; +using BaseTypes; + +/// +/// Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. +/// Returns Story on success. +/// +public class EditStory : BaseBusinessRequest +{ + /// + /// Unique identifier of the story to edit + /// + public int StoryId { get; set; } + + /// + /// Content of the story + /// + public InputStoryContent Content { get; set; } + + /// + /// Optional. Caption of the story, 0-2048 characters after entities parsing + /// + public string Caption { get; set; } + + /// + /// Optional. Mode for parsing entities in the story caption. See formatting options for more details. + /// + public string ParseMode { get; set; } + + /// + /// Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode + /// + public List CaptionEntities { get; set; } + + /// + /// Optional. A JSON-serialized list of clickable areas to be shown on the story + /// + public List Areas { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Story/Requests/PostStory.cs b/src/RxTelegram.Bot/Interface/Story/Requests/PostStory.cs new file mode 100644 index 0000000..83bd09b --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/Requests/PostStory.cs @@ -0,0 +1,55 @@ +using System.Collections.Generic; +using RxTelegram.Bot.Interface.BaseTypes; +using RxTelegram.Bot.Interface.BaseTypes.InputMedia; +using RxTelegram.Bot.Interface.BaseTypes.Requests.Base; +using RxTelegram.Bot.Validation; + +namespace RxTelegram.Bot.Interface.Story.Requests; + +/// +/// Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success. +/// +public class PostStory : BaseBusinessRequest +{ + /// + /// Content of the story + /// + public InputStoryContent Content { get; set; } + + /// + /// Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 + /// + public int ActivePeriod { get; set; } + + /// + /// Optional. Caption of the story, 0-2048 characters after entities parsing + /// + public string? Caption { get; set; } + + /// + /// Optional. Mode for parsing entities in the story caption. See formatting options for more details. + /// + public string? ParseMode { get; set; } + + /// + /// Optional. A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode + /// + public List? CaptionEntities { get; set; } + + /// + /// Optional. A JSON-serialized list of clickable areas to be shown on the story + /// + public List? Areas { get; set; } + + /// + /// Optional. Pass True to keep the story accessible after it expires + /// + public bool? PostToChatPage { get; set; } + + /// + /// Optional. Pass True if the content of the story must be protected from forwarding and screenshotting + /// + public bool? ProtectContent { get; set; } + + protected override IValidationResult Validate() => this.CreateValidation(); +} diff --git a/src/RxTelegram.Bot/Interface/Story/StoryArea.cs b/src/RxTelegram.Bot/Interface/Story/StoryArea.cs new file mode 100644 index 0000000..730a07c --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/StoryArea.cs @@ -0,0 +1,19 @@ +using RxTelegram.Bot.Interface.Story.Enums; + +namespace RxTelegram.Bot.Interface.Story; + +/// +/// Describes a clickable area on a story media. +/// +public class StoryArea +{ + /// + /// Position of the area + /// + public StoryAreaPosition Position { get; set; } + + /// + /// Type of the area + /// + public StoryAreaType Type { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Story/StoryAreaPosition.cs b/src/RxTelegram.Bot/Interface/Story/StoryAreaPosition.cs new file mode 100644 index 0000000..f2d0007 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/StoryAreaPosition.cs @@ -0,0 +1,37 @@ +namespace RxTelegram.Bot.Interface.Story; + +/// +/// Describes the position of a clickable area within a story. +/// +public class StoryAreaPosition +{ + /// + /// The abscissa of the area's center, as a percentage of the media width + /// + public float XPercentage { get; set; } + + /// + /// The ordinate of the area's center, as a percentage of the media height + /// + public float YPercentage { get; set; } + + /// + /// The width of the area's rectangle, as a percentage of the media width + /// + public float WidthPercentage { get; set; } + + /// + /// The height of the area's rectangle, as a percentage of the media height + /// + public float HeightPercentage { get; set; } + + /// + /// The clockwise rotation angle of the rectangle, in degrees; 0-360 + /// + public float RotationAngle { get; set; } + + /// + /// The radius of the rectangle corner rounding, as a percentage of the media width + /// + public float CornerRadiusPercentage { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeLink.cs b/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeLink.cs new file mode 100644 index 0000000..adcd0ee --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeLink.cs @@ -0,0 +1,19 @@ +using RxTelegram.Bot.Interface.Story.Enums; + +namespace RxTelegram.Bot.Interface.Story; + +/// +/// Describes a story area pointing to an HTTP or tg:// link. Currently, a story can have up to 3 link areas. +/// +public class StoryAreaTypeLink +{ + /// + /// Type of the area, always "link" + /// + public StoryAreaType Type => StoryAreaType.Link; + + /// + /// HTTP or tg:// URL to be opened when the area is clicked + /// + public string Url { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeLocation.cs b/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeLocation.cs new file mode 100644 index 0000000..7879e02 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeLocation.cs @@ -0,0 +1,29 @@ +using RxTelegram.Bot.Interface.Story.Enums; + +namespace RxTelegram.Bot.Interface.Story; + +/// +/// Describes a story area pointing to a location. Currently, a story can have up to 10 location areas. +/// +public class StoryAreaTypeLocation +{ + /// + /// Type of the area, always "location" + /// + public StoryAreaType Type => StoryAreaType.Location; + + /// + /// Location latitude in degrees + /// + public float Latitude { get; set; } + + /// + /// Location longitude in degrees + /// + public float Longitude { get; set; } + + /// + /// Optional. Address of the location + /// + public LocationAddress? Address { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeSuggestedReaction.cs b/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeSuggestedReaction.cs new file mode 100644 index 0000000..373ca94 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeSuggestedReaction.cs @@ -0,0 +1,30 @@ +using RxTelegram.Bot.Interface.Reaction.Enums; +using RxTelegram.Bot.Interface.Story.Enums; + +namespace RxTelegram.Bot.Interface.Story; + +/// +/// Describes a story area pointing to a suggested reaction. Currently, a story can have up to 5 suggested reaction areas. +/// +public class StoryAreaTypeSuggestedReaction +{ + /// + /// Type of the area, always "suggested_reaction" + /// + public StoryAreaType Type => StoryAreaType.SuggestedReaction; + + /// + /// Type of the reaction + /// + public ReactionType ReactionType { get; set; } + + /// + /// Optional. Pass True if the reaction area has a dark background + /// + public bool? IsDark { get; set; } + + /// + /// Optional. Pass True if reaction area corner is flipped + /// + public bool? IsFlipped { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeUniqueGift.cs b/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeUniqueGift.cs new file mode 100644 index 0000000..9dd7d2a --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeUniqueGift.cs @@ -0,0 +1,16 @@ +using RxTelegram.Bot.Interface.Story.Enums; + +namespace RxTelegram.Bot.Interface.Story; + +public class StoryAreaTypeUniqueGift +{ + /// + /// Type of the area, always "unique_gift" + /// + public StoryAreaType Type => StoryAreaType.UniqueGift; + + /// + /// Unique name of the gift + /// + public string Name { get; set; } +} diff --git a/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeWeather.cs b/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeWeather.cs new file mode 100644 index 0000000..ddc8683 --- /dev/null +++ b/src/RxTelegram.Bot/Interface/Story/StoryAreaTypeWeather.cs @@ -0,0 +1,26 @@ +using RxTelegram.Bot.Interface.Story.Enums; + +namespace RxTelegram.Bot.Interface.Story; + +public class StoryAreaTypeWeather +{ + /// + /// Type of the area, always "weather" + /// + public StoryAreaType Type => StoryAreaType.Weather; + + /// + /// Temperature, in degree Celsius + /// + public float Temperature { get; set; } + + /// + /// Emoji representing the weather + /// + public string Emoji { get; set; } + + /// + /// A color of the area background in the ARGB format + /// + public int BackgroundColor { get; set; } +} diff --git a/src/RxTelegram.Bot/RxTelegram.Bot.csproj b/src/RxTelegram.Bot/RxTelegram.Bot.csproj index 6763346..cfbc154 100644 --- a/src/RxTelegram.Bot/RxTelegram.Bot.csproj +++ b/src/RxTelegram.Bot/RxTelegram.Bot.csproj @@ -10,7 +10,7 @@ https://github.com/RxTelegram/RxTelegram.Bot git Telegram;Bot;Api;Rx;Reactive;Observable;RxTelegram;RxTelegram.Bot - 8.3.0 + 9.0.0 icon.png true bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml diff --git a/src/RxTelegram.Bot/TelegramBot.cs b/src/RxTelegram.Bot/TelegramBot.cs index 7a8c1e5..fe8b280 100644 --- a/src/RxTelegram.Bot/TelegramBot.cs +++ b/src/RxTelegram.Bot/TelegramBot.cs @@ -26,6 +26,7 @@ using RxTelegram.Bot.Interface.Setup; using RxTelegram.Bot.Interface.Stickers; using RxTelegram.Bot.Interface.Stickers.Requests; +using RxTelegram.Bot.Interface.Story.Requests; using File = RxTelegram.Bot.Interface.BaseTypes.File; namespace RxTelegram.Bot; @@ -1470,4 +1471,186 @@ public Task RemoveUserVerification(RemoveUserVerification removeUserVerifi /// Returns True on success. public Task RemoveChatVerification(RemoveChatVerification removeChatVerification, CancellationToken cancellationToken = default) => Post("removeChatVerification", removeChatVerification, cancellationToken); + + /// + /// Gifts a Telegram Premium subscription to the given user. + /// + /// Details for the premium subscription to gift. + /// Propagates notification that operations should be canceled. + /// Returns True on success. + public Task GiftPremiumSubscription(GiftPremiumSubscription giftPremiumSubscription, CancellationToken cancellationToken = default) => + Post("giftPremiumSubscription", giftPremiumSubscription, cancellationToken); + + /// + /// Marks incoming message as read on behalf of a business account. + /// + /// Requires the can_read_messages business bot right + /// + /// + /// Propagates notification that operations should be canceled. + /// Returns True on success. + public Task ReadBusinessMessage(ReadBusinessMessage readBusinessMessage, CancellationToken cancellationToken = default) => + Post("readBusinessMessage", readBusinessMessage, cancellationToken); + + /// + /// Delete messages on behalf of a business account. + /// + /// Requires the can_delete_sent_messages business bot right to delete messages sent by the bot itself, + /// or the can_delete_all_messages business bot right to delete any message. + /// + /// Messages to delete + /// Propagates notification that operations should be canceled. + /// Returns True on success. + public Task DeleteBusinessMessages(DeleteBusinessMessages deleteBusinessMessages, CancellationToken cancellationToken = default) => + Post("deleteBusinessMessages", deleteBusinessMessages, cancellationToken); + + /// + /// Changes the first and last name of a managed business account. + /// + /// Requires the can_change_name business bot right. + /// + /// New first and last name for the business account + /// Propagates notification that operations should be canceled. + /// Returns True on success. + public Task SetBusinessAccountUsername( + SetBusinessAccountUsername setBusinessAccountUsername, + CancellationToken cancellationToken = default) => + Post("setBusinessAccountUsername", setBusinessAccountUsername, cancellationToken); + + /// + /// Changes the bio of a managed business account. + /// + /// Requires the can_change_bio business bot right. + /// + /// Sets the bio for the business account + /// Propagates notification that operations should be canceled. + /// Returns True on success. + public Task SetBusinessAccountBio( + SetBusinessAccountBio setBusinessAccountBio, + CancellationToken cancellationToken = default) => + Post("setBusinessAccountBio", setBusinessAccountBio, cancellationToken); + + /// + /// Changes the profile photo of a managed business account. + /// + /// Requires the can_edit_profile_photo business bot right. + /// + /// The profile photo to set for the business account. + /// Propagates notification that operations should be canceled. + /// Returns True on success. + public Task SetBusinessAccountProfilePhoto( + SetBusinessAccountProfilePhoto setBusinessAccountProfilePhoto, + CancellationToken cancellationToken = default) => + Post("setBusinessAccountProfilePhoto", setBusinessAccountProfilePhoto, cancellationToken); + + /// + /// Removes the current profile photo of a managed business account. + /// + /// Requires the can_edit_profile_photo business bot right. + /// + /// Information about the profile photo to remove. + /// Propagates notification that operations should be canceled. + /// Returns True on success. + public Task RemoveBusinessAccountProfilePhoto( + RemoveBusinessAccountProfilePhoto removeBusinessAccountProfilePhoto, + CancellationToken cancellationToken = default) => + Post("removeBusinessAccountProfilePhoto", removeBusinessAccountProfilePhoto, cancellationToken); + + /// + /// Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. + /// + /// Request to get the business account star balance + /// Propagates notification that operations should be canceled. + /// Returns a object on success. + public Task GetBusinessAccountStarBalance( + GetBusinessAccountStarBalance getBusinessAccountStarBalance, + CancellationToken cancellationToken = default) => + Post("getBusinessAccountStarBalance", getBusinessAccountStarBalance, cancellationToken); + + /// + /// Transfers Telegram Stars from the business account balance to the bot's balance. + /// + /// Amount to transfer + /// Propagates notification that operations should be canceled. + /// Returns True on success. + public Task TransferBusinessAccountStars( + TransferBusinessAccountStars transferBusinessAccountStars, + CancellationToken cancellationToken = default) => + Post("transferBusinessAccountStars", transferBusinessAccountStars, cancellationToken); + + /// + /// Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. + /// + /// + /// Propagates notification that operations should be canceled. + /// Returns OwnedGifts on success. + public Task GetBusinessAccountGifts( + GetBusinessAccountGifts getBusinessAccountGifts, + CancellationToken cancellationToken = default) => + Post("getBusinessAccountGifts", getBusinessAccountGifts, cancellationToken); + + /// + /// Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. + /// + /// Information about the gift to convert + /// Propagates notification that operations should be canceled. + /// Returns True on success. + public Task ConvertGiftToStars( + ConvertGiftToStars convertGiftToStars, + CancellationToken cancellationToken = default) => + Post("convertGiftToStars", convertGiftToStars, cancellationToken); + + /// + /// Upgrades a given regular gift to a unique gift. Requires the can_transfer_and_upgrade_gifts business bot right. + /// Additionally requires the can_transfer_stars business bot right if the upgrade is paid. + /// + /// Gift to upgrade + /// Propagates notification that operations should be canceled. + /// Returns True on success. + public Task UpgradeGift( + UpgradeGift upgradeGift, + CancellationToken cancellationToken = default) => + Post("upgradeGift", upgradeGift, cancellationToken); + + /// + /// Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right. + /// Requires can_transfer_stars business bot right if the transfer is paid. + /// + /// Information about the transfer + /// Propagates notification that operations should be canceled. + /// Returns True on success. + public Task TransferGift( + TransferGift transferGift, + CancellationToken cancellationToken = default) => + Post("transferGift", transferGift, cancellationToken); + + /// + /// Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. + /// + /// + /// Propagates notification that operations should be canceled. + /// Returns Story on success. + public Task PostStory( + PostStory postStory, + CancellationToken cancellationToken = default) => Post("postStory", postStory, cancellationToken); + + /// + /// Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. + /// + /// + /// Propagates notification that operations should be canceled. + /// Returns True on success. + public Task EditStory( + EditStory editStory, + CancellationToken cancellationToken = default) => Post("editStory", editStory, cancellationToken); + + /// + /// Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. + /// + /// + /// Propagates notification that operations should be canceled. + /// Returns True on success. + public Task DeleteStory( + DeleteStory deleteStory, + CancellationToken cancellationToken = default) => Post("deleteStory", deleteStory, cancellationToken); } diff --git a/src/RxTelegram.Bot/Validation/ValidationResultFactory.cs b/src/RxTelegram.Bot/Validation/ValidationResultFactory.cs index ad3c02f..1d41682 100644 --- a/src/RxTelegram.Bot/Validation/ValidationResultFactory.cs +++ b/src/RxTelegram.Bot/Validation/ValidationResultFactory.cs @@ -12,6 +12,7 @@ using RxTelegram.Bot.Interface.BaseTypes.Requests.Inline; using RxTelegram.Bot.Interface.BaseTypes.Requests.Messages; using RxTelegram.Bot.Interface.BaseTypes.Requests.Users; +using RxTelegram.Bot.Interface.Business.Requests; using RxTelegram.Bot.Interface.Games.Requests; using RxTelegram.Bot.Interface.InlineMode; using RxTelegram.Bot.Interface.InlineMode.InlineQueryResults; @@ -20,6 +21,8 @@ using RxTelegram.Bot.Interface.Reaction.Requests; using RxTelegram.Bot.Interface.Setup; using RxTelegram.Bot.Interface.Stickers.Requests; +using RxTelegram.Bot.Interface.Story; +using RxTelegram.Bot.Interface.Story.Requests; namespace RxTelegram.Bot.Validation; @@ -634,10 +637,10 @@ public static ValidationResult CreateValidation(this ForwardMes .ValidateRequired(x => x.FromChatId) .ValidateRequired(x => x.MessageIds); - public static ValidationResult CreateValidation(this CopyMessages value) => - new ValidationResult(value).ValidateRequired(x => x.ChatId) - .ValidateRequired(x => x.FromChatId) - .ValidateRequired(x => x.MessageIds); + public static ValidationResult CreateValidation(this CopyMessages value) => new ValidationResult(value) + .ValidateRequired(x => x.ChatId) + .ValidateRequired(x => x.FromChatId) + .ValidateRequired(x => x.MessageIds); public static ValidationResult CreateValidation(this GetUserChatBoosts value) => new ValidationResult(value).ValidateRequired(x => x.UserId) @@ -653,9 +656,9 @@ public static ValidationResult CreateValidation(this RefundSt new ValidationResult(value).ValidateRequired(x => x.UserId) .ValidateRequired(x => x.TelegramPaymentChargeId); - public static ValidationResult CreateValidation(this SendPaidMedia value) => - new ValidationResult(value).ValidateRequired(x => x.StarCount) - .ValidateRequired(x => x.Media); + public static ValidationResult CreateValidation(this SendPaidMedia value) => new ValidationResult(value) + .ValidateRequired(x => x.StarCount) + .ValidateRequired(x => x.Media); public static ValidationResult CreateValidation(this CreateChatSubscriptionInviteLink value) => new ValidationResult(value).ValidateRequired(x => x.ChatId) @@ -683,9 +686,9 @@ public static ValidationResult CreateValidation(this public static ValidationResult CreateValidation(this SendGift value) => new ValidationResult(value) .IsFalse(x => x.ChatId == null && x.UserId == null, - ValidationErrors.FieldRequired) + ValidationErrors.FieldRequired) .IsFalse(x => x.ChatId != null && x.UserId != null, - ValidationErrors.OnlyOnePropertyCanBeSet) + ValidationErrors.OnlyOnePropertyCanBeSet) .ValidateRequired(x => x.GiftId); public static ValidationResult CreateValidation(this VerifyUser value) => @@ -699,4 +702,83 @@ public static ValidationResult CreateValidation(this Rem public static ValidationResult CreateValidation(this RemoveChatVerification value) => new ValidationResult(value).ValidateRequired(x => x.ChatId); + + public static ValidationResult CreateValidation(this GiftPremiumSubscription value) => + new ValidationResult(value).ValidateRequired(x => x.UserId) + .ValidateRequired(x => x.MonthCount) + .ValidateRequired(x => x.StarCount); + + public static ValidationResult CreateValidation(this ReadBusinessMessage value) => + new ValidationResult(value) + .ValidateRequired(x => x.BusinessConnectionId) + .ValidateRequired(x => x.ChatId) + .ValidateRequired(x => x.MessageId); + + public static ValidationResult CreateValidation(this DeleteBusinessMessages value) => + new ValidationResult(value).ValidateRequired(x => x.BusinessConnectionId) + .ValidateRequired(x => x.MessageIds); + + public static ValidationResult CreateValidation(this SetBusinessAccountName value) => + new ValidationResult(value).ValidateRequired(x => x.BusinessConnectionId) + .ValidateRequired(x => x.FirstName) + .IsTrue(x => x.FirstName.Length <= 64, ValidationErrors.TextTooLong); + + public static ValidationResult CreateValidation(this SetBusinessAccountUsername value) => + new ValidationResult(value).ValidateRequired(x => x.BusinessConnectionId) + .ValidateRequired(x => x.Username) + .IsTrue(x => x.Username.Length <= 32, ValidationErrors.TextTooLong); + + public static ValidationResult CreateValidation(this SetBusinessAccountBio value) => + new ValidationResult(value).ValidateRequired(x => x.BusinessConnectionId) + .ValidateRequired(x => x.Bio) + .IsTrue(x => x.Bio.Length <= 140, ValidationErrors.TextTooLong); + + public static ValidationResult CreateValidation(this SetBusinessAccountProfilePhoto value) => + new ValidationResult(value) + .ValidateRequired(x => x.BusinessConnectionId) + .ValidateRequired(x => x.Photo); + + public static ValidationResult CreateValidation(this RemoveBusinessAccountProfilePhoto value) => + new ValidationResult(value) + .ValidateRequired(x => x.BusinessConnectionId); + + public static ValidationResult CreateValidation(this SetBusinessAccountGiftSettings value) => + new ValidationResult(value) + .ValidateRequired(x => x.BusinessConnectionId) + .ValidateRequired(x => x.ShowGiftButton) + .ValidateRequired(x => x.AccpetedGiftTypes); + + public static ValidationResult CreateValidation(this GetBusinessAccountStarBalance value) => + new ValidationResult(value).ValidateRequired(x => x.BusinessConnectionId); + + public static ValidationResult CreateValidation(this TransferBusinessAccountStars value) => + new ValidationResult(value).ValidateRequired(x => x.BusinessConnectionId) + .ValidateRequired(x => x.StarCount); + + public static ValidationResult CreateValidation(this ConvertGiftToStars value) => + new ValidationResult(value).ValidateRequired(x => x.BusinessConnectionId) + .ValidateRequired(x => x.OwnedGiftId); + + public static ValidationResult CreateValidation(this UpgradeGift value) => + new ValidationResult(value).ValidateRequired(x => x.BusinessConnectionId) + .ValidateRequired(x => x.OwnedGiftId); + + public static ValidationResult CreateValidation(this TransferGift value) => + new ValidationResult(value).ValidateRequired(x => x.BusinessConnectionId) + .ValidateRequired(x => x.OwnedGiftId) + .ValidateRequired(x => x.NewOwnerChatId); + + public static ValidationResult CreateValidation(this PostStory value) => + new ValidationResult(value).ValidateRequired(x => x.BusinessConnectionId) + .ValidateRequired(x => x.Content) + .ValidateRequired(x => x.ActivePeriod); + + public static ValidationResult CreateValidation(this EditStory value) => + new ValidationResult(value).ValidateRequired(x => x.BusinessConnectionId) + .ValidateRequired(x => x.StoryId) + .ValidateRequired(x => x.Content); + + public static ValidationResult CreateValidation(this DeleteStory value) => + new ValidationResult(value).ValidateRequired(x => x.BusinessConnectionId) + .ValidateRequired(x => x.StoryId); }