Skip to content

Commit b309d6f

Browse files
Merge pull request #81 from HedgehogNSK/master
feat(keyboard): extend IInlineKeyboardRow with builder methods + serialization fixes
2 parents b6422f7 + 4aa8927 commit b309d6f

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/RxTelegram.Bot/Interface/BaseTypes/InlineKeyboardButton.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class InlineKeyboardButton
6060
/// <summary>
6161
/// Optional. Description of the button that copies the specified text to the clipboard.
6262
/// </summary>
63-
public CopyTextButton CopyTextButton { get; set; }
63+
public CopyTextButton CopyText { get; set; }
6464

6565
/// <summary>
6666
/// Optional. Description of the game that will be launched when the user presses the button.
@@ -72,5 +72,5 @@ public class InlineKeyboardButton
7272
/// Optional. Specify True, to send a Pay button.
7373
/// NOTE: This type of button must always be the first button in the first row.
7474
/// </summary>
75-
public bool Pay { get; set; }
75+
public bool? Pay { get; set; }
7676
}

src/RxTelegram.Bot/Utils/Keyboard/Interfaces/IInlineKeyboardRow.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ namespace RxTelegram.Bot.Utils.Keyboard.Interfaces;
44

55
public interface IInlineKeyboardRow
66
{
7+
public IInlineKeyboardRow AddButton(InlineKeyboardButton button);
8+
79
public IInlineKeyboardRow AddUrl(string text, string url);
810

911
public IInlineKeyboardRow AddLoginUrl(string text, LoginUrl loginUrl);
@@ -14,6 +16,8 @@ public interface IInlineKeyboardRow
1416

1517
public IInlineKeyboardRow AddCallbackGame(string text);
1618

19+
public IInlineKeyboardRow AddCopyText(string text, string copyText);
20+
1721
public IInlineKeyboardRow AddSwitchInlineQuery(string text, string switchInlineQuery);
1822

1923
public IInlineKeyboardRow AddSetSwitchInlineQueryCurrentChat(string text, string switchInlineQueryCurrentChat);

src/RxTelegram.Bot/Utils/Keyboard/KeyboardBuilder.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,25 @@ public IInlineKeyboardRow AddCallbackGame(string text)
137137
return this;
138138
}
139139

140+
public IInlineKeyboardRow AddCopyText(string text, string copyText)
141+
{
142+
_inlineRow.Add(new InlineKeyboardButton
143+
{
144+
Text = text,
145+
CopyText = new CopyTextButton()
146+
{
147+
Text = copyText
148+
}
149+
});
150+
return this;
151+
}
152+
153+
public IInlineKeyboardRow AddButton(InlineKeyboardButton button)
154+
{
155+
_inlineRow.Add(button);
156+
return this;
157+
}
158+
140159
public IInlineKeyboardRow AddSwitchInlineQuery(string text, string switchInlineQuery)
141160
{
142161
_inlineRow.Add(new InlineKeyboardButton { Text = text, SwitchInlineQuery = switchInlineQuery });

0 commit comments

Comments
 (0)