publishhelperbot/PublishHelperBot/Environment.fs

21 lines
497 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
2023-02-11 04:16:34 +03:00
YoutubeDlUrl: string
2023-02-07 21:55:46 +03:00
}
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