Change remaining .xml build files to .rbuild and fixup links.
[reactos.git] / irc / TechBot / TechBot.Console / Main.cs
1 using System;
2 using System.Configuration;
3 using TechBot.Library;
4
5 namespace TechBot.Console
6 {
7 public class ConsoleServiceOutput : IServiceOutput
8 {
9 public void WriteLine(MessageContext context,
10 string message)
11 {
12 System.Console.WriteLine(message);
13 }
14 }
15
16
17 class MainClass
18 {
19 private static void VerifyRequiredOption(string optionName,
20 string optionValue)
21 {
22 if (optionValue == null)
23 {
24 throw new Exception(String.Format("Option '{0}' not set.",
25 optionName));
26 }
27 }
28
29 private static string IRCServerHostName
30 {
31 get
32 {
33 string optionName = "IRCServerHostName";
34 string s = ConfigurationSettings.AppSettings[optionName];
35 VerifyRequiredOption(optionName,
36 s);
37 return s;
38 }
39 }
40
41 private static int IRCServerHostPort
42 {
43 get
44 {
45 string optionName = "IRCServerHostPort";
46 string s = ConfigurationSettings.AppSettings[optionName];
47 VerifyRequiredOption(optionName,
48 s);
49 return Int32.Parse(s);
50 }
51 }
52
53 private static string IRCChannelNames
54 {
55 get
56 {
57 string optionName = "IRCChannelNames";
58 string s = ConfigurationSettings.AppSettings[optionName];
59 VerifyRequiredOption(optionName,
60 s);
61 return s;
62 }
63 }
64
65 private static string IRCBotName
66 {
67 get
68 {
69 string optionName = "IRCBotName";
70 string s = ConfigurationSettings.AppSettings[optionName];
71 VerifyRequiredOption(optionName,
72 s);
73 return s;
74 }
75 }
76
77 private static string IRCBotPassword
78 {
79 get
80 {
81 string optionName = "IRCBotPassword";
82 string s = ConfigurationSettings.AppSettings[optionName];
83 VerifyRequiredOption(optionName,
84 s);
85 return s;
86 }
87 }
88
89 private static string ChmPath
90 {
91 get
92 {
93 string optionName = "ChmPath";
94 string s = ConfigurationSettings.AppSettings[optionName];
95 VerifyRequiredOption(optionName,
96 s);
97 return s;
98 }
99 }
100
101 private static string MainChm
102 {
103 get
104 {
105 string optionName = "MainChm";
106 string s = ConfigurationSettings.AppSettings[optionName];
107 VerifyRequiredOption(optionName,
108 s);
109 return s;
110 }
111 }
112
113 private static string NtstatusXml
114 {
115 get
116 {
117 string optionName = "NtstatusXml";
118 string s = ConfigurationSettings.AppSettings[optionName];
119 VerifyRequiredOption(optionName,
120 s);
121 return s;
122 }
123 }
124
125 private static string WinerrorXml
126 {
127 get
128 {
129 string optionName = "WinerrorXml";
130 string s = ConfigurationSettings.AppSettings[optionName];
131 VerifyRequiredOption(optionName,
132 s);
133 return s;
134 }
135 }
136
137 private static string HresultXml
138 {
139 get
140 {
141 string optionName = "HresultXml";
142 string s = ConfigurationSettings.AppSettings[optionName];
143 VerifyRequiredOption(optionName,
144 s);
145 return s;
146 }
147 }
148
149 private static string WmXml
150 {
151 get
152 {
153 string optionName = "WmXml";
154 string s = ConfigurationSettings.AppSettings[optionName];
155 VerifyRequiredOption(optionName,
156 s);
157 return s;
158 }
159 }
160
161 private static string SvnCommand
162 {
163 get
164 {
165 string optionName = "SvnCommand";
166 string s = ConfigurationSettings.AppSettings[optionName];
167 VerifyRequiredOption(optionName,
168 s);
169 return s;
170 }
171 }
172
173 private static string BugUrl
174 {
175 get
176 {
177 string optionName = "BugUrl";
178 string s = ConfigurationSettings.AppSettings[optionName];
179 VerifyRequiredOption(optionName,
180 s);
181 return s;
182 }
183 }
184
185 private static string WineBugUrl
186 {
187 get
188 {
189 string optionName = "WineBugUrl";
190 string s = ConfigurationSettings.AppSettings[optionName];
191 VerifyRequiredOption(optionName,
192 s);
193 return s;
194 }
195 }
196
197
198 private static string SambaBugUrl
199 {
200 get
201 {
202 string optionName = "SambaBugUrl";
203 string s = ConfigurationSettings.AppSettings[optionName];
204 VerifyRequiredOption(optionName,
205 s);
206 return s;
207 }
208 }
209
210
211 private static void RunIrcService()
212 {
213 IrcService ircService = new IrcService(IRCServerHostName,
214 IRCServerHostPort,
215 IRCChannelNames,
216 IRCBotName,
217 IRCBotPassword,
218 ChmPath,
219 MainChm,
220 NtstatusXml,
221 WinerrorXml,
222 HresultXml,
223 WmXml,
224 SvnCommand,
225 BugUrl,
226 WineBugUrl,
227 SambaBugUrl);
228 ircService.Run();
229 }
230
231 public static void Main(string[] args)
232 {
233 if (args.Length > 0 && args[0].ToLower().Equals("irc"))
234 {
235 RunIrcService();
236 return;
237 }
238
239 System.Console.WriteLine("TechBot running console service...");
240 TechBotService service = new TechBotService(new ConsoleServiceOutput(),
241 ChmPath,
242 MainChm,
243 NtstatusXml,
244 WinerrorXml,
245 HresultXml,
246 WmXml,
247 SvnCommand,
248 BugUrl,
249 WineBugUrl,
250 SambaBugUrl);
251 service.Run();
252 while (true)
253 {
254 string s = System.Console.ReadLine();
255 service.InjectMessage(null,
256 s);
257 }
258 }
259 }
260 }