From e182baffdb8900f07ea413d6bb594cd155465daf Mon Sep 17 00:00:00 2001 From: wellon Date: Mon, 8 May 2023 20:24:41 +0300 Subject: [PATCH 1/4] Fix for photo message updating --- Deployf.Botf/BotController.cs | 61 ++++++++++++++++--- Deployf.Botf/StartupExtensions.cs | 9 ++- .../System/UpdateContextExtensions.cs | 22 +++++++ .../EditTextMessageStrategy.cs | 37 +++++++++++ .../UpdateMessageStrategies/FileStrategy1.cs | 37 +++++++++++ .../UpdateMessageStrategies/FileStrategy2.cs | 38 ++++++++++++ .../UpdateMessageStrategies/FileStrategy3.cs | 55 +++++++++++++++++ .../IUpdateMessageStrategy.cs | 9 +++ .../IUpdateMessageStrategyFactory.cs | 21 +++++++ .../UpdateMessageContext.cs | 24 ++++++++ 10 files changed, 304 insertions(+), 9 deletions(-) create mode 100644 Deployf.Botf/System/UpdateMessageStrategies/EditTextMessageStrategy.cs create mode 100644 Deployf.Botf/System/UpdateMessageStrategies/FileStrategy1.cs create mode 100644 Deployf.Botf/System/UpdateMessageStrategies/FileStrategy2.cs create mode 100644 Deployf.Botf/System/UpdateMessageStrategies/FileStrategy3.cs create mode 100644 Deployf.Botf/System/UpdateMessageStrategies/IUpdateMessageStrategy.cs create mode 100644 Deployf.Botf/System/UpdateMessageStrategies/IUpdateMessageStrategyFactory.cs create mode 100644 Deployf.Botf/System/UpdateMessageStrategies/UpdateMessageContext.cs diff --git a/Deployf.Botf/BotController.cs b/Deployf.Botf/BotController.cs index b555297..6525884 100644 --- a/Deployf.Botf/BotController.cs +++ b/Deployf.Botf/BotController.cs @@ -1,4 +1,5 @@ using System.Linq.Expressions; +using Deployf.Botf.System.UpdateMessageStrategies; using Telegram.Bot; using Telegram.Bot.Framework.Abstractions; using Telegram.Bot.Types; @@ -19,6 +20,7 @@ public abstract class BotController protected ITelegramBotClient Client { get; set; } = null!; protected MessageBuilder Message { get; set; } = new MessageBuilder(); public IKeyValueStorage? Store { get; set; } + public IUpdateMessageStrategyFactory UpdateMessageStrategyFactory { get; set; } public int? MessageId { get; set; } protected bool IsDirty @@ -35,6 +37,7 @@ public virtual void Init(IUpdateContext context, CancellationToken cancellationT FromId = Context.GetSafeUserId().GetValueOrDefault(); Client = Context.Bot.Client; Store = Context.Services.GetService(); // todo: move outside + UpdateMessageStrategyFactory = Context.Services.GetRequiredService(); Message = new MessageBuilder(); } @@ -180,14 +183,46 @@ public async Task Update(InlineKeyboardMarkup? markup = null, string? t { var markupValue = markup ?? Message.Markup as InlineKeyboardMarkup; IsDirty = false; - var message = await Client.EditMessageTextAsync( - ChatId == 0 ? Context!.GetSafeChatId()! : ChatId, - MessageId ?? Context!.GetSafeMessageId().GetValueOrDefault(), - text ?? Message.Message, - parseMode: mode, - replyMarkup: markupValue, - cancellationToken: CancelToken - ); + + var chatId = Context!.GetSafeChatId()!.Value; + var messageId = MessageId ?? Context!.GetSafeMessageId().GetValueOrDefault(); + var messageText = text ?? Message.Message; + var previousMessage = Context.Update.CallbackQuery!.Message; + var nextMessagePhotoUrl = Message.PhotoUrl; + + var ctx = new UpdateMessageContext( + Context, + chatId, + messageId, + messageText, + previousMessage!, + nextMessagePhotoUrl, + markupValue, + mode, + Message.ReplyToMessageId, + CancelToken); + + Message message; + var strategy = UpdateMessageStrategyFactory.GetStrategy(ctx); + if (strategy == null) + { + var logger = Context.Services.GetRequiredService>(); + logger.LogDebug("Not found a suitable strategy, using default instead"); + + message = await Client.EditMessageTextAsync( + ChatId == 0 ? Context!.GetSafeChatId()! : ChatId, + MessageId ?? Context!.GetSafeMessageId().GetValueOrDefault(), + text ?? Message.Message, + parseMode: mode, + replyMarkup: markupValue, + cancellationToken: CancelToken + ); + } + else + { + message = await strategy.UpdateMessage(ctx); + } + await TrySaveLastMessageId(markupValue, message); ClearMessage(); return message; @@ -384,6 +419,16 @@ public void Reply(int? messageId = default) } } + /// + /// Sets photo for message + /// + /// Attention! Telegram limit is 0-1024 characters for text messages with images + /// + /// Photo url to send. Pass a FileId as String to send a photo that exists on + /// the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from + /// the Internet. The photo must be at most 10 MB in size. + /// The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20 + /// public void Photo(string url) { Message.SetPhotoUrl(url); diff --git a/Deployf.Botf/StartupExtensions.cs b/Deployf.Botf/StartupExtensions.cs index 596b5b7..c45901e 100644 --- a/Deployf.Botf/StartupExtensions.cs +++ b/Deployf.Botf/StartupExtensions.cs @@ -1,4 +1,5 @@ -using Telegram.Bot; +using Deployf.Botf.System.UpdateMessageStrategies; +using Telegram.Bot; using Telegram.Bot.Framework; using Telegram.Bot.Framework.Abstractions; using Telegram.Bot.Requests; @@ -133,6 +134,12 @@ public static IServiceCollection AddBotf(this IServiceCollection services, BotfO services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + return services; } diff --git a/Deployf.Botf/System/UpdateContextExtensions.cs b/Deployf.Botf/System/UpdateContextExtensions.cs index cc01c11..5817119 100644 --- a/Deployf.Botf/System/UpdateContextExtensions.cs +++ b/Deployf.Botf/System/UpdateContextExtensions.cs @@ -5,6 +5,7 @@ namespace Deployf.Botf; public static class UpdateContextExtensions { + private const string UPDATE_MESSAGE_POLICY_KEY = "$_UpdateMessagePolicy"; private const string STOP_HANDLING_KEY = "$_StopHandling"; private const string CURRENT_HANDLER_KEY = "$_CurrentHandler"; private const string FILTER_PARAMETER_KEY = "$_FilterParameter"; @@ -200,4 +201,25 @@ public static void SetFilterParameter(this IUpdateContext context, object? param return null; } + + public static void SetUpdateMsgPolicy(this IUpdateContext context, UpdateMessagePolicy policy) + { + context.Items[UPDATE_MESSAGE_POLICY_KEY] = policy; + } + + public static UpdateMessagePolicy? GetCurrentUpdateMsgPolicy(this IUpdateContext context) + { + if(context.Items.TryGetValue(UPDATE_MESSAGE_POLICY_KEY, out var policy) && policy is UpdateMessagePolicy result) + { + return result; + } + + return null; + } +} + +public enum UpdateMessagePolicy +{ + UpdateContent = 0, // default + DeleteAndSend = 1 } \ No newline at end of file diff --git a/Deployf.Botf/System/UpdateMessageStrategies/EditTextMessageStrategy.cs b/Deployf.Botf/System/UpdateMessageStrategies/EditTextMessageStrategy.cs new file mode 100644 index 0000000..2aa8c83 --- /dev/null +++ b/Deployf.Botf/System/UpdateMessageStrategies/EditTextMessageStrategy.cs @@ -0,0 +1,37 @@ +using Telegram.Bot; +using Telegram.Bot.Types; + +namespace Deployf.Botf.System.UpdateMessageStrategies; + +/// +/// Situation: previous message has no media file and a new message does not have. +/// +public class EditTextMessageStrategy : IUpdateMessageStrategy +{ + private readonly BotfBot _bot; + + public EditTextMessageStrategy(BotfBot bot) + { + _bot = bot; + } + + public bool CanHandle(IUpdateMessageContext context) + { + var newMessageFileIsEmpty = string.IsNullOrEmpty(context.MediaFile?.FileId) && + string.IsNullOrEmpty(context.MediaFile?.Url); + + return context.PreviousMessage.Photo == null && newMessageFileIsEmpty; + } + + public async Task UpdateMessage(IUpdateMessageContext context) + { + return await _bot.Client.EditMessageTextAsync( + context.ChatId, + context.MessageId, + context.MessageText, + parseMode: context.ParseMode, + replyMarkup: context.KeyboardMarkup, + cancellationToken: context.CancelToken + ); + } +} \ No newline at end of file diff --git a/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy1.cs b/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy1.cs new file mode 100644 index 0000000..8d968e1 --- /dev/null +++ b/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy1.cs @@ -0,0 +1,37 @@ +using Telegram.Bot; +using Telegram.Bot.Types; + +namespace Deployf.Botf.System.UpdateMessageStrategies; + +/// +/// Situation: previous message has media file, but a new message does not have. +/// +public class FileStrategy1 : IUpdateMessageStrategy +{ + private readonly BotfBot _bot; + + public FileStrategy1(BotfBot bot) + { + _bot = bot; + } + + public bool CanHandle(IUpdateMessageContext context) + { + var newMessageFileIsEmpty = string.IsNullOrEmpty(context.MediaFile?.FileId) && + string.IsNullOrEmpty(context.MediaFile?.Url); + + return context.PreviousMessage.Photo != null && newMessageFileIsEmpty; + } + + public async Task UpdateMessage(IUpdateMessageContext context) + { + await _bot.Client.DeleteMessageAsync(context.ChatId, context.PreviousMessage.MessageId, context.CancelToken); + return await _bot.Client.SendTextMessageAsync( + context.ChatId, + context.MessageText, + context.ParseMode, + replyMarkup: context.KeyboardMarkup, + cancellationToken: context.CancelToken, + replyToMessageId: context.ReplyToMessageId); + } +} \ No newline at end of file diff --git a/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy2.cs b/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy2.cs new file mode 100644 index 0000000..b2cab5a --- /dev/null +++ b/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy2.cs @@ -0,0 +1,38 @@ +using Telegram.Bot; +using Telegram.Bot.Types; + +namespace Deployf.Botf.System.UpdateMessageStrategies; + +/// +/// Situation: previous message has no media file, but a new message has one. +/// +public class FileStrategy2 : IUpdateMessageStrategy +{ + private readonly BotfBot _bot; + + public FileStrategy2(BotfBot bot) + { + _bot = bot; + } + + public bool CanHandle(IUpdateMessageContext context) + { + var newMessageHasFile = !string.IsNullOrEmpty(context.MediaFile?.FileId) || + !string.IsNullOrEmpty(context.MediaFile?.Url); + + return context.PreviousMessage.Photo == null && newMessageHasFile; + } + + public async Task UpdateMessage(IUpdateMessageContext context) + { + await _bot.Client.DeleteMessageAsync(context.ChatId, context.PreviousMessage.MessageId, context.CancelToken); + return await _bot.Client.SendPhotoAsync( + context.ChatId, + context.MediaFile!, + context.MessageText, + context.ParseMode, + replyMarkup: context.KeyboardMarkup, + cancellationToken: context.CancelToken, + replyToMessageId: context.ReplyToMessageId); + } +} \ No newline at end of file diff --git a/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy3.cs b/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy3.cs new file mode 100644 index 0000000..3b068ff --- /dev/null +++ b/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy3.cs @@ -0,0 +1,55 @@ +using Telegram.Bot; +using Telegram.Bot.Types; + +namespace Deployf.Botf.System.UpdateMessageStrategies; + +/// +/// Situation: previous message has a media file and a new message has one. +/// +public class FileStrategy3 : IUpdateMessageStrategy +{ + private readonly BotfBot _bot; + + public FileStrategy3(BotfBot bot) + { + _bot = bot; + } + + public bool CanHandle(IUpdateMessageContext context) + { + var newMessageHasFile = !string.IsNullOrEmpty(context.MediaFile?.FileId) || + !string.IsNullOrEmpty(context.MediaFile?.Url); + + return context.PreviousMessage.Photo != null && newMessageHasFile; + } + + public async Task UpdateMessage(IUpdateMessageContext context) + { + var updateMessagePolicy = context.UpdateContext.GetCurrentUpdateMsgPolicy(); + if (updateMessagePolicy is UpdateMessagePolicy.DeleteAndSend) + { + await _bot.Client.DeleteMessageAsync(context.ChatId, context.PreviousMessage.MessageId, context.CancelToken); + return await _bot.Client.SendPhotoAsync( + context.ChatId, + context.MediaFile!, + context.MessageText, + context.ParseMode, + replyMarkup: context.KeyboardMarkup, + cancellationToken: context.CancelToken, + replyToMessageId: context.ReplyToMessageId); + } + else + { + return await _bot.Client.EditMessageMediaAsync( + context.ChatId, + context.MessageId, + new InputMediaPhoto(context.MediaFile!) + { + Caption = context.MessageText + }, + replyMarkup: context.KeyboardMarkup, + cancellationToken: context.CancelToken + ); + } + } +} \ No newline at end of file diff --git a/Deployf.Botf/System/UpdateMessageStrategies/IUpdateMessageStrategy.cs b/Deployf.Botf/System/UpdateMessageStrategies/IUpdateMessageStrategy.cs new file mode 100644 index 0000000..b547914 --- /dev/null +++ b/Deployf.Botf/System/UpdateMessageStrategies/IUpdateMessageStrategy.cs @@ -0,0 +1,9 @@ +using Telegram.Bot.Types; + +namespace Deployf.Botf.System.UpdateMessageStrategies; + +public interface IUpdateMessageStrategy +{ + public bool CanHandle(IUpdateMessageContext context); + public Task UpdateMessage(IUpdateMessageContext context); +} \ No newline at end of file diff --git a/Deployf.Botf/System/UpdateMessageStrategies/IUpdateMessageStrategyFactory.cs b/Deployf.Botf/System/UpdateMessageStrategies/IUpdateMessageStrategyFactory.cs new file mode 100644 index 0000000..379962a --- /dev/null +++ b/Deployf.Botf/System/UpdateMessageStrategies/IUpdateMessageStrategyFactory.cs @@ -0,0 +1,21 @@ +namespace Deployf.Botf.System.UpdateMessageStrategies; + +public interface IUpdateMessageStrategyFactory +{ + IUpdateMessageStrategy? GetStrategy(IUpdateMessageContext context); +} + +public class UpdateMessageStrategyFactory : IUpdateMessageStrategyFactory +{ + private readonly IEnumerable _strategies; + + public UpdateMessageStrategyFactory(IEnumerable strategies) + { + _strategies = strategies; + } + + public IUpdateMessageStrategy? GetStrategy(IUpdateMessageContext context) + { + return _strategies.FirstOrDefault(s => s.CanHandle(context)); + } +} \ No newline at end of file diff --git a/Deployf.Botf/System/UpdateMessageStrategies/UpdateMessageContext.cs b/Deployf.Botf/System/UpdateMessageStrategies/UpdateMessageContext.cs new file mode 100644 index 0000000..e0a1069 --- /dev/null +++ b/Deployf.Botf/System/UpdateMessageStrategies/UpdateMessageContext.cs @@ -0,0 +1,24 @@ +using Telegram.Bot.Framework.Abstractions; +using Telegram.Bot.Types; +using Telegram.Bot.Types.Enums; +using Telegram.Bot.Types.ReplyMarkups; + +namespace Deployf.Botf.System.UpdateMessageStrategies; + +public interface IUpdateMessageContext +{ + public IUpdateContext UpdateContext { get; init; } + public long ChatId { get; init; } + public int MessageId { get; init; } + public string MessageText { get; init; } + public Message PreviousMessage { get; init; } + public InputMedia? MediaFile { get; init; } + public InlineKeyboardMarkup? KeyboardMarkup { get; init; } + public ParseMode ParseMode { get; init; } + public int ReplyToMessageId { get; init; } + public CancellationToken CancelToken { get; init; } +} + +public record UpdateMessageContext(IUpdateContext UpdateContext, long ChatId, int MessageId, string MessageText, Message PreviousMessage, + InputMedia? MediaFile, InlineKeyboardMarkup? KeyboardMarkup, ParseMode ParseMode, int ReplyToMessageId, + CancellationToken CancelToken) : IUpdateMessageContext; \ No newline at end of file From 64c1bc77eaae3c5ba9f8f4bfb88d9f233a5f8c40 Mon Sep 17 00:00:00 2001 From: wellon Date: Mon, 8 May 2023 20:39:28 +0300 Subject: [PATCH 2/4] Updated an example project --- Examples/Deployf.Botf.MediaExample/Program.cs | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/Examples/Deployf.Botf.MediaExample/Program.cs b/Examples/Deployf.Botf.MediaExample/Program.cs index 3265c86..2346131 100644 --- a/Examples/Deployf.Botf.MediaExample/Program.cs +++ b/Examples/Deployf.Botf.MediaExample/Program.cs @@ -4,12 +4,115 @@ class MediaController : BotController { + /* + * There is a picture in the 1st message, but not in the 2nd. + * What should happen: + * The 1st will be deleted and the second will be sent + */ + + #region 1st scenario + [Action("/start")] void Start() { // Add the photo to message Photo("https://avatars.githubusercontent.com/u/59260433"); Push("Hello from deploy-f"); + Button("Got to botf repo", Q(Test1)); + } + + [Action] + void Test1() + { + Push("Test1"); + Button("Got to botf repo", "https://github.com/deploy-f/botf"); + } + + #endregion + + + /* + * There is no picture in the 1st message, but there is in the 2nd. + * What should happen: + * The 1st will be deleted and the second will be sent + */ + + #region 2й scenario + + [Action("/start2")] + void Start2() + { + Push("Hello from deploy-f"); + Button("Got to botf repo", Q(Test2)); + } + + [Action] + void Test2() + { + // Add the photo to message + Photo("https://avatars.githubusercontent.com/u/59260433"); + Push("Test2"); + Button("Got to botf repo", "https://github.com/deploy-f/botf"); + } + + #endregion + + + /* + * There is no picture in the 1st message and there is no picture in the 2nd either. + * What should happen: + * 1st message update via without deletion + */ + + #region 3й scenario + + [Action("/start3")] + void Start3() + { + Push("Hello from deploy-f"); + Button("Got to botf repo", Q(Test3)); + } + + [Action] + void Test3() + { + Push("Test3"); + Button("Got to botf repo", "https://github.com/deploy-f/botf"); + } + + #endregion + + + /* + * In the 1st message there is a picture and in the 2nd there is. + * What should happen: + * The 1st message will update its text and image without deleting. + * If you specify UpdateMessagePolicy to DeleteAndSend, so the 1st message will be deleted + * and new message with new picture will be sent + * Note from Telegram: When an inline message is edited, a new file can't be uploaded; + * use a previously uploaded file via its file_id or specify a URL. + */ + + #region 4й scenario + + [Action("/start4")] + void Start4() + { + // Add the photo to message + Photo("https://avatars.githubusercontent.com/u/59260433"); + Push("Hello from deploy-f"); + Button("Got to botf repo", Q(Test4)); + } + + [Action] + void Test4() + { + Context.SetUpdateMsgPolicy(UpdateMessagePolicy.UpdateContent); + // Add a new photo to message + Photo("https://icons-for-free.com/iconfiles/png/512/csharp+line-1324760527290176528.png"); + Push("Test4"); Button("Got to botf repo", "https://github.com/deploy-f/botf"); } + + #endregion } \ No newline at end of file From 56304b870e6e5e38610442996a1ac90bfe603648 Mon Sep 17 00:00:00 2001 From: wellon Date: Mon, 8 May 2023 20:42:33 +0300 Subject: [PATCH 3/4] Fix an exception --- Deployf.Botf/System/BotfException.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Deployf.Botf/System/BotfException.cs b/Deployf.Botf/System/BotfException.cs index ac51b39..5b15853 100644 --- a/Deployf.Botf/System/BotfException.cs +++ b/Deployf.Botf/System/BotfException.cs @@ -1,12 +1,14 @@ +using System.Runtime.Serialization; + namespace Deployf.Botf; -[System.Serializable] -public class BotfException : System.Exception +[Serializable] +public class BotfException : Exception { public BotfException() { } public BotfException(string message) : base(message) { } - public BotfException(string message, System.Exception inner) : base(message, inner) { } + public BotfException(string message, Exception inner) : base(message, inner) { } protected BotfException( - System.Runtime.Serialization.SerializationInfo info, - System.Runtime.Serialization.StreamingContext context) : base(info, context) { } + SerializationInfo info, + StreamingContext context) : base(info, context) { } } From 0175aff91d6f7cb2e149deb4a01e2a7be40e7a62 Mon Sep 17 00:00:00 2001 From: wellon Date: Mon, 8 May 2023 20:50:29 +0300 Subject: [PATCH 4/4] renamed strategies --- Deployf.Botf/StartupExtensions.cs | 6 +++--- .../{FileStrategy3.cs => MediaToMediaFileStrategy.cs} | 4 ++-- .../{FileStrategy1.cs => MediaToPlainTextStrategy.cs} | 4 ++-- .../{FileStrategy2.cs => PlainTextToMediaStrategy.cs} | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) rename Deployf.Botf/System/UpdateMessageStrategies/{FileStrategy3.cs => MediaToMediaFileStrategy.cs} (94%) rename Deployf.Botf/System/UpdateMessageStrategies/{FileStrategy1.cs => MediaToPlainTextStrategy.cs} (90%) rename Deployf.Botf/System/UpdateMessageStrategies/{FileStrategy2.cs => PlainTextToMediaStrategy.cs} (90%) diff --git a/Deployf.Botf/StartupExtensions.cs b/Deployf.Botf/StartupExtensions.cs index c45901e..682e4a0 100644 --- a/Deployf.Botf/StartupExtensions.cs +++ b/Deployf.Botf/StartupExtensions.cs @@ -134,9 +134,9 @@ public static IServiceCollection AddBotf(this IServiceCollection services, BotfO services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); diff --git a/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy3.cs b/Deployf.Botf/System/UpdateMessageStrategies/MediaToMediaFileStrategy.cs similarity index 94% rename from Deployf.Botf/System/UpdateMessageStrategies/FileStrategy3.cs rename to Deployf.Botf/System/UpdateMessageStrategies/MediaToMediaFileStrategy.cs index 3b068ff..3068878 100644 --- a/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy3.cs +++ b/Deployf.Botf/System/UpdateMessageStrategies/MediaToMediaFileStrategy.cs @@ -6,11 +6,11 @@ namespace Deployf.Botf.System.UpdateMessageStrategies; /// /// Situation: previous message has a media file and a new message has one. /// -public class FileStrategy3 : IUpdateMessageStrategy +public class MediaToMediaFileStrategy : IUpdateMessageStrategy { private readonly BotfBot _bot; - public FileStrategy3(BotfBot bot) + public MediaToMediaFileStrategy(BotfBot bot) { _bot = bot; } diff --git a/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy1.cs b/Deployf.Botf/System/UpdateMessageStrategies/MediaToPlainTextStrategy.cs similarity index 90% rename from Deployf.Botf/System/UpdateMessageStrategies/FileStrategy1.cs rename to Deployf.Botf/System/UpdateMessageStrategies/MediaToPlainTextStrategy.cs index 8d968e1..5069714 100644 --- a/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy1.cs +++ b/Deployf.Botf/System/UpdateMessageStrategies/MediaToPlainTextStrategy.cs @@ -6,11 +6,11 @@ namespace Deployf.Botf.System.UpdateMessageStrategies; /// /// Situation: previous message has media file, but a new message does not have. /// -public class FileStrategy1 : IUpdateMessageStrategy +public class MediaToPlainTextStrategy : IUpdateMessageStrategy { private readonly BotfBot _bot; - public FileStrategy1(BotfBot bot) + public MediaToPlainTextStrategy(BotfBot bot) { _bot = bot; } diff --git a/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy2.cs b/Deployf.Botf/System/UpdateMessageStrategies/PlainTextToMediaStrategy.cs similarity index 90% rename from Deployf.Botf/System/UpdateMessageStrategies/FileStrategy2.cs rename to Deployf.Botf/System/UpdateMessageStrategies/PlainTextToMediaStrategy.cs index b2cab5a..2a957cf 100644 --- a/Deployf.Botf/System/UpdateMessageStrategies/FileStrategy2.cs +++ b/Deployf.Botf/System/UpdateMessageStrategies/PlainTextToMediaStrategy.cs @@ -6,11 +6,11 @@ namespace Deployf.Botf.System.UpdateMessageStrategies; /// /// Situation: previous message has no media file, but a new message has one. /// -public class FileStrategy2 : IUpdateMessageStrategy +public class PlainTextToMediaStrategy : IUpdateMessageStrategy { private readonly BotfBot _bot; - public FileStrategy2(BotfBot bot) + public PlainTextToMediaStrategy(BotfBot bot) { _bot = bot; }