Add a conf.supybot.plugins.Sourceforge.bold and setup @bugs, @rfes, and @patches to use it.

This commit is contained in:
James Vega 2004-09-06 01:32:45 +00:00
parent e22c732d14
commit 35b8fdeae3

View File

@ -96,6 +96,8 @@ conf.registerChannelValue(conf.supybot.plugins.Sourceforge, 'trackerSnarfer',
conf.registerChannelValue(conf.supybot.plugins.Sourceforge, 'defaultProject', conf.registerChannelValue(conf.supybot.plugins.Sourceforge, 'defaultProject',
registry.String('', """Sets the default project to use in the case that no registry.String('', """Sets the default project to use in the case that no
explicit project is given.""")) explicit project is given."""))
conf.registerGlobalValue(conf.supybot.plugins.Sourceforge, 'bold',
registry.Boolean(True, """Determines whether the results are bolded."""))
class Sourceforge(callbacks.PrivmsgCommandAndRegexp): class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
""" """
@ -135,10 +137,17 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
if num: if num:
for item in ifilter(lambda s, n=num: s and n in s, for item in ifilter(lambda s, n=num: s and n in s,
self._infoRe.findall(text)): self._infoRe.findall(text)):
if self.registryValue('bold'):
yield (ircutils.bold(utils.htmlToText(item[2])), yield (ircutils.bold(utils.htmlToText(item[2])),
utils.htmlToText(item[1])) utils.htmlToText(item[1]))
else:
yield (utils.htmlToText(item[2]),
utils.htmlToText(item[1]))
else: else:
for item in ifilter(None, self._infoRe.findall(text)): for item in ifilter(None, self._infoRe.findall(text)):
if self.registryValue('bold'):
yield (ircutils.bold(item[0]), utils.htmlToText(item[2]))
else:
yield (item[0], utils.htmlToText(item[2])) yield (item[0], utils.htmlToText(item[2]))
def _getTrackerURL(self, project, regex, status): def _getTrackerURL(self, project, regex, status):
@ -183,6 +192,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
Parses the specific tracker page, returning useful information. Parses the specific tracker page, returning useful information.
""" """
try: try:
bold = self.registryValue('bold')
s = webutils.getUrl(url) s = webutils.getUrl(url)
resp = [] resp = []
head = '' head = ''
@ -192,14 +202,20 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
linktype = m.group(1) linktype = m.group(1)
linktype = utils.depluralize(linktype) linktype = utils.depluralize(linktype)
(num, desc) = n.groups() (num, desc) = n.groups()
if bold:
head = '%s #%s: %s' % (ircutils.bold(linktype), num, desc) head = '%s #%s: %s' % (ircutils.bold(linktype), num, desc)
else:
head = '%s #%s: %s' % (linktype, num, desc)
resp.append(head) resp.append(head)
else: else:
return None return None
for r in self._regexps: for r in self._regexps:
m = r.search(s) m = r.search(s)
if m: if m:
if bold:
resp.append('%s: %s' % self._bold(m.groups())) resp.append('%s: %s' % self._bold(m.groups()))
else:
resp.append('%s: %s' % m.groups())
return '; '.join(resp) return '; '.join(resp)
except webutils.WebError, e: except webutils.WebError, e:
raise TrackerError, str(e) raise TrackerError, str(e)