using System.Text;
using MySql.Data.MySqlClient;
using System.IO;
+using Kelsier.Common;
namespace Kelsier {
- class Root {
- static public Database db { get; private set; }
- static public Logger log { get; private set; }
-
- static private Dictionary<int, Bot> bots; // accessed by this.bot(int id)
+ 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();
- static void Main(string[] args) {
StreamWriter fileout = new StreamWriter("kelsier.log", false);
fileout.AutoFlush = true;
LogOutput[] outputs = new LogOutput[] { new LogOutput(Console.Out), new LogOutput(fileout) };
- log = new Logger("Root", new LogOutput[] { new LogOutput(Console.Out) }, outputs, outputs);
+ Info.log = new Logger("Root", new LogOutput[] { new LogOutput(Console.Out) }, outputs, outputs);
- db = new Database(Properties.Settings.Default.dbstr);
+ Info.db = new Database(Properties.Settings.Default.dbstr);
List<int> botids = new List<int>();
- MySqlDataReader rdr = db.queryReader("SELECT id FROM bots");
+ MySqlDataReader rdr = Info.db.queryReader("SELECT id FROM bots");
while (rdr.Read()) {
botids.Add(rdr.GetInt32("id"));
}
rdr.Close();
-
- bots = new Dictionary<int, Bot>();
foreach (int key in botids) {
- bots.Add(key, new Bot(key));
- bots[key].connect();
+ Info.bots.Add(key, new Bot(key));
+ Info.bots[key].connect();
}
while (true) {
System.Threading.Thread.Sleep(2000);
}
}
-
- static Bot bot(int id) { return bots[id]; }
}
-
-
}