]> jfr.im git - z_archive/kelsier.git/blame - Kelsier.cs
Adding auth
[z_archive/kelsier.git] / Kelsier.cs
CommitLineData
7ed73705
JR
1// Kelsier project - entrypoint and global state code (Kelsier.cs)
2// Written by the Jobbig codeteam. <http://jobbig.eu/code/>
3// Copyright 2013 John Runyon.
4//
5// This file is part of the Kelsier project.
6//
7// Kelsier is free software: you can redistribute it and/or modify
8// it under the terms of the GNU Affero General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU Affero General Public License for more details.
16//
17// You should have received a copy of the GNU Affero General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20using System;
88ae06a4
JR
21using System.Collections.Generic;
22using System.Linq;
23using System.Text;
24using MySql.Data.MySqlClient;
12e0e204 25using System.IO;
e5993b94 26using Kelsier.Common;
88ae06a4 27
a3c84b90 28namespace Kelsier {
e5993b94
JR
29 static public class Root {
30 static void Main(string[] args) {
a3c84b90 31
e5993b94
JR
32 if (Properties.Settings.Default.datadir == ".")
33 Info.moduledir = Directory.GetCurrentDirectory() + @"\modules";
34 else
35 Info.moduledir = Properties.Settings.Default.datadir + @"\modules";
36 Info.refreshmods();
88ae06a4 37
12e0e204 38 StreamWriter fileout = new StreamWriter("kelsier.log", false);
88ae06a4 39 fileout.AutoFlush = true;
12e0e204 40 LogOutput[] outputs = new LogOutput[] { new LogOutput(Console.Out), new LogOutput(fileout) };
e5993b94 41 Info.log = new Logger("Root", new LogOutput[] { new LogOutput(Console.Out) }, outputs, outputs);
12e0e204 42
e5993b94 43 Info.db = new Database(Properties.Settings.Default.dbstr);
12e0e204
JR
44
45 List<int> botids = new List<int>();
e5993b94 46 MySqlDataReader rdr = Info.db.queryReader("SELECT id FROM bots");
12e0e204
JR
47 while (rdr.Read()) {
48 botids.Add(rdr.GetInt32("id"));
49 }
50 rdr.Close();
12e0e204 51 foreach (int key in botids) {
e5993b94
JR
52 Info.bots.Add(key, new Bot(key));
53 Info.bots[key].connect();
12e0e204
JR
54 }
55
56 while (true) {
57 System.Threading.Thread.Sleep(2000);
58 }
88ae06a4
JR
59 }
60 }
88ae06a4 61}