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));