diff --git a/PublishHelperBot/Program.fs b/PublishHelperBot/Program.fs index 0d55e66..1a05524 100644 --- a/PublishHelperBot/Program.fs +++ b/PublishHelperBot/Program.fs @@ -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,17 +47,22 @@ let (|ObsoleteUpdate|RelayMatchUpdate|YoutubeRepostMatchUpdate|SkipUpdate|) (upd let updateHandle (bc: ITelegramBotClient) (update: Update) (ct: CancellationToken): Task = let tgCtx = (update, config, bc) - match update with - | RelayMatchUpdate() -> - Logging.logger.Information("RelayMatchUpdate") - RelayHandler tgCtx - | YoutubeRepostMatchUpdate() -> - YoutubeRepostHandler <| (youtubeDlService, tgCtx) - | ObsoleteUpdate() -> - Logging.logger.Information("Skipping obsolete update") - Task.CompletedTask - | SkipUpdate() -> - Logging.logger.Information("Skipping update") + try + match update with + | RelayMatchUpdate() -> + Logging.logger.Information("RelayMatchUpdate") + RelayHandler tgCtx + | YoutubeRepostMatchUpdate() -> + YoutubeRepostHandler <| (youtubeDlService, tgCtx) + | ObsoleteUpdate() -> + Logging.logger.Information("Skipping obsolete update") + Task.CompletedTask + | 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) =