diff --git a/Bot-Utils/ABot.cs b/Bot-Utils/ABot.cs index f7bb3af..6f15734 100644 --- a/Bot-Utils/ABot.cs +++ b/Bot-Utils/ABot.cs @@ -11,14 +11,14 @@ namespace BlubbFish.Utils.IoT.Bots { public Boolean DebugLogging { get; - } + } = false; public ABot(String[] _, Boolean fileLogging, String configSearchPath) { InIReader.SetSearchPath(new List() { "/etc/"+ configSearchPath, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\"+ configSearchPath }); - if(fileLogging) { + if(fileLogging && InIReader.ConfigExist("settings") && Boolean.TryParse(InIReader.GetInstance("settings").GetValue("logging", "enabled", "false"), out Boolean _)) { this.logger = new ProgramLogger(InIReader.GetInstance("settings").GetValue("logging", "path", Assembly.GetEntryAssembly().GetName().Name + ".log")); } - if(Boolean.TryParse(InIReader.GetInstance("settings").GetValue("logging", "debug", "true"), out Boolean debuglog)) { + if(InIReader.ConfigExist("settings") && Boolean.TryParse(InIReader.GetInstance("settings").GetValue("logging", "debug", "true"), out Boolean debuglog)) { this.DebugLogging = debuglog; } } diff --git a/Bot-Utils/AWebserver.cs b/Bot-Utils/AWebserver.cs index da44cc7..f09b90e 100644 --- a/Bot-Utils/AWebserver.cs +++ b/Bot-Utils/AWebserver.cs @@ -12,7 +12,8 @@ namespace BlubbFish.Utils.IoT.Bots { protected HttpListener httplistener; - public AWebserver(String[] args, Boolean fileLogging, String configSearchPath, Dictionary settings) : base(args, fileLogging, configSearchPath) => this.config = settings; + public AWebserver(String[] args, Boolean fileLogging, String configSearchPath, Dictionary settings) : base(args, fileLogging, configSearchPath) => + this.config = this.config is null ? InIReader.GetInstance("settings").GetSection("webserver") : settings; protected void StartListen() { this.httplistener = new HttpListener(); diff --git a/Bot-Utils/AWebserverDataBackend.cs b/Bot-Utils/AWebserverDataBackend.cs index fb9cb80..f338d70 100644 --- a/Bot-Utils/AWebserverDataBackend.cs +++ b/Bot-Utils/AWebserverDataBackend.cs @@ -7,7 +7,8 @@ using BlubbFish.Utils.IoT.Events; namespace BlubbFish.Utils.IoT.Bots { public abstract class AWebserverDataBackend : AWebserver { protected ABackend databackend; - protected AWebserverDataBackend(String[] args, Boolean fileLogging, String configSearchPath, ABackend backend, Dictionary settings) : base(args, fileLogging, configSearchPath, settings) => this.databackend = backend; + protected AWebserverDataBackend(String[] args, Boolean fileLogging, String configSearchPath, ABackend backend, Dictionary settings) : base(args, fileLogging, configSearchPath, settings) => + this.databackend = backend is null ? ABackend.GetInstance(InIReader.GetInstance("settings").GetSection("backend")) : backend; protected void StartDataBackend() => this.databackend.MessageIncomming += this.Backend_MessageIncomming; diff --git a/Bot-Utils/Bot-Utils.csproj b/Bot-Utils/Bot-Utils.csproj index 01bee3a..e5e02d3 100644 --- a/Bot-Utils/Bot-Utils.csproj +++ b/Bot-Utils/Bot-Utils.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net10.0 BlubbFish.Utils.IoT.Bots Bot-Utils Bots.IoT.Utils.BlubbFish