From 8ace6ca157365790d5f5c8f44bef4f41cf54db50 Mon Sep 17 00:00:00 2001 From: Keroosha Date: Tue, 7 Mar 2023 02:46:50 +0300 Subject: [PATCH] Fix docker i guess?!? --- PublishHelperBot/Program.fs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PublishHelperBot/Program.fs b/PublishHelperBot/Program.fs index 0945c08..5f3f9e2 100644 --- a/PublishHelperBot/Program.fs +++ b/PublishHelperBot/Program.fs @@ -1,5 +1,6 @@ open System open System.Net.Http +open System.Threading open System.Threading.Tasks open PublishHelperBot.Environment open PublishHelperBot.YoutubeDl @@ -9,8 +10,8 @@ open Telegram.Bot.Polling open Telegram.Bot.Types open Telegram.Bot.Types.Enums +let cancellation = new CancellationTokenSource() let config = createConfig "SBPB_CONFIG_PATH" - let botClient = TelegramBotClient (config.token, new HttpClient()) let youtubeDlClient = @@ -56,5 +57,9 @@ botClient.StartReceiving( ) Logging.logger.Information("Я родился") - -Console.ReadKey() |> ignore \ No newline at end of file +Console.CancelKeyPress |> Event.add (fun _ -> cancellation.Cancel(); printfn "Сворачиваемся...") +Async.RunSynchronously( + async { + while (not(cancellation.Token.IsCancellationRequested)) do + do! Async.Sleep 500 |> Async.Ignore + }) \ No newline at end of file