[NF] Telegram Condition

[NF] Zway Libarary
This commit is contained in:
2017-10-29 19:32:18 +00:00
parent dc896de71e
commit d25c1ff831
3 changed files with 22 additions and 0 deletions
+18
View File
@@ -4,6 +4,8 @@ using Telegram.Bot;
using Telegram.Bot.Args;
using Telegram.Bot.Exceptions;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
namespace BlubbFish.Utils.IoT.Connector.User {
public class Telegram : AUserBackend {
@@ -37,11 +39,27 @@ namespace BlubbFish.Utils.IoT.Connector.User {
Console.WriteLine(e.Message+" "+e.ErrorCode+" "+e.Parameters);
Console.ForegroundColor = ConsoleColor.White;
}
}
public override void Dispose() {
this.bot.StopReceiving();
this.bot = null;
}
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]);
}
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));
} catch (ApiRequestException e) {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(e.Message + " " + e.ErrorCode + " " + e.Parameters);
Console.ForegroundColor = ConsoleColor.White;
}
}
}
}