publishhelperbot/PublishHelperBot/Environment.fs

20 lines
474 B
Forth
Raw Normal View History

2023-02-07 21:55:46 +03:00
module PublishHelperBot.Environment
open System
open System.IO
open Newtonsoft.Json
type public BotConfig = {
token: string
relayUrl: string
chanelId: int64
adminChatId: int64
}
let private ReadConfig =
File.ReadAllText >> JsonConvert.DeserializeObject<BotConfig>
let public CreateConfig (name: string) =
match Environment.GetEnvironmentVariable(name) with
| null -> raise <| ApplicationException("Missing config path env")
| path -> ReadConfig <| path