Updated to work with latest Telegram library
This commit is contained in:
parent
8249e5e182
commit
a797561a97
|
@ -8,19 +8,15 @@ namespace Core.Helper
|
||||||
{
|
{
|
||||||
public static class TelegramHelper
|
public static class TelegramHelper
|
||||||
{
|
{
|
||||||
public static void SendMessage(string botToken, Int64 chatId, string message, bool useSilentMode, LogHelper log)
|
public async static void SendMessage(string botToken, Int64 chatId, string message, bool useSilentMode, LogHelper log)
|
||||||
{
|
{
|
||||||
if (!botToken.Equals("") && chatId != 0)
|
if (!botToken.Equals("") && chatId != 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TelegramBotClient botClient = new TelegramBotClient(botToken);
|
TelegramBotClient botClient = new TelegramBotClient(botToken);
|
||||||
System.Threading.Tasks.Task<Message> sentMessage = botClient.SendTextMessageAsync(chatId, message, ParseMode.Markdown, false, useSilentMode);
|
await botClient.SendTextMessageAsync(chatId: chatId, text: message, parseMode: ParseMode.Markdown,disableNotification: useSilentMode);
|
||||||
|
log.DoLogDebug("Telegram message sent to ChatId " + chatId.ToString() + " on Bot Token '" + botToken + "'");
|
||||||
if (sentMessage.IsCompleted)
|
|
||||||
{
|
|
||||||
log.DoLogDebug("Telegram message sent to ChatId " + chatId.ToString() + " on Bot Token '" + botToken + "'");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue