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.Handlers
|
||||||
open PublishHelperBot.Environment
|
open PublishHelperBot.Environment
|
||||||
open PublishHelperBot.YoutubeDl
|
open PublishHelperBot.YoutubeDl
|
||||||
|
open Serilog.Core
|
||||||
open Telegram.Bot
|
open Telegram.Bot
|
||||||
open Telegram.Bot.Polling
|
open Telegram.Bot.Polling
|
||||||
open Telegram.Bot.Types
|
open Telegram.Bot.Types
|
||||||
@ -46,17 +47,22 @@ let (|ObsoleteUpdate|RelayMatchUpdate|YoutubeRepostMatchUpdate|SkipUpdate|) (upd
|
|||||||
|
|
||||||
let updateHandle (bc: ITelegramBotClient) (update: Update) (ct: CancellationToken): Task =
|
let updateHandle (bc: ITelegramBotClient) (update: Update) (ct: CancellationToken): Task =
|
||||||
let tgCtx = (update, config, bc)
|
let tgCtx = (update, config, bc)
|
||||||
match update with
|
try
|
||||||
| RelayMatchUpdate() ->
|
match update with
|
||||||
Logging.logger.Information("RelayMatchUpdate")
|
| RelayMatchUpdate() ->
|
||||||
RelayHandler tgCtx
|
Logging.logger.Information("RelayMatchUpdate")
|
||||||
| YoutubeRepostMatchUpdate() ->
|
RelayHandler tgCtx
|
||||||
YoutubeRepostHandler <| (youtubeDlService, tgCtx)
|
| YoutubeRepostMatchUpdate() ->
|
||||||
| ObsoleteUpdate() ->
|
YoutubeRepostHandler <| (youtubeDlService, tgCtx)
|
||||||
Logging.logger.Information("Skipping obsolete update")
|
| ObsoleteUpdate() ->
|
||||||
Task.CompletedTask
|
Logging.logger.Information("Skipping obsolete update")
|
||||||
| SkipUpdate() ->
|
Task.CompletedTask
|
||||||
Logging.logger.Information("Skipping update")
|
| SkipUpdate() ->
|
||||||
|
Logging.logger.Information("Skipping update")
|
||||||
|
Task.CompletedTask
|
||||||
|
with
|
||||||
|
| e ->
|
||||||
|
$"Случилась страшная хуйня:\n {e.Message}\n{e.StackTrace}" |> Logging.logger.Error
|
||||||
Task.CompletedTask
|
Task.CompletedTask
|
||||||
|
|
||||||
let handlePollingError (_: ITelegramBotClient) (e: Exception) (_: CancellationToken) =
|
let handlePollingError (_: ITelegramBotClient) (e: Exception) (_: CancellationToken) =
|
||||||
|
Loading…
Reference in New Issue
Block a user