From 41986987b1838432ba7078336bf39e1d45e9a6b3 Mon Sep 17 00:00:00 2001 From: FrigaT Date: Tue, 16 Dec 2025 16:19:50 +0300 Subject: [PATCH] =?UTF-8?q?=D1=87=D0=B8=D1=81=D1=82=D0=BA=D0=B0=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BotPages.Core/Abstractions/IMessengerAdapter.cs | 12 ++++++------ BotPages.Core/Context/ChatContext.cs | 4 +--- BotPages.Core/Context/PageContext.cs | 1 - .../Context/PageContextAdapterExtensions.cs | 16 ++++++++-------- BotPages.Core/Routing/CommandHandler.cs | 8 +------- BotPages.Core/Routing/RoutesRegistry.cs | 2 +- BotPages.Telegram/TelegramAdapter.cs | 11 +++++------ Demo/Pages/TitlePage.cs | 1 - 8 files changed, 22 insertions(+), 33 deletions(-) diff --git a/BotPages.Core/Abstractions/IMessengerAdapter.cs b/BotPages.Core/Abstractions/IMessengerAdapter.cs index db37aad..bc1abbb 100644 --- a/BotPages.Core/Abstractions/IMessengerAdapter.cs +++ b/BotPages.Core/Abstractions/IMessengerAdapter.cs @@ -17,21 +17,21 @@ public interface IMessengerAdapter /// /// Отправить текстовое сообщение в чат. /// - Task SendTextAsync(string chatId, - string text, + Task SendTextAsync(string chatId, + string text, MessageFormat format = MessageFormat.Plain, IEnumerable>? inline = null, IEnumerable>? reply = null, - string? messageId = null, + string? messageId = null, CancellationToken ct = default ); /// /// Отправить файл в чат. /// - Task SendFileAsync(string chatId, - FileDescriptor file, - string? caption = null, + Task SendFileAsync(string chatId, + FileDescriptor file, + string? caption = null, MessageFormat? captionFormat = null, IEnumerable>? inline = null, IEnumerable>? reply = null, diff --git a/BotPages.Core/Context/ChatContext.cs b/BotPages.Core/Context/ChatContext.cs index e962969..9783a0e 100644 --- a/BotPages.Core/Context/ChatContext.cs +++ b/BotPages.Core/Context/ChatContext.cs @@ -1,6 +1,4 @@ -using BotPages.Core.Abstractions; - -namespace BotPages.Core; +namespace BotPages.Core; /// /// Данные чата. diff --git a/BotPages.Core/Context/PageContext.cs b/BotPages.Core/Context/PageContext.cs index ea28518..6ae3c77 100644 --- a/BotPages.Core/Context/PageContext.cs +++ b/BotPages.Core/Context/PageContext.cs @@ -1,6 +1,5 @@ using BotPages.Core.Abstractions; using BotPages.Core.Context; -using BotPages.Core.Messaging; namespace BotPages.Core; diff --git a/BotPages.Core/Context/PageContextAdapterExtensions.cs b/BotPages.Core/Context/PageContextAdapterExtensions.cs index c17e79d..5be1578 100644 --- a/BotPages.Core/Context/PageContextAdapterExtensions.cs +++ b/BotPages.Core/Context/PageContextAdapterExtensions.cs @@ -11,8 +11,8 @@ public static class PageContextAdapterExtensions /// /// Отправить текстовое сообщение. /// - public static Task SendTextAsync(this PageContext ctx, - string text, + public static Task SendTextAsync(this PageContext ctx, + string text, MessageFormat format = MessageFormat.Plain, IEnumerable>? inline = null, IEnumerable>? reply = null, @@ -23,17 +23,17 @@ public static class PageContextAdapterExtensions /// /// Отправить файл. /// - public static Task SendFileAsync(this PageContext ctx, - FileDescriptor file, - string? caption = null, + public static Task SendFileAsync(this PageContext ctx, + FileDescriptor file, + string? caption = null, MessageFormat? captionFormat = null, IEnumerable>? inline = null, IEnumerable>? reply = null, CancellationToken ct = default ) - => ctx.Adapter.SendFileAsync(chatId: ctx.Update.Chat.Id, - file: file, - caption: caption, + => ctx.Adapter.SendFileAsync(chatId: ctx.Update.Chat.Id, + file: file, + caption: caption, captionFormat: captionFormat, inline: inline, reply: reply, diff --git a/BotPages.Core/Routing/CommandHandler.cs b/BotPages.Core/Routing/CommandHandler.cs index ea69ba7..bd18af0 100644 --- a/BotPages.Core/Routing/CommandHandler.cs +++ b/BotPages.Core/Routing/CommandHandler.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BotPages.Core.Routing; +namespace BotPages.Core.Routing; /// /// Обработчик команды: получает контекст страницы, аргументы команды и токен отмены. diff --git a/BotPages.Core/Routing/RoutesRegistry.cs b/BotPages.Core/Routing/RoutesRegistry.cs index 066928d..19ee6c7 100644 --- a/BotPages.Core/Routing/RoutesRegistry.cs +++ b/BotPages.Core/Routing/RoutesRegistry.cs @@ -31,7 +31,7 @@ internal sealed class RoutesRegistry internal void Map(Type? type) { - foreach(var attr in type.GetCustomAttributes(inherit: true)) + foreach (var attr in type.GetCustomAttributes(inherit: true)) { _routes.Add(attr.Template, type); } diff --git a/BotPages.Telegram/TelegramAdapter.cs b/BotPages.Telegram/TelegramAdapter.cs index fecd067..fe0a958 100644 --- a/BotPages.Telegram/TelegramAdapter.cs +++ b/BotPages.Telegram/TelegramAdapter.cs @@ -10,7 +10,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Telegram.Bot; -using Telegram.Bot.Exceptions; using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.ReplyMarkups; @@ -91,11 +90,11 @@ public sealed class TelegramAdapter : IMessangerAdapterSetup } /// - public async Task SendTextAsync(string chatId, string text, + public async Task SendTextAsync(string chatId, string text, MessageFormat format = MessageFormat.Plain, IEnumerable>? inline = null, IEnumerable>? reply = null, - string? messageId = null, + string? messageId = null, CancellationToken ct = default) { if (_client is null) @@ -194,9 +193,9 @@ public sealed class TelegramAdapter : IMessangerAdapterSetup } /// - public async Task SendFileAsync(string chatId, - FileDescriptor file, - string? caption = null, + public async Task SendFileAsync(string chatId, + FileDescriptor file, + string? caption = null, MessageFormat? captionFormat = null, IEnumerable>? inline = null, IEnumerable>? reply = null, diff --git a/Demo/Pages/TitlePage.cs b/Demo/Pages/TitlePage.cs index f270e5d..b7f63b7 100644 --- a/Demo/Pages/TitlePage.cs +++ b/Demo/Pages/TitlePage.cs @@ -1,7 +1,6 @@ using BotPages.Core; using BotPages.Core.Abstractions; using BotPages.Core.Messaging; -using BotPages.Core.Routing; namespace Demo.Pages; ///