- Add support for "!wm <value>" and "!wm <name>" commands.
[reactos.git] / irc / TechBot / TechBot / ServiceThread.cs
1 using System;
2 using System.Configuration;
3 using System.Diagnostics;
4 using TechBot.Library;
5
6 namespace TechBot
7 {
8 public class ServiceThread
9 {
10 private string IRCServerHostName;
11 private int IRCServerHostPort;
12 private string IRCChannelNames;
13 private string IRCBotName;
14 private string ChmPath;
15 private string MainChm;
16 private string NtstatusXml;
17 private string HresultXml;
18 private string WmXml;
19 private string WinerrorXml;
20 private string SvnCommand;
21 private EventLog eventLog;
22
23 public ServiceThread(EventLog eventLog)
24 {
25 this.eventLog = eventLog;
26 }
27
28 private void SetupConfiguration()
29 {
30 IRCServerHostName = ConfigurationSettings.AppSettings["IRCServerHostName"];
31 IRCServerHostPort = Int32.Parse(ConfigurationSettings.AppSettings["IRCServerHostPort"]);
32 IRCChannelNames = ConfigurationSettings.AppSettings["IRCChannelNames"];
33 IRCBotName = ConfigurationSettings.AppSettings["IRCBotName"];
34 ChmPath = ConfigurationSettings.AppSettings["ChmPath"];
35 MainChm = ConfigurationSettings.AppSettings["MainChm"];
36 NtstatusXml = ConfigurationSettings.AppSettings["NtstatusXml"];
37 HresultXml = ConfigurationSettings.AppSettings["HresultXml"];
38 WmXml = ConfigurationSettings.AppSettings["WmXml"];
39 WinerrorXml = ConfigurationSettings.AppSettings["WinerrorXml"];
40 SvnCommand = ConfigurationSettings.AppSettings["SvnCommand"];
41 }
42
43 public void Run()
44 {
45 SetupConfiguration();
46 System.Console.WriteLine("TechBot irc service...");
47
48 IrcService ircService = new IrcService(IRCServerHostName,
49 IRCServerHostPort,
50 IRCChannelNames,
51 IRCBotName,
52 ChmPath,
53 MainChm,
54 NtstatusXml,
55 WinerrorXml,
56 HresultXml,
57 WmXml,
58 SvnCommand);
59 ircService.Run();
60 }
61
62 public void Start()
63 {
64 try
65 {
66 Run();
67 }
68 catch (Exception ex)
69 {
70 eventLog.WriteEntry(String.Format("Ex. {0}", ex));
71 }
72 }
73 }
74 }