diff --git a/TelegramBotBase/Form/ButtonBase.cs b/TelegramBotBase/Form/ButtonBase.cs index 48891ab..6f6ed8d 100644 --- a/TelegramBotBase/Form/ButtonBase.cs +++ b/TelegramBotBase/Form/ButtonBase.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Telegram.Bot.Types.ReplyMarkups; namespace TelegramBotBase.Form { @@ -15,15 +16,35 @@ namespace TelegramBotBase.Form public String Value { get; set; } + public String Url { get; set; } + public ButtonBase() { } - public ButtonBase(String Text, String Value) + public ButtonBase(String Text, String Value, String Url = null) { this.Text = Text; this.Value = Value; + this.Url = Url; + } + + + public InlineKeyboardButton ToInlineButton() + { + if (this.Url == null) + { + return InlineKeyboardButton.WithCallbackData(this.Text, this.Value); + } + + var ikb = new InlineKeyboardButton(); + + ikb.Text = this.Text; + ikb.Url = this.Url; + + return ikb; + } } diff --git a/TelegramBotBase/Form/ButtonForm.cs b/TelegramBotBase/Form/ButtonForm.cs index fe60fbd..2a1cbf9 100644 --- a/TelegramBotBase/Form/ButtonForm.cs +++ b/TelegramBotBase/Form/ButtonForm.cs @@ -14,14 +14,18 @@ namespace TelegramBotBase.Form { List> Buttons = new List>(); + + public IReplyMarkup Markup { get; set; } + + public ButtonForm() { } - public void AddButtonRow(List row) + public void AddButtonRow(IEnumerable row) { - Buttons.Add(row); + Buttons.Add(row.ToList()); } public void AddButtonRow(params ButtonBase[] row) @@ -66,7 +70,7 @@ namespace TelegramBotBase.Form public InlineKeyboardButton[][] ToArray() { - var ikb = this.Buttons.Select(a => a.Select(b => InlineKeyboardButton.WithCallbackData(b.Text, b.Value)).ToArray()).ToArray(); + var ikb = this.Buttons.Select(a => a.Select(b => b.ToInlineButton()).ToArray()).ToArray(); return ikb; }