From 26024a4518128c9c426c6fa45417d4da929596bc Mon Sep 17 00:00:00 2001 From: BlubbFish Date: Sat, 25 Nov 2017 11:00:48 +0000 Subject: [PATCH] =?UTF-8?q?[NF]=20Zway-Bot=20hinzugef=C3=BCgt=20[NF]=20Vie?= =?UTF-8?q?le=20kleine=20=C3=84nderungen=20an=20Zwaylib=20zur=20Verbesseru?= =?UTF-8?q?ng=20der=20Kompatibilit=C3=A4t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IoT/Connector/User/Telegram.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/IoT/Connector/User/Telegram.cs b/IoT/Connector/User/Telegram.cs index 3c153e0..1ff02c0 100644 --- a/IoT/Connector/User/Telegram.cs +++ b/IoT/Connector/User/Telegram.cs @@ -32,7 +32,7 @@ namespace BlubbFish.Utils.IoT.Connector.User { public async override void Send(String message) { try { - Message x = await this.bot.SendTextMessageAsync(this.chat, message); + Message x = await this.bot.SendTextMessageAsync(this.chat, message, ParseMode.Default, false, false, 0, new ReplyKeyboardRemove()); this.MessageSending?.Invoke(this, new UserMessageEventArgs(x.Text, x.Chat.Id, x.Date)); } catch(ApiRequestException e) { Console.ForegroundColor = ConsoleColor.Red; @@ -49,9 +49,13 @@ namespace BlubbFish.Utils.IoT.Connector.User { public async override void Send(String message, String[] buttons) { try { - KeyboardButton[] button = new KeyboardButton[buttons.Length]; - for(Int32 i = 0; i < button.Length; i++) { - button[i] = new KeyboardButton(buttons[i]); + KeyboardButton[][] button = new KeyboardButton[(Int32)Math.Ceiling(((Double)buttons.Length)/2)][]; + for(Int32 i = 0; i < buttons.Length; i++) { + Int32 j = (Int32)Math.Floor(((Double)i) / 2); + if (i % 2 == 0) { + button[j] = new KeyboardButton[(j == button.Length - 1) ? ((buttons.Length % 2 == 0) ? 2 : buttons.Length % 2) : 2]; + } + button[j][i % 2] = new KeyboardButton(buttons[i]); } Message x = await this.bot.SendTextMessageAsync(this.chat, message, ParseMode.Default, false, false, 0, new ReplyKeyboardMarkup(button,true,true)); this.MessageSending?.Invoke(this, new UserMessageEventArgs(x.Text, x.Chat.Id, x.Date));