public add_server(Interface frmctrl, configuration config) { InitializeComponent(); old_configeration = config; m_parent = frmctrl; user_level_box.Text = "1"; voice_level_box.Text = "3"; hop_level_box.Text = "6"; op_level_box.Text = "7"; sop_level_box.Text = "8"; founder_level_box.Text = "9"; owner_level_box.Text = "10"; xmlDocModules.Load(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "Module_Config" + Path.DirectorySeparatorChar + "Default" + Path.DirectorySeparatorChar + "modules.xml"); XmlNodeList xnList = xmlDocModules.SelectNodes("/modules/module"); foreach (XmlNode xnModules in xnList) { String module_name = xnModules["name"].InnerText; module_list.Items.Add(module_name); // Add commands to command list XmlNodeList optionList = xnModules.ChildNodes; foreach (XmlNode option in optionList) { if (option.Name.Equals("commands")) { XmlNodeList Options = option.ChildNodes; foreach (XmlNode options in Options) { command_list.Items.Add(options["name"].InnerText); } } } } xnList = xmlDocModules.SelectNodes("/modules/module"); foreach (XmlNode xn_node in xnList) { XmlNodeList optionList = xn_node.ChildNodes; foreach (XmlNode option in optionList) { if (option.Name.Equals("commands")) { XmlNodeList Options = option.ChildNodes; foreach (XmlNode options in Options) { if (options["name"].InnerText.Equals(command_list.Items[0])) { command_label.Text = options["name"].InnerText; command_name.Text = options["name"].InnerText; command_triggers.Text = options["triggers"].InnerText; command_arguments.Text = options["syntax"].InnerText; command_description.Text = options["description"].InnerText; command_access_level.Text = options["access_level"].InnerText; channel_blacklist.Text = options["blacklist"].InnerText; show_in_help.Checked = Convert.ToBoolean(options["show_help"].InnerText); spam_counter.Checked = Convert.ToBoolean(options["spam_check"].InnerText); break; } } } } } module_list.SelectedIndex = 0; command_list.SelectedIndex = 0; }
public configuration(Interface frmctrl) { InitializeComponent(); m_parent = frmctrl; XmlDocument xmlDoc = new XmlDocument(); if (File.Exists(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "config.xml")) { xmlDoc.Load(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "config.xml"); } else { XmlNode node = xmlDoc.CreateNode(XmlNodeType.Element, "global_settings", null); XmlNode nodeCommand = xmlDoc.CreateElement("command_prefix"); nodeCommand.InnerText = "."; node.AppendChild(nodeCommand); XmlNode nodeKeep = xmlDoc.CreateElement("keep_logs"); nodeKeep.InnerText = "True"; node.AppendChild(nodeKeep); XmlNode nodeLogs = xmlDoc.CreateElement("logs_path"); nodeLogs.InnerText = m_parent.cur_dir + Path.DirectorySeparatorChar + "logs" + Path.DirectorySeparatorChar + ""; node.AppendChild(nodeLogs); XmlNode nodeStart = xmlDoc.CreateElement("start_with_windows"); nodeStart.InnerText = "False"; node.AppendChild(nodeStart); XmlNode nodeTray = xmlDoc.CreateElement("minimize_to_tray"); nodeTray.InnerText = "False"; node.AppendChild(nodeTray); XmlNode nodeSpamCount = xmlDoc.CreateElement("spam_count"); nodeSpamCount.InnerText = "5"; node.AppendChild(nodeSpamCount); XmlNode nodeSpamThreshold = xmlDoc.CreateElement("spam_threshold"); nodeSpamThreshold.InnerText = "1000"; node.AppendChild(nodeSpamThreshold); XmlNode nodeSpamTime = xmlDoc.CreateElement("spam_timeout"); nodeSpamTime.InnerText = "10000"; node.AppendChild(nodeSpamTime); XmlNode nodeSpamMaxMsgLength = xmlDoc.CreateElement("max_message_length"); nodeSpamMaxMsgLength.InnerText = "450"; node.AppendChild(nodeSpamMaxMsgLength); xmlDoc.AppendChild(node); xmlDoc.Save(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "config.xml"); xmlDoc.Load(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "config.xml"); } XmlNode list = xmlDoc.SelectSingleNode("/bot_settings/global_settings"); command_prefix_box.Text = list["command_prefix"].InnerText; spam_count_box.Text = list["spam_count"].InnerText; spam_threshold_box.Text = list["spam_threshold"].InnerText; spam_timeout_box.Text = list["spam_timeout"].InnerText; max_message_length_box.Text = list["max_message_length"].InnerText; if (list["keep_logs"].InnerText == "True") { keep_logs_box.Checked = true; } else { keep_logs_box.Checked = false; } log_folder_box.Text = list["logs_path"].InnerText; if (list["start_with_windows"].InnerText == "True") { windows_start_box.Checked = true; } else { windows_start_box.Checked = false; } if (list["minimize_to_tray"].InnerText == "True") { minimize_to_tray.Checked = true; } else { minimize_to_tray.Checked = false; } XmlNodeList xnList = xmlDoc.SelectNodes("/bot_settings/server_list/server"); foreach (XmlNode xn in xnList) { string server_name = xn["server_name"].InnerText; server_list.Items.Add(server_name); } server_list.SelectedIndexChanged += server_changed; }
public edit_server(Interface frmctrl, string tmp_server_name) { InitializeComponent(); m_parent = frmctrl; server_name = tmp_server_name; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "config.xml"); XmlNodeList ServerxnList = xmlDoc.SelectNodes("/bot_settings/server_list/server"); foreach (XmlNode xn in ServerxnList) { string tmp_server = xn["server_name"].InnerText; if (tmp_server.Equals(server_name)) { bot_name_box.Text = xn["name"].InnerText; bot_nick_box.Text = xn["nick"].InnerText; sec_nicks.Text = xn["sec_nicks"].InnerText; password_box.Text = xn["password"].InnerText; email_box.Text = xn["email"].InnerText; owner_nicks_box.Text = xn["owner"].InnerText; port_box.Text = xn["port"].InnerText; server_name_box.Text = xn["server_name"].InnerText; server_module_folder = xn["server_folder"].InnerText; channels_box.Text = xn["chan_list"].InnerText; channel_blacklist_box.Text = xn["chan_blacklist"].InnerText; ignore_list_box.Text = xn["ignore_list"].InnerText; user_level_box.Text = xn["user_level"].InnerText; voice_level_box.Text = xn["voice_level"].InnerText; hop_level_box.Text = xn["hop_level"].InnerText; op_level_box.Text = xn["op_level"].InnerText; sop_level_box.Text = xn["sop_level"].InnerText; founder_level_box.Text = xn["founder_level"].InnerText; owner_level_box.Text = xn["owner_level"].InnerText; if (File.Exists(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "Module_Config" + Path.DirectorySeparatorChar + server_module_folder + Path.DirectorySeparatorChar + "modules.xml")) { xmlDocModules.Load(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "Module_Config" + Path.DirectorySeparatorChar + server_module_folder + Path.DirectorySeparatorChar + "modules.xml"); } else { Directory.CreateDirectory(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "Module_Config" + Path.DirectorySeparatorChar + server_module_folder); File.Copy(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "Module_Config" + Path.DirectorySeparatorChar + "Default" + Path.DirectorySeparatorChar + "modules.xml", m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "Module_Config" + Path.DirectorySeparatorChar + server_module_folder + Path.DirectorySeparatorChar + "modules.xml"); xmlDocModules.Load(m_parent.cur_dir + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "Module_Config" + Path.DirectorySeparatorChar + server_module_folder + Path.DirectorySeparatorChar + "modules.xml"); } XmlNodeList xnList = xmlDocModules.SelectNodes("/modules/module"); foreach (XmlNode xnModules in xnList) { String module_name = xnModules["name"].InnerText; module_list.Items.Add(module_name); // Add commands to command list XmlNodeList optionList = xnModules.ChildNodes; foreach (XmlNode option in optionList) { if (option.Name.Equals("commands")) { XmlNodeList Options = option.ChildNodes; foreach (XmlNode options in Options) { command_list.Items.Add(options["name"].InnerText); } } } } xnList = xmlDocModules.SelectNodes("/modules/module"); foreach (XmlNode xn_node in xnList) { XmlNodeList optionList = xn_node.ChildNodes; foreach (XmlNode option in optionList) { if (option.Name.Equals("commands")) { XmlNodeList Options = option.ChildNodes; foreach (XmlNode options in Options) { if (options["name"].InnerText.Equals(command_list.Items[0])) { command_label.Text = options["name"].InnerText; command_name.Text = options["name"].InnerText; command_triggers.Text = options["triggers"].InnerText; command_arguments.Text = options["syntax"].InnerText; command_description.Text = options["description"].InnerText; command_access_level.Text = options["access_level"].InnerText; channel_blacklist.Text = options["blacklist"].InnerText; show_in_help.Checked = Convert.ToBoolean(options["show_help"].InnerText); spam_counter.Checked = Convert.ToBoolean(options["spam_check"].InnerText); break; } } } } } module_list.SelectedIndex = 0; command_list.SelectedIndex = 0; } } }
public void start_bot(Interface main, IRCConfig tmp_conf) { connecting = true; start_time = DateTime.Now; ircbot = main; conf = tmp_conf; string[] tmp_server = conf.server.Split('.'); if (tmp_server.GetUpperBound(0) > 0) { server_name = tmp_server[1]; } full_server_name = conf.server; cur_dir = ircbot.cur_dir; load_modules(); Spam_Check_Timer.Tick += new EventHandler(spam_tick); Spam_Check_Timer.Interval = conf.spam_threshold; Spam_Check_Timer.Start(); Spam_Threshold_Check.Tick += new EventHandler(spam_check); Spam_Threshold_Check.Interval = 100; Spam_Threshold_Check.Start(); checkRegisterationTimer.Tick += new EventHandler(checkRegistration); checkRegisterationTimer.Interval = 120000; checkRegisterationTimer.Enabled = true; check_cancel.Tick += new EventHandler(cancel_tick); check_cancel.Interval = 500; check_cancel.Start(); BackgroundWorker work = new BackgroundWorker(); work.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork); work.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted); work.WorkerSupportsCancellation = true; worker = work; worker.RunWorkerAsync(2000); }