3 namespace TechBot.Library
5 public class BugCommand : BaseCommand, ICommand
7 private IServiceOutput serviceOutput;
8 private string RosBugUrl;
9 private string WineBugUrl;
10 private string SambaBugUrl;
12 public BugCommand(IServiceOutput serviceOutput,
17 this.serviceOutput = serviceOutput;
18 this.RosBugUrl = RosBugUrl;
19 this.WineBugUrl = WineBugUrl;
20 this.SambaBugUrl = SambaBugUrl;
23 public bool CanHandle(string commandName)
25 return CanHandle(commandName,
26 new string[] { "bug" });
29 public void Handle(MessageContext context,
33 string bugText = parameters;
34 if (bugText.Equals(String.Empty))
36 serviceOutput.WriteLine(context,
37 "Please provide a valid bug number.");
41 NumberParser np = new NumberParser();
42 long bug = np.Parse(bugText);
45 serviceOutput.WriteLine(context,
46 String.Format("{0} is not a valid bug number.",
51 string bugUrl = this.RosBugUrl;
53 if (context is ChannelMessageContext)
55 ChannelMessageContext channelContext = context as ChannelMessageContext;
56 if (channelContext.Channel.Name == "winehackers")
57 bugUrl = this.WineBugUrl;
58 else if (channelContext.Channel.Name == "samba-technical")
59 bugUrl = this.SambaBugUrl;
62 serviceOutput.WriteLine(context,
63 String.Format(bugUrl, bug));
68 return "!bug <number>";