diff --git a/Deployf.Botf/BotController.cs b/Deployf.Botf/BotController.cs index 6525884..c9063db 100644 --- a/Deployf.Botf/BotController.cs +++ b/Deployf.Botf/BotController.cs @@ -147,6 +147,7 @@ protected async Task Send(string text, ParseMode mode) message = await Client.SendTextMessageAsync( ChatId == 0 ? Context!.GetSafeChatId()! : ChatId, text, + null, ParseMode.Html, replyMarkup: Message.Markup, cancellationToken: CancelToken, @@ -156,7 +157,8 @@ protected async Task Send(string text, ParseMode mode) { message = await Client.SendPhotoAsync( ChatId == 0 ? Context!.GetSafeChatId()! : ChatId, - Message.PhotoUrl, + new InputFileUrl(Message.PhotoUrl), + null, text, ParseMode.Html, replyMarkup: Message.Markup, @@ -196,7 +198,7 @@ public async Task Update(InlineKeyboardMarkup? markup = null, string? t messageId, messageText, previousMessage!, - nextMessagePhotoUrl, + new InputMediaPhoto(new InputFileUrl(nextMessagePhotoUrl)), markupValue, mode, Message.ReplyToMessageId, diff --git a/Deployf.Botf/Deployf.Botf.csproj b/Deployf.Botf/Deployf.Botf.csproj index 4f039e1..a240a2e 100644 --- a/Deployf.Botf/Deployf.Botf.csproj +++ b/Deployf.Botf/Deployf.Botf.csproj @@ -26,7 +26,7 @@ - + diff --git a/Deployf.Botf/Messages/MessageSender.cs b/Deployf.Botf/Messages/MessageSender.cs index 7ae4808..192875f 100644 --- a/Deployf.Botf/Messages/MessageSender.cs +++ b/Deployf.Botf/Messages/MessageSender.cs @@ -20,6 +20,7 @@ public async ValueTask Send(MessageBuilder message, CancellationToken t return await _client.SendTextMessageAsync( message.ChatId, message.Message, + null, message.ParseMode, replyMarkup: message.Markup, cancellationToken: token, @@ -30,7 +31,8 @@ public async ValueTask Send(MessageBuilder message, CancellationToken t { return await _client.SendPhotoAsync( message.ChatId, - message.PhotoUrl, + new InputFileUrl(message.PhotoUrl), + null, message.Message, message.ParseMode, replyMarkup: message.Markup, diff --git a/Deployf.Botf/System/UpdateMessageStrategies/EditTextMessageStrategy.cs b/Deployf.Botf/System/UpdateMessageStrategies/EditTextMessageStrategy.cs index 2aa8c83..d994f1d 100644 --- a/Deployf.Botf/System/UpdateMessageStrategies/EditTextMessageStrategy.cs +++ b/Deployf.Botf/System/UpdateMessageStrategies/EditTextMessageStrategy.cs @@ -17,9 +17,8 @@ public EditTextMessageStrategy(BotfBot bot) public bool CanHandle(IUpdateMessageContext context) { - var newMessageFileIsEmpty = string.IsNullOrEmpty(context.MediaFile?.FileId) && - string.IsNullOrEmpty(context.MediaFile?.Url); - + var newMessageFileIsEmpty = context.MediaFile is InputMediaDocument; + return context.PreviousMessage.Photo == null && newMessageFileIsEmpty; } diff --git a/Deployf.Botf/System/UpdateMessageStrategies/MediaToMediaFileStrategy.cs b/Deployf.Botf/System/UpdateMessageStrategies/MediaToMediaFileStrategy.cs index ab8718e..49540b4 100644 --- a/Deployf.Botf/System/UpdateMessageStrategies/MediaToMediaFileStrategy.cs +++ b/Deployf.Botf/System/UpdateMessageStrategies/MediaToMediaFileStrategy.cs @@ -17,9 +17,8 @@ public MediaToMediaFileStrategy(BotfBot bot) public bool CanHandle(IUpdateMessageContext context) { - var newMessageHasFile = !string.IsNullOrEmpty(context.MediaFile?.FileId) || - !string.IsNullOrEmpty(context.MediaFile?.Url); - + var newMessageHasFile = context.MediaFile is InputMediaDocument; + return context.PreviousMessage.Photo != null && newMessageHasFile; } @@ -31,7 +30,8 @@ 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.MediaFile!.Media, + null, context.MessageText, context.ParseMode, replyMarkup: context.KeyboardMarkup, @@ -43,7 +43,7 @@ public async Task UpdateMessage(IUpdateMessageContext context) return await _bot.Client.EditMessageMediaAsync( context.ChatId, context.MessageId, - new InputMediaPhoto(context.MediaFile!) + new InputMediaPhoto(context.MediaFile!.Media) { Caption = context.MessageText, ParseMode = context.ParseMode diff --git a/Deployf.Botf/System/UpdateMessageStrategies/MediaToPlainTextStrategy.cs b/Deployf.Botf/System/UpdateMessageStrategies/MediaToPlainTextStrategy.cs index 5069714..33e0cf3 100644 --- a/Deployf.Botf/System/UpdateMessageStrategies/MediaToPlainTextStrategy.cs +++ b/Deployf.Botf/System/UpdateMessageStrategies/MediaToPlainTextStrategy.cs @@ -17,9 +17,8 @@ public MediaToPlainTextStrategy(BotfBot bot) public bool CanHandle(IUpdateMessageContext context) { - var newMessageFileIsEmpty = string.IsNullOrEmpty(context.MediaFile?.FileId) && - string.IsNullOrEmpty(context.MediaFile?.Url); - + var newMessageFileIsEmpty = context.MediaFile is InputMediaDocument; + return context.PreviousMessage.Photo != null && newMessageFileIsEmpty; } @@ -29,6 +28,7 @@ public async Task UpdateMessage(IUpdateMessageContext context) return await _bot.Client.SendTextMessageAsync( context.ChatId, context.MessageText, + null, context.ParseMode, replyMarkup: context.KeyboardMarkup, cancellationToken: context.CancelToken, diff --git a/Deployf.Botf/System/UpdateMessageStrategies/PlainTextToMediaStrategy.cs b/Deployf.Botf/System/UpdateMessageStrategies/PlainTextToMediaStrategy.cs index 2a957cf..03eda06 100644 --- a/Deployf.Botf/System/UpdateMessageStrategies/PlainTextToMediaStrategy.cs +++ b/Deployf.Botf/System/UpdateMessageStrategies/PlainTextToMediaStrategy.cs @@ -17,9 +17,8 @@ public PlainTextToMediaStrategy(BotfBot bot) public bool CanHandle(IUpdateMessageContext context) { - var newMessageHasFile = !string.IsNullOrEmpty(context.MediaFile?.FileId) || - !string.IsNullOrEmpty(context.MediaFile?.Url); - + var newMessageHasFile = context.MediaFile is InputMediaDocument; + return context.PreviousMessage.Photo == null && newMessageHasFile; } @@ -28,7 +27,8 @@ 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.MediaFile!.Media, + null, context.MessageText, context.ParseMode, replyMarkup: context.KeyboardMarkup,