public static async Task SendTextAsync(this string sendText, InlineKeyboardMarkup replyMarkup = null, int replyToMsgId = -1, long customChatId = -1) { // var replyToMsgId = Message.MessageId; // if (replyToReplied) // { // replyToMsgId = Message.ReplyToMessage.MessageId; // } TimeProc = Message.Date.GetDelay(); if (sendText != "") { sendText += $"\n\n⏱ <code>{TimeInit} s</code> | ⌛️ <code>{TimeProc} s</code>"; } var chatTarget = Message.Chat.Id; if (customChatId < -1) { chatTarget = customChatId; } Message send = null; try { ConsoleHelper.WriteLine($"Sending message to {chatTarget}"); send = await Client.SendTextMessageAsync( chatTarget, sendText, ParseMode.Html, replyMarkup : replyMarkup, replyToMessageId : replyToMsgId ); } catch (ApiRequestException apiRequestException) { // ConsoleHelper.WriteLine($"SendMessage: {apiRequestException.Message}"); Log.Error(apiRequestException, "Send Message with reply (default) Exception."); try { ConsoleHelper.WriteLine($"Try Sending message to {chatTarget} without reply to Msg Id."); send = await Client.SendTextMessageAsync( chatTarget, sendText, ParseMode.Html, replyMarkup : replyMarkup ); } catch (ApiRequestException apiRequestException2) { // ConsoleHelper.WriteLine($"SendMessage: {apiRequestException2.ErrorCode}: {apiRequestException2.Message}"); Log.Error(apiRequestException2, "Send Message without reply Exception."); } } if (send != null) { SentMessageId = send.MessageId; } }
public static void BackgroundWriteCache(this object dataTable, string fileJson) { var jobId = BackgroundJob.Enqueue(() => WriteCacheAsync(dataTable, fileJson, true)); ConsoleHelper.WriteLine($"Background Write Cache scheduled with ID: {jobId}"); }