private async void StopCountdown(string chatId, int?messageId) { if (messageId.HasValue) { _dapperDB.StopCountdown(messageId.Value); _telegram.UpdateMessage(chatId, messageId.Value, "<i>COUNTDOWN CANCLED</i>"); await _telegram.SendMessage(chatId, "Successfully cancled the countdown"); } else { await _telegram.SendMessage(chatId, "Please reply to a countdown message"); } }
private async Task UpdateCountDowns() { try { var allCountdowns = await _dapperDB.GetAllCountdowns(); foreach (var countdown in allCountdowns) { try { if (countdown.countdownEnd > DateTime.UtcNow) { TimeSpan timeSpan = countdown.countdownEnd - DateTime.UtcNow; int days = ((int)Math.Floor(timeSpan.TotalDays)); int hours = ((int)Math.Floor(timeSpan.TotalHours)) % 24; int minutes = ((int)Math.Floor(timeSpan.TotalMinutes)) % 60; var message = "<b>" + countdown.title + "</b>| Days: " + days + " Hours: " + hours + " Minutes: " + minutes; _telegram.UpdateMessage(countdown.chatId, countdown.messageId, message); } else { _dapperDB.StopCountdown(countdown.messageId); } } catch (Exception e) { _dapperDB.WriteEventLog("CheckForSubscribedServices", "Error", "There was an error processing the countdown with messageId " + countdown.messageId + " Error: " + e.Message, "UpdateCountDowns"); } } } catch (Exception e) { _dapperDB.WriteEventLog("CheckForSubscribedServices", "Error", e.Message, "UpdateCountDowns"); } }