|
@@ -1,3 +1,4 @@
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Threading.Tasks;
|
|
|
using MafiaTelegramBot.Models.Commands;
|
|
@@ -84,24 +85,59 @@ namespace MafiaTelegramBot.Models
|
|
|
_repliesList = new List<Reply>();
|
|
|
}
|
|
|
|
|
|
- public static async Task SendStickerAsync(long chatId, string fileId)
|
|
|
+ public static async Task<Message> SendStickerAsync(long chatId, string fileId)
|
|
|
{
|
|
|
- if (chatId > 0)
|
|
|
- await Get().SendStickerAsync(chatId, fileId, disableNotification: true);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return await Get().SendStickerAsync(chatId, fileId, disableNotification: true);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ Console.WriteLine(e.Message);
|
|
|
+ return new Message();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public static async Task SendHyperLink(long chatId, string message)
|
|
|
+ public static async Task<Message> SendHyperLink(long chatId, string message)
|
|
|
{
|
|
|
- if (chatId > 0)
|
|
|
- await Get().SendTextMessageAsync(chatId, message, ParseMode.Html, disableNotification: true);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return await Get().SendTextMessageAsync(chatId, message, ParseMode.Html, disableNotification: true);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ Console.WriteLine(e.Message);
|
|
|
+ return new Message();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static async Task<Message> SendWithMarkdown2(long chatId, string message, IReplyMarkup replyMarkup = null)
|
|
|
{
|
|
|
- if (chatId > 0)
|
|
|
- return await Get().SendTextMessageAsync(chatId, await Utilities.ToMarkdownString(message),
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var editedMessage = await Utilities.ToMarkdownString(message);
|
|
|
+ return await Get().SendTextMessageAsync(chatId, editedMessage,
|
|
|
ParseMode.MarkdownV2, replyMarkup: replyMarkup, disableNotification: true);
|
|
|
- return new Message();
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ Console.WriteLine(e.Message);
|
|
|
+ return new Message();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static async Task<Message> EditMessageAsync(long chatId, int messageId, string message)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var editedMessage = await Utilities.ToMarkdownString(message);
|
|
|
+ return await Get().EditMessageTextAsync(chatId, messageId, editedMessage, parseMode:ParseMode.MarkdownV2);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ Console.WriteLine(e.Message);
|
|
|
+ return new Message();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|