mirror of
https://github.com/reactos/reactos.git
synced 2025-06-07 10:20:26 +00:00
188 lines
4.5 KiB
C#
188 lines
4.5 KiB
C#
![]() |
using System;
|
||
|
using System.Configuration;
|
||
|
using TechBot.Library;
|
||
|
|
||
|
namespace TechBot.Console
|
||
|
{
|
||
|
public class ConsoleServiceOutput : IServiceOutput
|
||
|
{
|
||
|
public void WriteLine(string message)
|
||
|
{
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static string IRCChannelName
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
string optionName = "IRCChannelName";
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static string SvnCommand
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
string optionName = "SvnCommand";
|
||
|
string s = ConfigurationSettings.AppSettings[optionName];
|
||
|
VerifyRequiredOption(optionName,
|
||
|
s);
|
||
|
return s;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static void RunIrcService()
|
||
|
{
|
||
|
IrcService ircService = new IrcService(IRCServerHostName,
|
||
|
IRCServerHostPort,
|
||
|
IRCChannelName,
|
||
|
IRCBotName,
|
||
|
ChmPath,
|
||
|
MainChm,
|
||
|
NtstatusXml,
|
||
|
WinerrorXml,
|
||
|
HresultXml,
|
||
|
SvnCommand);
|
||
|
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,
|
||
|
SvnCommand);
|
||
|
service.Run();
|
||
|
while (true)
|
||
|
{
|
||
|
string s = System.Console.ReadLine();
|
||
|
service.InjectMessage(s);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|