/// <summary> /// Loads settings and configuration info from various xml files referenced in the settings file passed in the args. /// Also generates some default values if such values have not been set by the settings file. /// </summary> /// <param name="pathToSettings">Path to the settings xml file</param> public void LoadSettings(string pathToSettings) { GlobalSettings.LoadSettings(pathToSettings); // Checks for some important default settings if (!GlobalSettings.ContainsSettingCalled("version")) { GlobalSettings.AddSetting("version", Environment.Version.ToString()); } if (!GlobalSettings.ContainsSettingCalled("name")) { GlobalSettings.AddSetting("name", "Chat bot"); } if (!GlobalSettings.ContainsSettingCalled("botmaster")) { GlobalSettings.AddSetting("botmaster", "creator"); } if (!GlobalSettings.ContainsSettingCalled("master")) { GlobalSettings.AddSetting("botmaster", "creator"); } if (!GlobalSettings.ContainsSettingCalled("author")) { GlobalSettings.AddSetting("author", "Rolands Krumbergs"); } if (!GlobalSettings.ContainsSettingCalled("location")) { GlobalSettings.AddSetting("location", "Riga"); } if (!GlobalSettings.ContainsSettingCalled("gender")) { GlobalSettings.AddSetting("gender", "-1"); } if (!GlobalSettings.ContainsSettingCalled("birthday")) { GlobalSettings.AddSetting("birthday", "2018/12/04"); } if (!GlobalSettings.ContainsSettingCalled("birthplace")) { GlobalSettings.AddSetting("birthplace", "Riga"); } if (!GlobalSettings.ContainsSettingCalled("website")) { GlobalSettings.AddSetting("website", "https://www.if.no/"); } if (!GlobalSettings.ContainsSettingCalled("islogging")) { GlobalSettings.AddSetting("islogging", "False"); } if (!GlobalSettings.ContainsSettingCalled("timeout")) { GlobalSettings.AddSetting("timeout", "2000"); } if (!GlobalSettings.ContainsSettingCalled("timeoutmessage")) { GlobalSettings.AddSetting("timeoutmessage", "ERROR: The request has timed out."); } if (!GlobalSettings.ContainsSettingCalled("culture")) { GlobalSettings.AddSetting("culture", "nb-no"); } if (!GlobalSettings.ContainsSettingCalled("splittersfile")) { GlobalSettings.AddSetting("splittersfile", "Splitters.xml"); } if (!GlobalSettings.ContainsSettingCalled("person2substitutionsfile")) { GlobalSettings.AddSetting("person2substitutionsfile", "Person2Substitutions.xml"); } if (!GlobalSettings.ContainsSettingCalled("personsubstitutionsfile")) { GlobalSettings.AddSetting("personsubstitutionsfile", "PersonSubstitutions.xml"); } if (!GlobalSettings.ContainsSettingCalled("gendersubstitutionsfile")) { GlobalSettings.AddSetting("gendersubstitutionsfile", "GenderSubstitutions.xml"); } if (!GlobalSettings.ContainsSettingCalled("defaultpredicates")) { GlobalSettings.AddSetting("defaultpredicates", "DefaultPredicates.xml"); } if (!GlobalSettings.ContainsSettingCalled("substitutionsfile")) { GlobalSettings.AddSetting("substitutionsfile", "Substitutions.xml"); } if (!GlobalSettings.ContainsSettingCalled("aimldirectory")) { GlobalSettings.AddSetting("aimldirectory", "aiml"); } if (!GlobalSettings.ContainsSettingCalled("configdirectory")) { GlobalSettings.AddSetting("configdirectory", "config"); } if (!GlobalSettings.ContainsSettingCalled("logdirectory")) { GlobalSettings.AddSetting("logdirectory", "logs"); } if (!GlobalSettings.ContainsSettingCalled("maxlogbuffersize")) { GlobalSettings.AddSetting("maxlogbuffersize", "64"); } if (!GlobalSettings.ContainsSettingCalled("notacceptinguserinputmessage")) { GlobalSettings.AddSetting("notacceptinguserinputmessage", "This bot is currently set to not accept user input."); } if (!GlobalSettings.ContainsSettingCalled("stripperregex")) { GlobalSettings.AddSetting("stripperregex", "[^0-9a-zA-Z]"); } // Load the dictionaries for this Bot from the various configuration files Person2Substitutions.LoadSettings(Path.Combine(PathToConfigFiles, GlobalSettings.GrabSetting("person2substitutionsfile"))); PersonSubstitutions.LoadSettings(Path.Combine(PathToConfigFiles, GlobalSettings.GrabSetting("personsubstitutionsfile"))); GenderSubstitutions.LoadSettings(Path.Combine(PathToConfigFiles, GlobalSettings.GrabSetting("gendersubstitutionsfile"))); DefaultPredicates.LoadSettings(Path.Combine(PathToConfigFiles, GlobalSettings.GrabSetting("defaultpredicates"))); Substitutions.LoadSettings(Path.Combine(PathToConfigFiles, GlobalSettings.GrabSetting("substitutionsfile"))); // Grab the splitters for this bot LoadSplitters(Path.Combine(PathToConfigFiles, GlobalSettings.GrabSetting("splittersfile"))); }