Do not die on updateHandle ever again
This commit is contained in:
parent
f0e6aaa7e5
commit
a64867c3f8
@ -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) =
|
||||
|
Loading…
Reference in New Issue
Block a user