correct relay loop error

This commit is contained in:
Madpeterz 2021-04-08 01:21:47 +01:00
parent 958aceaa6b
commit a44b80c7d2
4 changed files with 27 additions and 4 deletions

View file

@ -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<string, string> config = new Dictionary<string, string>();
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);

View file

@ -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;

View file

@ -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;

View file

@ -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)