From 6de3d3ca112c80c6da5ee93345545faad8c14e9b Mon Sep 17 00:00:00 2001 From: Maarten Bosma Date: Thu, 5 Jan 2006 21:46:24 +0000 Subject: [PATCH] Different output for !bug command on the other channels. (#winehackers, #samba-technical) svn path=/trunk/; revision=20590 --- irc/TechBot/TechBot.Console/App.config | 6 ++-- irc/TechBot/TechBot.Console/Main.cs | 34 +++++++++++++++++-- irc/TechBot/TechBot.Library/BugCommand.cs | 23 +++++++++++-- irc/TechBot/TechBot.Library/IrcService.cs | 14 +++++--- irc/TechBot/TechBot.Library/TechBotService.cs | 12 +++++-- irc/TechBot/TechBot/App.config | 4 ++- irc/TechBot/TechBot/ServiceThread.cs | 8 +++-- 7 files changed, 84 insertions(+), 17 deletions(-) diff --git a/irc/TechBot/TechBot.Console/App.config b/irc/TechBot/TechBot.Console/App.config index 310f6ee2f35..397d4b0773c 100644 --- a/irc/TechBot/TechBot.Console/App.config +++ b/irc/TechBot/TechBot.Console/App.config @@ -12,7 +12,9 @@ - - + + + + diff --git a/irc/TechBot/TechBot.Console/Main.cs b/irc/TechBot/TechBot.Console/Main.cs index 323f234746d..8a291725360 100644 --- a/irc/TechBot/TechBot.Console/Main.cs +++ b/irc/TechBot/TechBot.Console/Main.cs @@ -182,6 +182,32 @@ namespace TechBot.Console } } + 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; + } + } + + private static void RunIrcService() { IrcService ircService = new IrcService(IRCServerHostName, @@ -196,7 +222,9 @@ namespace TechBot.Console HresultXml, WmXml, SvnCommand, - BugUrl); + BugUrl, + WineBugUrl, + SambaBugUrl); ircService.Run(); } @@ -217,7 +245,9 @@ namespace TechBot.Console HresultXml, WmXml, SvnCommand, - BugUrl); + BugUrl, + WineBugUrl, + SambaBugUrl); service.Run(); while (true) { diff --git a/irc/TechBot/TechBot.Library/BugCommand.cs b/irc/TechBot/TechBot.Library/BugCommand.cs index 955abe78e39..afba6800a33 100644 --- a/irc/TechBot/TechBot.Library/BugCommand.cs +++ b/irc/TechBot/TechBot.Library/BugCommand.cs @@ -5,13 +5,19 @@ namespace TechBot.Library public class BugCommand : BaseCommand, ICommand { private IServiceOutput serviceOutput; - private string bugUrl; + private string RosBugUrl; + private string WineBugUrl; + private string SambaBugUrl; public BugCommand(IServiceOutput serviceOutput, - string bugUrl) + string RosBugUrl, + string WineBugUrl, + string SambaBugUrl) { this.serviceOutput = serviceOutput; - this.bugUrl = bugUrl; + this.RosBugUrl = RosBugUrl; + this.WineBugUrl = WineBugUrl; + this.SambaBugUrl = SambaBugUrl; } public bool CanHandle(string commandName) @@ -41,7 +47,18 @@ namespace TechBot.Library bugText)); return; } + + 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; + } + serviceOutput.WriteLine(context, String.Format(bugUrl, bug)); } diff --git a/irc/TechBot/TechBot.Library/IrcService.cs b/irc/TechBot/TechBot.Library/IrcService.cs index 2bc382c3b06..2e7229f37cd 100644 --- a/irc/TechBot/TechBot.Library/IrcService.cs +++ b/irc/TechBot/TechBot.Library/IrcService.cs @@ -19,7 +19,7 @@ namespace TechBot.Library private string hresultXml; private string wmXml; private string svnCommand; - private string bugUrl; + private string bugUrl, WineBugUrl, SambaBugUrl; private IrcClient client; private ArrayList channels = new ArrayList(); /* IrcChannel */ private TechBotService service; @@ -37,7 +37,9 @@ namespace TechBot.Library string hresultXml, string wmXml, string svnCommand, - string bugUrl) + string BugUrl, + string WineBugUrl, + string SambaBugUrl) { this.hostname = hostname; this.port = port; @@ -54,7 +56,9 @@ namespace TechBot.Library this.hresultXml = hresultXml; this.wmXml = wmXml; this.svnCommand = svnCommand; - this.bugUrl = bugUrl; + this.bugUrl = BugUrl; + this.WineBugUrl = WineBugUrl; + this.SambaBugUrl = SambaBugUrl; } public void Run() @@ -67,7 +71,9 @@ namespace TechBot.Library hresultXml, wmXml, svnCommand, - bugUrl); + bugUrl, + WineBugUrl, + SambaBugUrl); service.Run(); client = new IrcClient(); diff --git a/irc/TechBot/TechBot.Library/TechBotService.cs b/irc/TechBot/TechBot.Library/TechBotService.cs index 1b7f95d187f..1efb858f5d3 100644 --- a/irc/TechBot/TechBot.Library/TechBotService.cs +++ b/irc/TechBot/TechBot.Library/TechBotService.cs @@ -17,7 +17,7 @@ namespace TechBot.Library private string hresultXml; private string wmXml; private string svnCommand; - private string bugUrl; + private string bugUrl, WineBugUrl, SambaBugUrl; private ArrayList commands = new ArrayList(); public TechBotService(IServiceOutput serviceOutput, @@ -28,7 +28,9 @@ namespace TechBot.Library string hresultXml, string wmXml, string svnCommand, - string bugUrl) + string bugUrl, + string WineBugUrl, + string SambaBugUrl) { this.serviceOutput = serviceOutput; this.chmPath = chmPath; @@ -39,6 +41,8 @@ namespace TechBot.Library this.wmXml = wmXml; this.svnCommand = svnCommand; this.bugUrl = bugUrl; + this.WineBugUrl = WineBugUrl; + this.SambaBugUrl = SambaBugUrl; } public void Run() @@ -63,7 +67,9 @@ namespace TechBot.Library commands.Add(new SvnCommand(serviceOutput, svnCommand)); commands.Add(new BugCommand(serviceOutput, - bugUrl)); + bugUrl, + WineBugUrl, + SambaBugUrl)); } public void InjectMessage(MessageContext context, diff --git a/irc/TechBot/TechBot/App.config b/irc/TechBot/TechBot/App.config index 2a40c92b2f0..397d4b0773c 100644 --- a/irc/TechBot/TechBot/App.config +++ b/irc/TechBot/TechBot/App.config @@ -13,6 +13,8 @@ - + + + diff --git a/irc/TechBot/TechBot/ServiceThread.cs b/irc/TechBot/TechBot/ServiceThread.cs index f2595c94f9a..48b30d2ae75 100644 --- a/irc/TechBot/TechBot/ServiceThread.cs +++ b/irc/TechBot/TechBot/ServiceThread.cs @@ -19,7 +19,7 @@ namespace TechBot private string WmXml; private string WinerrorXml; private string SvnCommand; - private string BugUrl; + private string BugUrl, WineBugUrl, SambaBugUrl; private EventLog eventLog; public ServiceThread(EventLog eventLog) @@ -42,6 +42,8 @@ namespace TechBot WinerrorXml = ConfigurationSettings.AppSettings["WinerrorXml"]; SvnCommand = ConfigurationSettings.AppSettings["SvnCommand"]; BugUrl = ConfigurationSettings.AppSettings["BugUrl"]; + WineBugUrl = ConfigurationSettings.AppSettings["WineBugUrl"]; + SambaBugUrl = ConfigurationSettings.AppSettings["SambaBugUrl"]; } public void Run() @@ -61,7 +63,9 @@ namespace TechBot HresultXml, WmXml, SvnCommand, - BugUrl); + BugUrl, + WineBugUrl, + SambaBugUrl); ircService.Run(); }