static void Main(string[] args) { if (args.Contains("license", StringComparer.OrdinalIgnoreCase)) { License(); return; } Icebot host = new Icebot(); Console.WriteLine(Icebot._asm.GetName().Name); Console.WriteLine("\tVersion " + Icebot._asm.GetName().Version.ToString()); Console.WriteLine("\tCopyright (C) 2012 Carl Kittelberger"); Console.WriteLine(); Console.WriteLine("This program comes with ABSOLUTELY NO WARRANTY."); Console.WriteLine("This is free software, and you are welcome to redistribute it under certain conditions."); Console.WriteLine("To read the whole license, start this program with the 'license' parameter."); Console.WriteLine(); if (!File.Exists("Icebot.xml")) { Console.WriteLine("Creating configuration file..."); IcebotConfiguration conf = new IcebotConfiguration(); IcebotServerConfiguration server = new IcebotServerConfiguration(); IcebotChannelConfiguration channel = new IcebotChannelConfiguration(); IcebotChannelPluginConfiguration plugin1 = new IcebotChannelPluginConfiguration(); plugin1.PluginName = "pluginlist"; plugin1.Enable = true; channel.ChannelName = "#icebot"; channel.Plugins.Add(plugin1); server.Nickname = "Icebot"; server.Channels.Add(channel); conf.CommandPrefix = "!"; conf.Servers.Add(server); /*XmlWriter w = XmlWriter.Create("Icebot.xml"); w.WriteStartElement("configuration"); w.WriteRaw(Properties.Resources.l4nStandardConfiguration); IcebotConfiguration.Serialize(w, conf); w.WriteEndElement(); w.Close();*/ conf.Save("Icebot.xml"); Console.WriteLine("Config created, edit it to your needs and restart the bot!"); return; } host.LoadConfig("Icebot.xml"); host.Connect(); System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite); }
public void LoadConfig(string filename) { LoadLogEngine(filename); XmlReaderSettings setup = new XmlReaderSettings(); setup.ConformanceLevel = ConformanceLevel.Document; setup.IgnoreComments = true; setup.DtdProcessing = DtdProcessing.Ignore; setup.CloseInput = true; XmlReader r = XmlReader.Create(filename, setup); while (r.Read() && r.Name != "icebot" && !r.EOF) { } if (r.EOF) { _log.Error("Didn't find a valid icebot configuration in the config file."); throw new Exception(); } else { config = IcebotConfiguration.Deserialize(r); r.Close(); _log.Info("Loaded icebot configuration."); } }