diff --git a/BotPages.Core/Messaging/MessageBuilder.cs b/BotPages.Core/Messaging/MessageBuilder.cs
index 2e17fc9..c32ef0b 100644
--- a/BotPages.Core/Messaging/MessageBuilder.cs
+++ b/BotPages.Core/Messaging/MessageBuilder.cs
@@ -17,6 +17,7 @@ public sealed class MessageBuilder
private string? _progressTitle = null;
private int? _progressPercent = null;
private string? _progressMessageId = null;
+ private bool _disableReplyKeyboard;
/// Создать билдер сообщений.
public MessageBuilder(PageContext ctx) => _ctx = ctx;
@@ -64,9 +65,20 @@ public sealed class MessageBuilder
return this;
}
+ ///
+ /// Отключение Reply клавиатуры.
+ ///
+ ///
+ public MessageBuilder DisableReply()
+ {
+ _disableReplyKeyboard = true;
+ return this;
+ }
+
/// Добавить reply‑кнопку.
public MessageBuilder Reply(params ReplyButton[] label)
{
+ _disableReplyKeyboard = false;
_reply.Add(label.ToList());
return this;
}
@@ -74,6 +86,7 @@ public sealed class MessageBuilder
/// Добавить строку reply‑кнопок.
public MessageBuilder Reply(IEnumerable row)
{
+ _disableReplyKeyboard = false;
_reply.Add(row.ToList());
return this;
}
@@ -81,6 +94,7 @@ public sealed class MessageBuilder
/// Добавить строку reply‑кнопок.
public MessageBuilder Reply(IEnumerable> row)
{
+ _disableReplyKeyboard = false;
_reply.AddRange(row.Select(t => t.ToList()).ToList());
return this;
}
@@ -113,7 +127,11 @@ public sealed class MessageBuilder
// Текст
if (!string.IsNullOrWhiteSpace(_text))
{
- await _ctx.SendTextAsync(_text, _format, _inline, _reply, ct);
+ List>? reply = null;
+ if (_disableReplyKeyboard) reply = new();
+ else if (_reply.Any()) reply = _reply;
+
+ await _ctx.SendTextAsync(_text, _format, _inline, reply, ct);
}
// Файлы
diff --git a/BotPages.Telegram/TelegramAdapter.cs b/BotPages.Telegram/TelegramAdapter.cs
index 774956a..495a254 100644
--- a/BotPages.Telegram/TelegramAdapter.cs
+++ b/BotPages.Telegram/TelegramAdapter.cs
@@ -104,14 +104,21 @@ public sealed class TelegramAdapter : IMessangerAdapterSetup
.ToArray()
);
}
- else if (reply is not null && reply.Any())
+ else if (reply is not null)
{
- markup = new ReplyKeyboardMarkup(
- reply.Select(row => row.Select(b => new KeyboardButton(b.Label)).ToArray()).ToArray()
- )
+ if (reply.Any())
{
- ResizeKeyboard = true
- };
+ markup = new ReplyKeyboardMarkup(
+ reply.Select(row => row.Select(b => new KeyboardButton(b.Label)).ToArray()).ToArray()
+ )
+ {
+ ResizeKeyboard = true
+ };
+ }
+ else
+ {
+ markup = new ReplyKeyboardRemove();
+ }
}
var parseMode = ParseMode.None;