Добавлены новые методы отправки сообщений
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using BotPages.Core.Abstractions;
|
||||
using BotPages.Core.Messaging;
|
||||
|
||||
namespace BotPages.Core;
|
||||
|
||||
@@ -19,4 +20,108 @@ public static class PageContextAdapterExtensions
|
||||
/// </summary>
|
||||
public static Task DeleteAsync(this PageContext ctx, string chatId, string messageId, CancellationToken ct = default)
|
||||
=> ctx.Adapter.DeleteAsync(chatId, messageId, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Удалить сообщение (используя ChatId из контекста).
|
||||
/// </summary>
|
||||
public static Task DeleteAsync(this PageContext ctx, string messageId, CancellationToken ct = default)
|
||||
=> ctx.Adapter.DeleteAsync(ctx.Update.Chat.Id, messageId, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Удалить несколько сообщений.
|
||||
/// </summary>
|
||||
public static Task<bool> DeleteMultipleAsync(this PageContext ctx, string chatId, IEnumerable<string> messageIds, CancellationToken ct = default)
|
||||
=> ctx.Adapter.DeleteMultipleAsync(chatId, messageIds, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Удалить несколько сообщений (используя ChatId из контекста).
|
||||
/// </summary>
|
||||
public static Task<bool> DeleteMultipleAsync(this PageContext ctx, IEnumerable<string> messageIds, CancellationToken ct = default)
|
||||
=> ctx.Adapter.DeleteMultipleAsync(ctx.Update.Chat.Id, messageIds, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Редактировать текст сообщения.
|
||||
/// </summary>
|
||||
public static Task<string?> EditTextAsync(this PageContext ctx, string chatId, string messageId, string text,
|
||||
MessageFormat? format = null, CancellationToken ct = default)
|
||||
=> ctx.Adapter.EditTextAsync(chatId, messageId, text, format, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Редактировать текст сообщения (используя ChatId из контекста).
|
||||
/// </summary>
|
||||
public static Task<string?> EditTextAsync(this PageContext ctx, string messageId, string text,
|
||||
MessageFormat? format = null, CancellationToken ct = default)
|
||||
=> ctx.Adapter.EditTextAsync(ctx.Update.Chat.Id, messageId, text, format, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Редактировать кнопки сообщения.
|
||||
/// </summary>
|
||||
public static Task<string?> EditButtonsAsync(this PageContext ctx, string chatId, string messageId,
|
||||
IEnumerable<IEnumerable<InlineButton>>? inlineButtons = null, CancellationToken ct = default)
|
||||
=> ctx.Adapter.EditButtonsAsync(chatId, messageId, inlineButtons, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Редактировать кнопки сообщения (используя ChatId из контекста).
|
||||
/// </summary>
|
||||
public static Task<string?> EditButtonsAsync(this PageContext ctx, string messageId,
|
||||
IEnumerable<IEnumerable<InlineButton>>? inlineButtons = null, CancellationToken ct = default)
|
||||
=> ctx.Adapter.EditButtonsAsync(ctx.Update.Chat.Id, messageId, inlineButtons, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Закрепить сообщение.
|
||||
/// </summary>
|
||||
public static Task<bool> PinMessageAsync(this PageContext ctx, string chatId, string messageId,
|
||||
bool disableNotification = false, CancellationToken ct = default)
|
||||
=> ctx.Adapter.PinMessageAsync(chatId, messageId, disableNotification, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Закрепить сообщение (используя ChatId из контекста).
|
||||
/// </summary>
|
||||
public static Task<bool> PinMessageAsync(this PageContext ctx, string messageId,
|
||||
bool disableNotification = false, CancellationToken ct = default)
|
||||
=> ctx.Adapter.PinMessageAsync(ctx.Update.Chat.Id, messageId, disableNotification, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Открепить сообщение.
|
||||
/// </summary>
|
||||
public static Task<bool> UnpinMessageAsync(this PageContext ctx, string chatId, string messageId,
|
||||
CancellationToken ct = default)
|
||||
=> ctx.Adapter.UnpinMessageAsync(chatId, messageId, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Открепить сообщение (используя ChatId из контекста).
|
||||
/// </summary>
|
||||
public static Task<bool> UnpinMessageAsync(this PageContext ctx, string messageId,
|
||||
CancellationToken ct = default)
|
||||
=> ctx.Adapter.UnpinMessageAsync(ctx.Update.Chat.Id, messageId, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Получить информацию о сообщении.
|
||||
/// </summary>
|
||||
public static Task<MessageInfo?> GetMessageInfoAsync(this PageContext ctx, string chatId, string messageId,
|
||||
CancellationToken ct = default)
|
||||
=> ctx.Adapter.GetMessageInfoAsync(chatId, messageId, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Получить информацию о сообщении (используя ChatId из контекста).
|
||||
/// </summary>
|
||||
public static Task<MessageInfo?> GetMessageInfoAsync(this PageContext ctx, string messageId,
|
||||
CancellationToken ct = default)
|
||||
=> ctx.Adapter.GetMessageInfoAsync(ctx.Update.Chat.Id, messageId, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Переслать сообщение.
|
||||
/// </summary>
|
||||
public static Task<string?> ForwardMessageAsync(this PageContext ctx, string fromChatId, string messageId,
|
||||
string toChatId, bool disableNotification = false, CancellationToken ct = default)
|
||||
=> ctx.Adapter.ForwardMessageAsync(fromChatId, messageId, toChatId, disableNotification, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Копировать сообщение.
|
||||
/// </summary>
|
||||
public static Task<string?> CopyMessageAsync(this PageContext ctx, string fromChatId, string messageId,
|
||||
string toChatId, string? caption = null, MessageFormat? captionFormat = null,
|
||||
bool disableNotification = false, CancellationToken ct = default)
|
||||
=> ctx.Adapter.CopyMessageAsync(fromChatId, messageId, toChatId, caption, captionFormat,
|
||||
disableNotification, ct);
|
||||
}
|
||||
Reference in New Issue
Block a user