// Kelsier project - entrypoint and global state code (Kelsier.cs) // Written by the Jobbig codeteam. // Copyright 2013 John Runyon. // // This file is part of the Kelsier project. // // Kelsier is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . using System; using System.Collections.Generic; using System.Linq; using System.Text; using MySql.Data.MySqlClient; using System.IO; using Kelsier.Common; namespace Kelsier { static public class Root { static void Main(string[] args) { if (Properties.Settings.Default.datadir == ".") Info.moduledir = Directory.GetCurrentDirectory() + @"\modules"; else Info.moduledir = Properties.Settings.Default.datadir + @"\modules"; Info.refreshmods(); StreamWriter fileout = new StreamWriter("kelsier.log", false); fileout.AutoFlush = true; LogOutput[] outputs = new LogOutput[] { new LogOutput(Console.Out), new LogOutput(fileout) }; Info.log = new Logger("Root", new LogOutput[] { new LogOutput(Console.Out) }, outputs, outputs); Info.db = new Database(Properties.Settings.Default.dbstr); List botids = new List(); MySqlDataReader rdr = Info.db.queryReader("SELECT id FROM bots"); while (rdr.Read()) { botids.Add(rdr.GetInt32("id")); } rdr.Close(); foreach (int key in botids) { Info.bots.Add(key, new Bot(key)); Info.bots[key].connect(); } while (true) { System.Threading.Thread.Sleep(2000); } } } }