36 lines
1.6 KiB
C#
36 lines
1.6 KiB
C#
using Telegram.Bot.Types.ReplyMarkups;
|
|
|
|
namespace nsszcontactbot
|
|
{
|
|
internal static class InlineKeyboardMarkupExtensions
|
|
{
|
|
internal static InlineKeyboardMarkup AddCloseButton(this InlineKeyboardMarkup markup, bool newRow = true)
|
|
{
|
|
var buttonRow = newRow ? markup.AddNewRow() : markup;
|
|
return buttonRow.AddButton("❌ Закрыть", "close");
|
|
}
|
|
|
|
internal static InlineKeyboardMarkup AddPrevPageButton(this InlineKeyboardMarkup markup, int currentPage, string context = "", string text = "⬅️ Назад")
|
|
{
|
|
return markup.AddButton(text, $"page/{currentPage - 1}{(string.IsNullOrEmpty(context) ? "" : "/")}{context}");
|
|
}
|
|
|
|
internal static InlineKeyboardMarkup AddNextPageButton(this InlineKeyboardMarkup markup, int currentPage, string context = "", string text = "Вперед ➡️")
|
|
{
|
|
return markup.AddButton(text, $"page/{currentPage + 1}{(string.IsNullOrEmpty(context) ? "" : "/")}{context}");
|
|
}
|
|
|
|
internal static InlineKeyboardMarkup AddPaginator(this InlineKeyboardMarkup markup, int currentPage, int totalPages, string context = "", string textPrev = "⬅️ Назад", string textNext = "Вперед ➡️")
|
|
{
|
|
if (totalPages > 1)
|
|
{
|
|
if (currentPage > 1)
|
|
AddPrevPageButton(markup, currentPage, context, textPrev);
|
|
if (currentPage < totalPages)
|
|
AddNextPageButton(markup, currentPage, context, textNext);
|
|
}
|
|
return markup;
|
|
}
|
|
}
|
|
}
|