]>
Commit | Line | Data |
---|---|---|
88ae06a4 JR |
1 | using System; |
2 | using System.Collections.Generic; | |
3 | using System.Linq; | |
4 | using System.Text; | |
5 | using MySql.Data.MySqlClient; | |
12e0e204 | 6 | using System.IO; |
88ae06a4 | 7 | |
a3c84b90 JR |
8 | namespace Kelsier { |
9 | class Root { | |
12e0e204 JR |
10 | static public Database db { get; private set; } |
11 | static public Logger log { get; private set; } | |
88ae06a4 | 12 | |
12e0e204 | 13 | static private Dictionary<int, Bot> bots; // accessed by this.bot(int id) |
a3c84b90 | 14 | |
88ae06a4 | 15 | |
a3c84b90 | 16 | static void Main(string[] args) { |
12e0e204 | 17 | StreamWriter fileout = new StreamWriter("kelsier.log", false); |
88ae06a4 | 18 | fileout.AutoFlush = true; |
12e0e204 JR |
19 | LogOutput[] outputs = new LogOutput[] { new LogOutput(Console.Out), new LogOutput(fileout) }; |
20 | log = new Logger("Root", new LogOutput[] { new LogOutput(Console.Out) }, outputs, outputs); | |
21 | ||
22 | db = new Database(Properties.Settings.Default.dbstr); | |
23 | ||
24 | List<int> botids = new List<int>(); | |
25 | MySqlDataReader rdr = db.queryReader("SELECT id FROM bots"); | |
26 | while (rdr.Read()) { | |
27 | botids.Add(rdr.GetInt32("id")); | |
28 | } | |
29 | rdr.Close(); | |
30 | ||
31 | bots = new Dictionary<int, Bot>(); | |
32 | foreach (int key in botids) { | |
33 | bots.Add(key, new Bot(key)); | |
34 | bots[key].connect(); | |
35 | } | |
36 | ||
37 | while (true) { | |
38 | System.Threading.Thread.Sleep(2000); | |
39 | } | |
88ae06a4 | 40 | } |
12e0e204 JR |
41 | |
42 | static Bot bot(int id) { return bots[id]; } | |
88ae06a4 JR |
43 | } |
44 | ||
45 | ||
46 | } |