diff --git a/plugins/Sourceforge.py b/plugins/Sourceforge.py index c140753fe..47e589c82 100644 --- a/plugins/Sourceforge.py +++ b/plugins/Sourceforge.py @@ -98,6 +98,10 @@ conf.registerChannelValue(conf.supybot.plugins.Sourceforge, 'defaultProject', explicit project is given.""")) conf.registerGlobalValue(conf.supybot.plugins.Sourceforge, 'bold', registry.Boolean(True, """Determines whether the results are bolded.""")) +conf.registerGlobalValue(conf.supybot.plugins.Sourceforge, + 'enableSpecificTrackerCommands', registry.Boolean(True, """Determines + whether the bug, rfe, and patch commands (convenience wrappers around + the tracker command) will be enabled.""")) class Sourceforge(callbacks.PrivmsgCommandAndRegexp): """ @@ -130,6 +134,12 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp): super(Sourceforge, self).__init__() self.__class__.sf = self.__class__.sourceforge + def isCommand(self, name): + if name in ('bug', 'rfe', 'patch'): + return self.registryValue('enableSpecificTrackerCommands') + else: + return super(Sourceforge, self).isCommand(name) + def _formatResp(self, text, num=''): """ Parses the Sourceforge query to return a list of tuples that @@ -221,11 +231,38 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp): except webutils.WebError, e: raise TrackerError, str(e) - def tracker(self, irc, msg, args): - """ + def bug(self, irc, msg, args): + """ - Returns a description of the tracker with Tracker id and the - corresponding Tracker url. + Returns a description of the bug with id . Really, this is + just a wrapper for the tracker command; it won't even complain if the + you give isn't a bug. + """ + self.tracker(irc, msg, args) + + def patch(self, irc, msg, args): + """ + + Returns a description of the patch with id . Really, this is + just a wrapper for the tracker command; it won't even complain if the + you give isn't a patch. + """ + self.tracker(irc, msg, args) + + def rfe(self, irc, msg, args): + """ + + Returns a description of the rfe with id . Really, this is + just a wrapper for the tracker command; it won't even complain if the + you give isn't an rfe. + """ + self.tracker(irc, msg, args) + + def tracker(self, irc, msg, args): + """ + + Returns a description of the tracker with id and the corresponding + url. """ num = privmsgs.getArgs(args) try: diff --git a/test/test_Sourceforge.py b/test/test_Sourceforge.py index 12f92b71f..20fdef637 100644 --- a/test/test_Sourceforge.py +++ b/test/test_Sourceforge.py @@ -39,6 +39,19 @@ Sf = conf.supybot.plugins.Sourceforge class SourceforgeTest(ChannelPluginTestCase): plugins = ('Sourceforge',) config = {'supybot.plugins.Sourceforge.bold': False} + def testEnableSpecificTrackerCommands(self): + w = conf.supybot.plugins.Sourceforge.enableSpecificTrackerCommands + orig = w() + try: + w.setValue(True) + self.assertRegexp('list Sourceforge', + r'bug[^s].*patch[^es].*rfe[^s]') + w.setValue(False) + self.assertNotRegexp('list Sourceforge', + r'bug[^s].*patch[^es].*rfe[^s]') + finally: + w.setValue(orig) + if network: def testAny(self): m = self.getMsg('bugs --any gaim')