Skip to content

Commit

Permalink
Add support for v7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasweimann committed Apr 14, 2024
1 parent 3229b57 commit c05b9cc
Show file tree
Hide file tree
Showing 45 changed files with 596 additions and 100 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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.1 (as at February 16, 2024).
RxTelegram.Bot supports Telegram Bot API 7.2 (as at March 31, 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
161 changes: 94 additions & 67 deletions src/RxTelegram.Bot/ITelegramBot.cs

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions src/RxTelegram.Bot/Interface/BaseTypes/Birthdate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace RxTelegram.Bot.Interface.BaseTypes;

public class Birthdate
{
/// <summary>
/// Day of the user's birth; 1-31
/// </summary>
public int Day { get; set; }

/// <summary>
/// Month of the user's birth; 1-12
/// </summary>
public int Month { get; set; }

/// <summary>
/// Optional. Year of the user's birth
/// </summary>
public int? Year { get; set; }
}
33 changes: 32 additions & 1 deletion src/RxTelegram.Bot/Interface/BaseTypes/Chat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading;
using RxTelegram.Bot.Interface.BaseTypes.Enums;
using RxTelegram.Bot.Interface.BaseTypes.Requests.Chats;
using RxTelegram.Bot.Interface.Business;
using RxTelegram.Bot.Interface.Reaction;

namespace RxTelegram.Bot.Interface.BaseTypes;
Expand Down Expand Up @@ -64,6 +65,36 @@ public class Chat
/// </summary>
public List<string> ActiveUsernames { get; set; }

/// <summary>
/// Optional. For private chats, the date of birth of the user.
/// Returned only in <see cref="ITelegramBot.GetChat(GetChat,CancellationToken)"/>.
/// </summary>
public Birthdate Birthdate { get; set; }

/// <summary>
/// Optional. For private chats with business accounts, the intro of the business.
/// Returned only in <see cref="TelegramBot.GetChat(GetChat,CancellationToken)"/>.
/// </summary>
public BusinessIntro BusinessIntro { get; set; }

/// <summary>
/// Optional. For private chats with business accounts, the location of the business.
/// Returned only in <see cref="TelegramBot.GetChat(GetChat,CancellationToken)"/>.
/// </summary>
public BusinessLocation BusinessLocation { get; set; }

/// <summary>
/// Optional. For private chats with business accounts, the opening hours of the business.
/// Returned only in <see cref="TelegramBot.GetChat(GetChat,CancellationToken)"/>.
/// </summary>
public BusinessOpeningHours BusinessOpeningHours { get; set; }

/// <summary>
/// Optional. For private chats, the personal channel of the user.
/// Returned only in <see cref="TelegramBot.GetChat(GetChat,CancellationToken)"/>.
/// </summary>
public Chat PersonalChat { get; set; }

/// <summary>
/// Optional. List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed.
/// Returned only in <see cref="GetChat"/>.
Expand Down Expand Up @@ -93,7 +124,7 @@ public class Chat
/// Optional. Custom emoji identifier of the emoji chosen by the chat for its profile background.
/// Returned only in <see cref="ITelegramBot.GetChat(GetChat,CancellationToken)"/>.
/// </summary>
public string ProfileBackgroundCustomEmojiId { get; set;}
public string ProfileBackgroundCustomEmojiId { get; set; }

/// <summary>
/// Optional. Custom emoji identifier of emoji status of the other party in a private chat.
Expand Down
23 changes: 20 additions & 3 deletions src/RxTelegram.Bot/Interface/BaseTypes/ChatShared.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Collections.Generic;

namespace RxTelegram.Bot.Interface.BaseTypes;

/// <summary>
Expand All @@ -11,10 +13,25 @@ public class ChatShared
public int RequestId { get; set; }

/// <summary>
/// Identifier of the shared user.
/// Identifier of the shared chat.
/// This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it.
/// But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
/// The bot may not have access to the user and could be unable to use this identifier, unless the user is already known to the bot by some other means.
/// The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means.
/// </summary>
public long ChatId { get; set; }

/// <summary>
/// Optional. Title of the chat, if the title was requested by the bot.
/// </summary>
public string Title { get; set; }

/// <summary>
/// Optional. Username of the chat, if the username was requested by the bot and available.
/// </summary>
public string Username { get; set; }

/// <summary>
/// Optional. Available sizes of the chat photo, if the photo was requested by the bot
/// </summary>
public long UserId { get; set; }
public List<PhotoSize> Photo { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,19 @@ public class KeyboardButtonRequestChat
/// Otherwise, no additional restrictions are applied.
/// </summary>
public bool BotIsMember { get; set; }

/// <summary>
/// Optional. Pass True to request the chat's title
/// </summary>
public bool RequestTitle { get; set; }

/// <summary>
/// Optional. Pass True to request the chat's username
/// </summary>
public bool RequestUsername { get; set; }

/// <summary>
/// Optional. Pass True to request the chat's photo
/// </summary>
public bool RequestPhoto { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,19 @@ public class KeyboardButtonRequestUsers
/// Optional. The maximum number of users to be selected; 1-10. Defaults to 1.
/// </summary>
public int MaxQuantity { get; set; }

/// <summary>
/// Optional. Pass True to request the users' first and last name
/// </summary>
public bool RequestName { get; set; }

/// <summary>
/// Optional. Pass True to request the users' username
/// </summary>
public bool RequestUsername { get; set; }

/// <summary>
/// Optional. Pass True to request the users' photo
/// </summary>
public bool RequestPhoto { get; set; }
}
20 changes: 19 additions & 1 deletion src/RxTelegram.Bot/Interface/BaseTypes/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,24 @@ public class Message
/// </summary>
public ChatBoostAdded BoostAdded { get; set; }

/// <summary>
/// Optional. The bot that actually sent the message on behalf of the business account.
/// Available only for outgoing messages sent on behalf of the connected business account.
/// </summary>
public User SenderBusinessBot { get; set; }

/// <summary>
/// Date the message was sent
/// </summary>
public DateTime Date { get; set; }

/// <summary>
/// Optional. Unique identifier of the business connection from which the message was received.
/// If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat
/// which might share the same identifier.
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Conversation the message belongs to
/// </summary>
Expand Down Expand Up @@ -106,6 +119,11 @@ public class Message
/// </summary>
public bool? HasProtectedContent { get; set; }

/// <summary>
/// Optional. True, if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message
/// </summary>
public bool IsFromOffline { get; set; }

/// <summary>
/// Optional. The unique identifier of a media message group this message belongs to
/// </summary>
Expand Down Expand Up @@ -296,7 +314,7 @@ public class Message
/// <summary>
/// Optional. Service message: a user was shared with the bot
/// </summary>
public UserShared UserShared { get; set; }
public UsersShared UsersShared { get; set; }

/// <summary>
/// Optional. Service message: a chat was shared with the bot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Attachments;
/// </summary>
public class SendAnimation : BaseSend, IProtectContent
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Attachments;
/// </summary>
public class SendAudio : BaseSend, IProtectContent
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Attachments;
/// </summary>
public class SendContact : BaseRequest, IProtectContent
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Attachments;

public class SendDocument : BaseSend, IProtectContent
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Attachments;

public class SendLocation : BaseRequest, IProtectContent
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Attachments;

public class SendMediaGroup : BaseRequest, IProtectContent
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Attachments;

public class SendPhoto : BaseSend, IProtectContent
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Attachments;
/// </summary>
public class SendPoll : BaseRequest, IProtectContent
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Attachments;
/// </summary>
public class SendVenue : BaseRequest, IProtectContent
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Attachments;
/// </summary>
public class SendVideo : BaseSend, IProtectContent
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Attachments;
/// </summary>
public class SendVideoNote : BaseSend, IProtectContent
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Attachments;
/// </summary>
public class SendVoice : BaseSend, IProtectContent
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Chats;

public class SendChatAction : BaseRequest
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Required
/// Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages,
Expand All @@ -20,4 +25,4 @@ public class SendChatAction : BaseRequest
public long MessageThreadId { get; set; }

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

/// <summary>
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ namespace RxTelegram.Bot.Interface.BaseTypes.Requests.Messages;

public class SendMessage : BaseTextRequest, IProtectContent
{
/// <summary>
/// Unique identifier of the business connection on behalf of which the message will be sent
/// </summary>
public string BusinessConnectionId { get; set; }

/// <summary>
/// Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
/// </summary>
Expand Down
Loading

0 comments on commit c05b9cc

Please sign in to comment.