publishhelperbot/PublishHelperBot/Environment.fs
2023-02-24 21:04:13 +00:00

32 lines
803 B
Forth

module PublishHelperBot.Environment
open System
open System.IO
open Newtonsoft.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 >> JsonConvert.DeserializeObject<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