[NF] Zway-Bot hinzugefügt

[NF] Viele kleine Änderungen an Zwaylib zur Verbesserung der Kompatibilität
This commit is contained in:
BlubbFish 2017-11-25 11:00:48 +00:00
parent d25c1ff831
commit 26024a4518

View File

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