This commit is contained in:
Jeremy Fincher 2004-08-19 18:16:24 +00:00
parent fa84b0c87c
commit 5be0b319a4
2 changed files with 10 additions and 14 deletions

View File

@ -207,11 +207,12 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp):
irc.reply('I have no defined bugzillae.') irc.reply('I have no defined bugzillae.')
def bugzSnarf(self, irc, msg, match): def bugzSnarf(self, irc, msg, match):
r"""\s*bug\s*(?:id|ids|#)?\s+(?:id|ids|#)?(?P<bug>\d+)""" r"""\bbug\b(?:id|ids|#)?\s+(?:id|ids|#)?(?P<bug>\d+)"""
snarfTarget = self.registryValue('snarfTarget') snarfTarget = self.registryValue('snarfTarget')
bugid = match.group('bug') if not snarfTarget:
return
bugid = match.group('bug')
name = self.shorthand[snarfTarget] name = self.shorthand[snarfTarget]
try: try:
(url, description) = self.db[name] (url, description) = self.db[name]
@ -219,13 +220,10 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp):
s = self.registryValue('replyNoBugzilla', name) s = self.registryValue('replyNoBugzilla', name)
irc.error(s % name) irc.error(s % name)
return return
if not self.registryValue('bugSnarfer', name): if not self.registryValue('bugSnarfer', name):
return return
queryurl = '%s/xml.cgi?id=%s' % (url, bugid) queryurl = '%s/xml.cgi?id=%s' % (url, bugid)
bold = self.registryValue('bold', name) bold = self.registryValue('bold', name)
try: try:
summary = self._get_short_bug_summary(queryurl,description,bugid) summary = self._get_short_bug_summary(queryurl,description,bugid)
except BugzillaError, e: except BugzillaError, e:
@ -234,16 +232,13 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp):
except IOError, e: except IOError, e:
s = '%s. Try yourself: %s' % (e, queryurl) s = '%s. Try yourself: %s' % (e, queryurl)
irc.error(s) irc.error(s)
report = {} report = {}
report['id'] = bugid report['id'] = bugid
report['url'] = str('%s/show_bug.cgi?id=%s' % (url, bugid)) report['url'] = str('%s/show_bug.cgi?id=%s' % (url, bugid))
report['title'] = str(summary['title']) report['title'] = str(summary['title'])
report['summary'] = str(self._mk_summary_string(summary, bold)) report['summary'] = str(self._mk_summary_string(summary, bold))
report['product'] = str(summary['product']) report['product'] = str(summary['product'])
s = '%(product)s bug #%(id)s: %(title)s %(summary)s' % report s = '%(product)s bug #%(id)s: %(title)s %(summary)s' % report
irc.reply(s, prefixName=False) irc.reply(s, prefixName=False)
def bzSnarfer(self, irc, msg, match): def bzSnarfer(self, irc, msg, match):

View File

@ -60,10 +60,11 @@ if network:
def testConfigBugSnarfer(self): def testConfigBugSnarfer(self):
self.assertNotError('add gcc http://gcc.gnu.org/bugzilla gcc') self.assertNotError('add gcc http://gcc.gnu.org/bugzilla gcc')
conf.supybot.plugins.bugzilla.snarfTarget.setValue('gcc')
conf.supybot.plugins.bugzilla.bugSnarfer.setValue(False) conf.supybot.plugins.bugzilla.bugSnarfer.setValue(False)
self.assertNoResponse('bug 5') self.assertNoResponse('blah blah bug 5')
conf.supybot.plugins.bugzilla.bugSnarfer.setValue(True) conf.supybot.plugins.bugzilla.bugSnarfer.setValue(True)
self.assertNotError('bug 5') self.assertNotError('blah blah bug 5')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: