mirror of
https://github.com/reactos/reactos.git
synced 2025-05-06 10:28:45 +00:00
Implement "!bug <number>" command.
svn path=/trunk/; revision=20165
This commit is contained in:
parent
bd0b0b3d09
commit
27f6a74ba6
8 changed files with 89 additions and 6 deletions
|
@ -12,5 +12,6 @@
|
||||||
<add key="HresultXml" value="C:\IRC\TechBot\hresult.xml" />
|
<add key="HresultXml" value="C:\IRC\TechBot\hresult.xml" />
|
||||||
<add key="WmXml" value="C:\IRC\TechBot\wm.xml" />
|
<add key="WmXml" value="C:\IRC\TechBot\wm.xml" />
|
||||||
<add key="SvnCommand" value="svn co svn://svn.reactos.com/trunk/reactos" />
|
<add key="SvnCommand" value="svn co svn://svn.reactos.com/trunk/reactos" />
|
||||||
|
<add key="BugUrl" value="www.reactos.org/bugzilla/show_bug.cgi?id={0}" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -158,6 +158,18 @@ namespace TechBot.Console
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string BugUrl
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string optionName = "BugUrl";
|
||||||
|
string s = ConfigurationSettings.AppSettings[optionName];
|
||||||
|
VerifyRequiredOption(optionName,
|
||||||
|
s);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void RunIrcService()
|
private static void RunIrcService()
|
||||||
{
|
{
|
||||||
IrcService ircService = new IrcService(IRCServerHostName,
|
IrcService ircService = new IrcService(IRCServerHostName,
|
||||||
|
@ -170,7 +182,8 @@ namespace TechBot.Console
|
||||||
WinerrorXml,
|
WinerrorXml,
|
||||||
HresultXml,
|
HresultXml,
|
||||||
WmXml,
|
WmXml,
|
||||||
SvnCommand);
|
SvnCommand,
|
||||||
|
BugUrl);
|
||||||
ircService.Run();
|
ircService.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +203,8 @@ namespace TechBot.Console
|
||||||
WinerrorXml,
|
WinerrorXml,
|
||||||
HresultXml,
|
HresultXml,
|
||||||
WmXml,
|
WmXml,
|
||||||
SvnCommand);
|
SvnCommand,
|
||||||
|
BugUrl);
|
||||||
service.Run();
|
service.Run();
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
54
irc/TechBot/TechBot.Library/BugCommand.cs
Normal file
54
irc/TechBot/TechBot.Library/BugCommand.cs
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace TechBot.Library
|
||||||
|
{
|
||||||
|
public class BugCommand : BaseCommand, ICommand
|
||||||
|
{
|
||||||
|
private IServiceOutput serviceOutput;
|
||||||
|
private string bugUrl;
|
||||||
|
|
||||||
|
public BugCommand(IServiceOutput serviceOutput,
|
||||||
|
string bugUrl)
|
||||||
|
{
|
||||||
|
this.serviceOutput = serviceOutput;
|
||||||
|
this.bugUrl = bugUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanHandle(string commandName)
|
||||||
|
{
|
||||||
|
return CanHandle(commandName,
|
||||||
|
new string[] { "bug" });
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Handle(MessageContext context,
|
||||||
|
string commandName,
|
||||||
|
string parameters)
|
||||||
|
{
|
||||||
|
string bugText = parameters;
|
||||||
|
if (bugText.Equals(String.Empty))
|
||||||
|
{
|
||||||
|
serviceOutput.WriteLine(context,
|
||||||
|
"Please provide a valid bug number.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NumberParser np = new NumberParser();
|
||||||
|
long bug = np.Parse(bugText);
|
||||||
|
if (np.Error)
|
||||||
|
{
|
||||||
|
serviceOutput.WriteLine(context,
|
||||||
|
String.Format("{0} is not a valid bug number.",
|
||||||
|
bugText));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
serviceOutput.WriteLine(context,
|
||||||
|
String.Format(bugUrl, bug));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Help()
|
||||||
|
{
|
||||||
|
return "!bug <number>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,6 +18,7 @@ namespace TechBot.Library
|
||||||
private string hresultXml;
|
private string hresultXml;
|
||||||
private string wmXml;
|
private string wmXml;
|
||||||
private string svnCommand;
|
private string svnCommand;
|
||||||
|
private string bugUrl;
|
||||||
private IrcClient client;
|
private IrcClient client;
|
||||||
private ArrayList channels = new ArrayList(); /* IrcChannel */
|
private ArrayList channels = new ArrayList(); /* IrcChannel */
|
||||||
private TechBotService service;
|
private TechBotService service;
|
||||||
|
@ -33,7 +34,8 @@ namespace TechBot.Library
|
||||||
string winerrorXml,
|
string winerrorXml,
|
||||||
string hresultXml,
|
string hresultXml,
|
||||||
string wmXml,
|
string wmXml,
|
||||||
string svnCommand)
|
string svnCommand,
|
||||||
|
string bugUrl)
|
||||||
{
|
{
|
||||||
this.hostname = hostname;
|
this.hostname = hostname;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
|
@ -46,6 +48,7 @@ namespace TechBot.Library
|
||||||
this.hresultXml = hresultXml;
|
this.hresultXml = hresultXml;
|
||||||
this.wmXml = wmXml;
|
this.wmXml = wmXml;
|
||||||
this.svnCommand = svnCommand;
|
this.svnCommand = svnCommand;
|
||||||
|
this.bugUrl = bugUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
|
@ -57,7 +60,8 @@ namespace TechBot.Library
|
||||||
winerrorXml,
|
winerrorXml,
|
||||||
hresultXml,
|
hresultXml,
|
||||||
wmXml,
|
wmXml,
|
||||||
svnCommand);
|
svnCommand,
|
||||||
|
bugUrl);
|
||||||
service.Run();
|
service.Run();
|
||||||
|
|
||||||
client = new IrcClient();
|
client = new IrcClient();
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
<File name=".\HresultCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
<File name=".\HresultCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||||
<File name=".\WinerrorCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
<File name=".\WinerrorCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||||
<File name=".\SvnCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
<File name=".\SvnCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||||
|
<File name=".\BugCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||||
<File name=".\WmCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
<File name=".\WmCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||||
<File name=".\MessageContext.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
<File name=".\MessageContext.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
|
||||||
</Contents>
|
</Contents>
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace TechBot.Library
|
||||||
private string hresultXml;
|
private string hresultXml;
|
||||||
private string wmXml;
|
private string wmXml;
|
||||||
private string svnCommand;
|
private string svnCommand;
|
||||||
|
private string bugUrl;
|
||||||
private ArrayList commands = new ArrayList();
|
private ArrayList commands = new ArrayList();
|
||||||
|
|
||||||
public TechBotService(IServiceOutput serviceOutput,
|
public TechBotService(IServiceOutput serviceOutput,
|
||||||
|
@ -26,7 +27,8 @@ namespace TechBot.Library
|
||||||
string winerrorXml,
|
string winerrorXml,
|
||||||
string hresultXml,
|
string hresultXml,
|
||||||
string wmXml,
|
string wmXml,
|
||||||
string svnCommand)
|
string svnCommand,
|
||||||
|
string bugUrl)
|
||||||
{
|
{
|
||||||
this.serviceOutput = serviceOutput;
|
this.serviceOutput = serviceOutput;
|
||||||
this.chmPath = chmPath;
|
this.chmPath = chmPath;
|
||||||
|
@ -36,6 +38,7 @@ namespace TechBot.Library
|
||||||
this.hresultXml = hresultXml;
|
this.hresultXml = hresultXml;
|
||||||
this.wmXml = wmXml;
|
this.wmXml = wmXml;
|
||||||
this.svnCommand = svnCommand;
|
this.svnCommand = svnCommand;
|
||||||
|
this.bugUrl = bugUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
|
@ -55,6 +58,8 @@ namespace TechBot.Library
|
||||||
wmXml));
|
wmXml));
|
||||||
commands.Add(new SvnCommand(serviceOutput,
|
commands.Add(new SvnCommand(serviceOutput,
|
||||||
svnCommand));
|
svnCommand));
|
||||||
|
commands.Add(new BugCommand(serviceOutput,
|
||||||
|
bugUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InjectMessage(MessageContext context,
|
public void InjectMessage(MessageContext context,
|
||||||
|
|
|
@ -12,5 +12,6 @@
|
||||||
<add key="HresultXml" value="C:\IRC\TechBot\hresult.xml" />
|
<add key="HresultXml" value="C:\IRC\TechBot\hresult.xml" />
|
||||||
<add key="WmXml" value="C:\IRC\TechBot\wm.xml" />
|
<add key="WmXml" value="C:\IRC\TechBot\wm.xml" />
|
||||||
<add key="SvnCommand" value="svn co svn://svn.reactos.com/trunk/reactos" />
|
<add key="SvnCommand" value="svn co svn://svn.reactos.com/trunk/reactos" />
|
||||||
|
<add key="BugUrl" value="www.reactos.org/bugzilla/show_bug.cgi?id={0}" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace TechBot
|
||||||
private string WmXml;
|
private string WmXml;
|
||||||
private string WinerrorXml;
|
private string WinerrorXml;
|
||||||
private string SvnCommand;
|
private string SvnCommand;
|
||||||
|
private string BugUrl;
|
||||||
private EventLog eventLog;
|
private EventLog eventLog;
|
||||||
|
|
||||||
public ServiceThread(EventLog eventLog)
|
public ServiceThread(EventLog eventLog)
|
||||||
|
@ -38,6 +39,7 @@ namespace TechBot
|
||||||
WmXml = ConfigurationSettings.AppSettings["WmXml"];
|
WmXml = ConfigurationSettings.AppSettings["WmXml"];
|
||||||
WinerrorXml = ConfigurationSettings.AppSettings["WinerrorXml"];
|
WinerrorXml = ConfigurationSettings.AppSettings["WinerrorXml"];
|
||||||
SvnCommand = ConfigurationSettings.AppSettings["SvnCommand"];
|
SvnCommand = ConfigurationSettings.AppSettings["SvnCommand"];
|
||||||
|
BugUrl = ConfigurationSettings.AppSettings["BugUrl"];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
|
@ -55,7 +57,8 @@ namespace TechBot
|
||||||
WinerrorXml,
|
WinerrorXml,
|
||||||
HresultXml,
|
HresultXml,
|
||||||
WmXml,
|
WmXml,
|
||||||
SvnCommand);
|
SvnCommand,
|
||||||
|
BugUrl);
|
||||||
ircService.Run();
|
ircService.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue