[NF] Telegram Condition
[NF] Zway Libarary
This commit is contained in:
parent
dc896de71e
commit
d25c1ff831
@ -9,6 +9,9 @@ namespace BlubbFish.Utils.IoT.Connector {
|
||||
public delegate void MqttMessage(Object sender, MqttEventArgs e);
|
||||
|
||||
public static ADataBackend GetInstance(Dictionary<String, String> settings) {
|
||||
if(settings.Count == 0) {
|
||||
return null;
|
||||
}
|
||||
String object_sensor = "BlubbFish.Utils.IoT.Connector.Data." + Char.ToUpper(settings["type"][0]) + settings["type"].Substring(1).ToLower();
|
||||
Type t = null;
|
||||
try {
|
||||
|
@ -25,6 +25,7 @@ namespace BlubbFish.Utils.IoT.Connector {
|
||||
}
|
||||
|
||||
public abstract void Send(String message);
|
||||
public abstract void Send(String message, String[] buttons);
|
||||
|
||||
public abstract void Dispose();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user