ubuntu-bots team mailing list archive
-
ubuntu-bots team
-
Mailing list archive
-
Message #00308
[Merge] lp:~krytarik/ubuntu-bots/bugtracker-output into lp:ubuntu-bots
Krytarik Raido has proposed merging lp:~krytarik/ubuntu-bots/bugtracker-output into lp:ubuntu-bots.
Requested reviews:
Benjamin Rubin (bnrubin)
Ubuntu IRC Bots (ubuntu-bots)
For more details, see:
https://code.launchpad.net/~krytarik/ubuntu-bots/bugtracker-output/+merge/311899
Bugtracker: Make sure output fits maximum length of IRC messages, improve its formatting.
--
Your team Ubuntu IRC Bots is requested to review the proposed merge of lp:~krytarik/ubuntu-bots/bugtracker-output into lp:ubuntu-bots.
=== modified file 'Bugtracker/plugin.py'
--- Bugtracker/plugin.py 2014-08-12 16:47:38 +0000
+++ Bugtracker/plugin.py 2016-11-27 22:00:08 +0000
@@ -531,37 +531,50 @@
def get_bug(self, channel, tracker, id, do_assignee, do_url = True, show_tracker = True):
reports = []
+ message_max = 450 - len(channel)
+
if not self.is_ok(channel, tracker, id):
return []
+
for r in tracker.get_bug(id):
- showext = self.registryValue('extended', channel)
- extinfo = ''
+ show_ext = self.registryValue('extended', channel)
+
if len(r) == 8:
(bid, product, title, severity, status, assignee, url, extinfo) = r
else:
(bid, product, title, severity, status, assignee, url) = r
- severity = severity[0].upper() + severity[1:].lower()
- status = status[0].upper() + status[1:].lower()
- tracker_name = tracker.description + ' '
- if not do_url:
- url = ''
- if not show_tracker:
- tracker_name = ''
+ if show_tracker:
+ report = '%s bug %s' % (tracker.description, bid)
+ else:
+ report = 'Bug %s' % bid
+
if product:
- if showext:
- reports.append("%sbug %s in %s \"%s\" %s [%s,%s] %s" % (tracker_name, bid, product,
- title, extinfo, severity, status, url))
- else:
- reports.append("%sbug %s in %s \"%s\" [%s,%s] %s" % (tracker_name, bid, product,
- title, severity, status, url))
- else:
- if showext:
- reports.append("%sbug %s \"%s\" %s [%s,%s] %s" % (tracker_name, bid, title, extinfo, severity, status, url))
- else:
- reports.append("%sbug %s \"%s\" [%s,%s] %s" % (tracker_name, bid, title, severity, status, url))
+ report += ' in %s' % product
+
+ report += ' "%s"' % title.replace('"', '\'')
+
+ if show_ext and extinfo:
+ report += ' %s' % extinfo
+
if do_assignee and assignee:
- reports[-1] = reports[-1] + (" - Assigned to %s" % assignee)
+ report += ' [assigned: %s]' % assignee
+
+ report += ' [%s, %s]' % (severity, status)
+
+ if do_url:
+ report += ' %s' % url
+
+ if len(report) > message_max:
+ report_parts = report.split('"')
+ report_start = report_parts[0]
+ report_end = report_parts[-1]
+ report_title = '"'.join(report_parts[1:-1])
+ title_max = message_max - len(report_start) - len(report_end) - 5
+ report_title_cut = report_title[:title_max].rsplit(None, 1)[0] + '...'
+ report = '%s"%s"%s' % (report_start, report_title_cut, report_end)
+
+ reports.append(report)
return reports
# Define all bugtrackers