publishhelperbot/PublishHelperBot/Environment.fs
Vladislav Khapin 07b589e2a0 fix video size
2023-02-27 23:31:40 +04:00

32 lines
801 B
Forth

module PublishHelperBot.Environment
open System
open System.IO
open System.Text.Json
open Serilog
[<RequireQualifiedAccess>]
module Logging =
let logger =
let config = LoggerConfiguration()
config.WriteTo.Console().CreateLogger()
type public BotConfig = {
token: string
relayUrl: string
chanelId: int64
adminChatId: int64
YoutubeDlUrl: string
}
let private readConfig =
File.ReadAllText >> JsonSerializer.Deserialize<BotConfig>
let public createConfig (name: string) =
match Environment.GetEnvironmentVariable(name) with
| null ->
Logging.logger.Error("Missing env")
ApplicationException("Missing config path env") |> raise
| path ->
Logging.logger.Information("Read config from env")
readConfig path