2005-01-15 19:27:25 +00:00
|
|
|
using System;
|
|
|
|
using System.Configuration;
|
|
|
|
using TechBot.Library;
|
|
|
|
|
|
|
|
namespace TechBot.Console
|
|
|
|
{
|
|
|
|
public class ConsoleServiceOutput : IServiceOutput
|
|
|
|
{
|
2005-02-16 21:07:55 +00:00
|
|
|
public void WriteLine(MessageContext context,
|
|
|
|
string message)
|
2005-01-15 19:27:25 +00:00
|
|
|
{
|
|
|
|
System.Console.WriteLine(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class MainClass
|
|
|
|
{
|
|
|
|
private static void VerifyRequiredOption(string optionName,
|
|
|
|
string optionValue)
|
|
|
|
{
|
|
|
|
if (optionValue == null)
|
|
|
|
{
|
|
|
|
throw new Exception(String.Format("Option '{0}' not set.",
|
|
|
|
optionName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static string IRCServerHostName
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
string optionName = "IRCServerHostName";
|
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static int IRCServerHostPort
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
string optionName = "IRCServerHostPort";
|
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return Int32.Parse(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-16 21:07:55 +00:00
|
|
|
private static string IRCChannelNames
|
2005-01-15 19:27:25 +00:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2005-02-16 21:07:55 +00:00
|
|
|
string optionName = "IRCChannelNames";
|
2005-01-15 19:27:25 +00:00
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static string IRCBotName
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
string optionName = "IRCBotName";
|
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-05 15:29:08 +00:00
|
|
|
private static string IRCBotPassword
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
string optionName = "IRCBotPassword";
|
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-15 19:27:25 +00:00
|
|
|
private static string ChmPath
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
string optionName = "ChmPath";
|
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static string MainChm
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
string optionName = "MainChm";
|
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static string NtstatusXml
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
string optionName = "NtstatusXml";
|
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static string WinerrorXml
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
string optionName = "WinerrorXml";
|
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static string HresultXml
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
string optionName = "HresultXml";
|
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-14 17:34:00 +00:00
|
|
|
private static string WmXml
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
string optionName = "WmXml";
|
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-15 19:27:25 +00:00
|
|
|
private static string SvnCommand
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
string optionName = "SvnCommand";
|
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-14 18:13:05 +00:00
|
|
|
private static string BugUrl
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
string optionName = "BugUrl";
|
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-05 21:46:24 +00:00
|
|
|
private static string WineBugUrl
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
string optionName = "WineBugUrl";
|
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static string SambaBugUrl
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
string optionName = "SambaBugUrl";
|
|
|
|
string s = ConfigurationSettings.AppSettings[optionName];
|
|
|
|
VerifyRequiredOption(optionName,
|
|
|
|
s);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-15 19:27:25 +00:00
|
|
|
private static void RunIrcService()
|
|
|
|
{
|
|
|
|
IrcService ircService = new IrcService(IRCServerHostName,
|
|
|
|
IRCServerHostPort,
|
2005-02-16 21:07:55 +00:00
|
|
|
IRCChannelNames,
|
2005-01-15 19:27:25 +00:00
|
|
|
IRCBotName,
|
2006-01-05 15:29:08 +00:00
|
|
|
IRCBotPassword,
|
2005-01-15 19:27:25 +00:00
|
|
|
ChmPath,
|
|
|
|
MainChm,
|
|
|
|
NtstatusXml,
|
|
|
|
WinerrorXml,
|
|
|
|
HresultXml,
|
2005-12-14 17:34:00 +00:00
|
|
|
WmXml,
|
2005-12-14 18:13:05 +00:00
|
|
|
SvnCommand,
|
2006-01-05 21:46:24 +00:00
|
|
|
BugUrl,
|
|
|
|
WineBugUrl,
|
|
|
|
SambaBugUrl);
|
2005-01-15 19:27:25 +00:00
|
|
|
ircService.Run();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
{
|
|
|
|
if (args.Length > 0 && args[0].ToLower().Equals("irc"))
|
|
|
|
{
|
|
|
|
RunIrcService();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
System.Console.WriteLine("TechBot running console service...");
|
|
|
|
TechBotService service = new TechBotService(new ConsoleServiceOutput(),
|
|
|
|
ChmPath,
|
|
|
|
MainChm,
|
|
|
|
NtstatusXml,
|
|
|
|
WinerrorXml,
|
|
|
|
HresultXml,
|
2005-12-14 17:34:00 +00:00
|
|
|
WmXml,
|
2005-12-14 18:13:05 +00:00
|
|
|
SvnCommand,
|
2006-01-05 21:46:24 +00:00
|
|
|
BugUrl,
|
|
|
|
WineBugUrl,
|
|
|
|
SambaBugUrl);
|
2005-01-15 19:27:25 +00:00
|
|
|
service.Run();
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
string s = System.Console.ReadLine();
|
2005-02-16 21:07:55 +00:00
|
|
|
service.InjectMessage(null,
|
|
|
|
s);
|
2005-01-15 19:27:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|