Do not die on updateHandle ever again

This commit is contained in:
Keroosha 2023-02-25 02:46:05 +03:00
parent f0e6aaa7e5
commit a64867c3f8

View File

@ -5,6 +5,7 @@ open System.Threading.Tasks
open PublishHelperBot.Handlers
open PublishHelperBot.Environment
open PublishHelperBot.YoutubeDl
open Serilog.Core
open Telegram.Bot
open Telegram.Bot.Polling
open Telegram.Bot.Types
@ -46,6 +47,7 @@ let (|ObsoleteUpdate|RelayMatchUpdate|YoutubeRepostMatchUpdate|SkipUpdate|) (upd
let updateHandle (bc: ITelegramBotClient) (update: Update) (ct: CancellationToken): Task =
let tgCtx = (update, config, bc)
try
match update with
| RelayMatchUpdate() ->
Logging.logger.Information("RelayMatchUpdate")
@ -58,6 +60,10 @@ let updateHandle (bc: ITelegramBotClient) (update: Update) (ct: CancellationToke
| SkipUpdate() ->
Logging.logger.Information("Skipping update")
Task.CompletedTask
with
| e ->
$"Случилась страшная хуйня:\n {e.Message}\n{e.StackTrace}" |> Logging.logger.Error
Task.CompletedTask
let handlePollingError (_: ITelegramBotClient) (e: Exception) (_: CancellationToken) =
Logging.logger.Error(e, "Polling error")