From 164194ac660ef822f524b2f6b5ddd92790d34ed9 Mon Sep 17 00:00:00 2001 From: FlorianDahn Date: Fri, 27 Mar 2020 12:08:34 +0700 Subject: [PATCH] Update - adding more Constants to Telegram file - Buttongrid: fixing check for rows and columns - Buttongrid: replacingvalues with constants from Telegram file --- TelegramBotBase/Constants/Telegram.cs | 8 ++++++++ TelegramBotBase/Controls/ButtonGrid.cs | 16 ++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/TelegramBotBase/Constants/Telegram.cs b/TelegramBotBase/Constants/Telegram.cs index c2287a2..b7392ee 100644 --- a/TelegramBotBase/Constants/Telegram.cs +++ b/TelegramBotBase/Constants/Telegram.cs @@ -13,5 +13,13 @@ namespace TelegramBotBase.Constants /// public const int MaxMessageLength = 4096; + public const int MaxInlineKeyBoardRows = 13; + + public const int MaxInlineKeyBoardCols = 8; + + public const int MaxReplyKeyboardRows = 25; + + public const int MaxReplyKeyboardCols = 12; + } } diff --git a/TelegramBotBase/Controls/ButtonGrid.cs b/TelegramBotBase/Controls/ButtonGrid.cs index aab7431..56d3ab4 100644 --- a/TelegramBotBase/Controls/ButtonGrid.cs +++ b/TelegramBotBase/Controls/ButtonGrid.cs @@ -167,27 +167,27 @@ namespace TelegramBotBase.Controls { case eKeyboardType.InlineKeyBoard: - if (ButtonsForm.Rows > 13) + if (ButtonsForm.Rows > Constants.Telegram.MaxInlineKeyBoardRows) { - throw new MaximumRowsReachedException() { Value = ButtonsForm.Rows, Maximum = 13 }; + throw new MaximumRowsReachedException() { Value = ButtonsForm.Rows, Maximum = Constants.Telegram.MaxInlineKeyBoardRows }; } - if (ButtonsForm.Rows > 8) + if (ButtonsForm.Cols > Constants.Telegram.MaxInlineKeyBoardCols) { - throw new MaximumColsException() { Value = ButtonsForm.Rows, Maximum = 8 }; + throw new MaximumColsException() { Value = ButtonsForm.Rows, Maximum = Constants.Telegram.MaxInlineKeyBoardCols }; } break; case eKeyboardType.ReplyKeyboard: - if (ButtonsForm.Rows > 25) + if (ButtonsForm.Rows > Constants.Telegram.MaxReplyKeyboardRows) { - throw new MaximumRowsReachedException() { Value = ButtonsForm.Rows, Maximum = 25 }; + throw new MaximumRowsReachedException() { Value = ButtonsForm.Rows, Maximum = Constants.Telegram.MaxReplyKeyboardRows }; } - if (ButtonsForm.Rows > 12) + if (ButtonsForm.Cols > Constants.Telegram.MaxReplyKeyboardCols) { - throw new MaximumColsException() { Value = ButtonsForm.Rows, Maximum = 12 }; + throw new MaximumColsException() { Value = ButtonsForm.Rows, Maximum = Constants.Telegram.MaxReplyKeyboardCols }; } break;