Bugtracker: Add option to send bug information via notice.

This commit is contained in:
Krytarik Raido 2022-10-01 16:45:04 +02:00
parent 4dae298cc2
commit cccf339e2e
5 changed files with 27 additions and 9 deletions

View File

@ -36,7 +36,7 @@ import supybot
from supybot import world
# Use this for the version of this plugin.
__version__ = "1.0.0"
__version__ = "1.0.1"
# XXX Replace this with an appropriate author or supybot.Author instance.
__author__ = supybot.Author('Krytarik Raido', 'krytarik', 'krytarik@gmail.com')

View File

@ -59,7 +59,7 @@ conf.registerNetworkValue(Bugreporter, 'channels',
registry.SpaceSeparatedListOfStrings([], _("""Channels to announce bug reports to.""")))
conf.registerChannelValue(Bugreporter, 'projects',
registry.SpaceSeparatedListOfStrings(['ubuntu'], _("""Projects to announce bug reports on.""")))
registry.SpaceSeparatedListOfStrings(['ubuntu'], _("""Projects to announce bug reports on.""")))
conf.registerChannelValue(Bugreporter, 'useNotices',
registry.Boolean(False, _("""Use notices instead of normal messages.""")))
registry.Boolean(False, _("""Use notices instead of normal messages.""")))

View File

@ -23,7 +23,7 @@ import supybot
import supybot.world as world
from importlib import reload
__version__ = "5.4.0"
__version__ = "5.5.0"
__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@gmail.com")
__contributors__ = {
supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'],

View File

@ -71,6 +71,7 @@ def configure(advanced):
showassignee = yn("Show the assignee of a bug in the reply?", default=Bugtracker.showassignee._default)
extended = yn("Show tracker-specific extended infomation?", default=Bugtracker.extended._default)
useNotices = yn("Use notices instead of normal messages to send bug information?", default=Bugtracker.useNotices._default)
saveDiscoveredTrackers = yn("Save automatically discovered trackers to configuration?", default=Bugtracker.saveDiscoveredTrackers._default)
Bugtracker.bugSnarfer.setValue(bugSnarfer)
@ -84,6 +85,7 @@ def configure(advanced):
Bugtracker.repeatdelay.setValue(repeatdelay)
Bugtracker.showassignee.setValue(showassignee)
Bugtracker.extended.setValue(extended)
Bugtracker.useNotices.setValue(useNotices)
Bugtracker.saveDiscoveredTrackers.setValue(saveDiscoveredTrackers)
Bugtracker = conf.registerPlugin('Bugtracker')
@ -129,11 +131,14 @@ conf.registerChannelValue(Bugtracker, 'repeatdelay',
registry.Integer(60, """Number of seconds to wait between repeated bug calls"""))
conf.registerChannelValue(Bugtracker, 'showassignee',
registry.Boolean(False, """Whether to show the assignee in bug reports"""))
registry.Boolean(False, """Whether to show the assignee in bug information"""))
conf.registerChannelValue(Bugtracker, 'extended',
registry.Boolean(False, """Whether to show extended bug information, specific to trackers"""))
conf.registerChannelValue(Bugtracker, 'useNotices',
registry.Boolean(False, """Whether to use notices instead of normal messages to send bug information"""))
conf.registerGlobalValue(Bugtracker, 'saveDiscoveredTrackers',
registry.Boolean(False, """Whether to save automatically discovered trackers to configuration"""))

View File

@ -412,7 +412,10 @@ class Bugtracker(callbacks.PluginRegexp):
irc.error(str(e))
else:
if report:
irc.reply(report)
if not self.registryValue('useNotices', channel, irc.network):
irc.reply(report)
else:
irc.reply(report, notice=True)
def bugUrlSnarfer(self, irc, msg, match):
r"(https?://)?((bugs\.debian\.org|pad\.lv)/|\S+/(show_bug\.cgi\?id=|bugreport\.cgi\?bug=|view\.php\?id=|bug=|bugs/|\+bug/|tickets?/|feature-requests/|patches/|todo/|issues/|pulls?/|merge_requests/))(?P<bug>\d+)"
@ -452,7 +455,10 @@ class Bugtracker(callbacks.PluginRegexp):
irc.error(str(e))
else:
if report:
irc.reply(report)
if not self.registryValue('useNotices', channel, irc.network):
irc.reply(report)
else:
irc.reply(report, notice=True)
# Only useful to Launchpad developers
def oopsSnarfer(self, irc, msg, match):
@ -467,7 +473,11 @@ class Bugtracker(callbacks.PluginRegexp):
if not self.is_ok(channel or msg.nick, irc.network, 'lpoops', oopsid):
return
if not match.group(1):
irc.reply('https://oops.canonical.com/?oopsid=OOPS-%s' % oopsid)
report = 'https://oops.canonical.com/?oopsid=OOPS-%s' % oopsid
if not self.registryValue('useNotices', channel, irc.network):
irc.reply(report)
else:
irc.reply(report, notice=True)
def cveSnarfer(self, irc, msg, match):
r"(https?://\S+=)?CVE[- ](?P<cveid>\d{4}[- ]\d{4,})"
@ -494,7 +504,10 @@ class Bugtracker(callbacks.PluginRegexp):
irc.error(str(e))
else:
if report:
irc.reply(report)
if not self.registryValue('useNotices', channel, irc.network):
irc.reply(report)
else:
irc.reply(report, notice=True)
#TODO: As we will depend on launchpadlib, we should consider using lazr.uri.URI to do URL parsing
def get_tracker(self, snarfurl, bugid):