publishhelperbot/PublishHelperBot/Environment.fs
2023-02-27 23:03:31 +03: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