mirror of
https://github.com/reactos/reactos.git
synced 2025-06-24 20:29:47 +00:00
* refactor the code to make it more OOP and extensible
* remove old outdated SD project files * make it use some .NET 2.0 features as generic collections and settings svn path=/trunk/; revision=31130
This commit is contained in:
parent
588f8770cd
commit
82b5e2eb8b
31 changed files with 687 additions and 491 deletions
|
@ -2,70 +2,49 @@ using System;
|
|||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class BugCommand : BaseCommand, ICommand
|
||||
public abstract class BugCommand : Command//, ICommand
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private string RosBugUrl;
|
||||
private string WineBugUrl;
|
||||
private string SambaBugUrl;
|
||||
|
||||
public BugCommand(IServiceOutput serviceOutput,
|
||||
string RosBugUrl,
|
||||
string WineBugUrl,
|
||||
string SambaBugUrl)
|
||||
public BugCommand(TechBotService techBot) : base (techBot)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.RosBugUrl = RosBugUrl;
|
||||
this.WineBugUrl = WineBugUrl;
|
||||
this.SambaBugUrl = SambaBugUrl;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
public override void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string bugText = parameters;
|
||||
if (bugText.Equals(String.Empty))
|
||||
{
|
||||
TechBot.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;
|
||||
}
|
||||
|
||||
string bugUrl = this.RosBugUrl;
|
||||
NumberParser np = new NumberParser();
|
||||
long bug = np.Parse(bugText);
|
||||
if (np.Error)
|
||||
{
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is not a valid bug number.",
|
||||
bugText));
|
||||
return;
|
||||
}
|
||||
|
||||
if (context is ChannelMessageContext)
|
||||
{
|
||||
ChannelMessageContext channelContext = context as ChannelMessageContext;
|
||||
if (channelContext.Channel.Name == "winehackers")
|
||||
bugUrl = this.WineBugUrl;
|
||||
else if (channelContext.Channel.Name == "samba-technical")
|
||||
bugUrl = this.SambaBugUrl;
|
||||
}
|
||||
|
||||
serviceOutput.WriteLine(context,
|
||||
String.Format(bugUrl, bug));
|
||||
}
|
||||
|
||||
public string Help()
|
||||
{
|
||||
return "!bug <number>";
|
||||
}
|
||||
/*
|
||||
string bugUrl = this.RosBugUrl;
|
||||
|
||||
if (context is ChannelMessageContext)
|
||||
{
|
||||
ChannelMessageContext channelContext = context as ChannelMessageContext;
|
||||
if (channelContext.Channel.Name == "winehackers")
|
||||
bugUrl = this.WineBugUrl;
|
||||
else if (channelContext.Channel.Name == "samba-technical")
|
||||
bugUrl = this.SambaBugUrl;
|
||||
}*/
|
||||
|
||||
TechBot.ServiceOutput.WriteLine(context, String.Format(BugUrl, bug));
|
||||
}
|
||||
|
||||
protected abstract string BugUrl { get; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue