diff --git a/BetterSecondbot/BetterRelayService/BetterRelay.cs b/BetterSecondbot/BetterRelayService/BetterRelay.cs index 3f8bda9..3bcd309 100644 --- a/BetterSecondbot/BetterRelayService/BetterRelay.cs +++ b/BetterSecondbot/BetterRelayService/BetterRelay.cs @@ -77,6 +77,7 @@ namespace BetterSecondBot.BetterRelayService string[] needBits = new string[]{ "asJson", "sourceType", "sourceFilter", "targetType", "targetConfig" }; while (found == true) { + found = false; bool configfound = true; Dictionary config = new Dictionary(); foreach(string a in needBits) @@ -93,8 +94,9 @@ namespace BetterSecondBot.BetterRelayService } if(configfound == false) { - continue; + break; } + found = true; bool asJson = false; bool.TryParse(config["asJson"], out asJson); ApplyRelayConfig(config["sourceType"], config["sourceFilter"], config["targetType"], config["targetConfig"], asJson); diff --git a/BetterSecondbot/Cli.cs b/BetterSecondbot/Cli.cs index 1fd1717..172cd20 100644 --- a/BetterSecondbot/Cli.cs +++ b/BetterSecondbot/Cli.cs @@ -16,7 +16,7 @@ namespace BetterSecondBot { public bool Exited { get { return exitBot; } } protected bool exitBot = false; - protected SecondBot Bot; + protected SecondBot Bot = null; protected BetterAtHome betterAtHomeService; protected BetterTracking betterTracking; protected advertsService Adverts; diff --git a/BetterSecondbot/Tracking/BetterTracking.cs b/BetterSecondbot/Tracking/BetterTracking.cs index cbdae79..a1cfbe0 100644 --- a/BetterSecondbot/Tracking/BetterTracking.cs +++ b/BetterSecondbot/Tracking/BetterTracking.cs @@ -28,7 +28,13 @@ namespace BetterSecondbot.Tracking public BetterTracking(Cli setcontroler) { controler = setcontroler; - if(controler.getBot().getMyConfig.Setting_Tracker.ToLowerInvariant() == "false") + if (controler.getBot() == null) + { + LogFormater.Info("Tracker - error no bot"); + return; + } + SecondBot bot = controler.getBot(); + if (bot.getMyConfig.Setting_Tracker.ToLowerInvariant() == "false") { LogFormater.Info("Tracker - Disabled because set to false"); return; diff --git a/Shared/Json/JsonConfigApi.cs b/Shared/Json/JsonConfigApi.cs index 8715a68..ee5a21b 100644 --- a/Shared/Json/JsonConfigApi.cs +++ b/Shared/Json/JsonConfigApi.cs @@ -261,7 +261,22 @@ namespace BetterSecondBotShared.Json public static string GetProp(JsonConfig reply, string arg) { - return reply.GetType().GetProperty(arg, BindingFlags.Public | BindingFlags.Instance).GetValue(reply).ToString(); + Type T = reply.GetType(); + if(T == null) + { + return "- ERROR no type -"; + } + PropertyInfo Pi = T.GetProperty(arg, BindingFlags.Public | BindingFlags.Instance); + if(Pi == null) + { + return "- ERROR no prop -"; + } + object val = Pi.GetValue(reply); + if(val == null) + { + return ""; + } + return val.ToString(); } protected void SetPropTypeAndValue(JsonConfig reply,PropertyInfo prop,string arg,string arg_type,string arg_value_default)