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