X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=sid%2Fbts.py;h=82b31d41ef5398bb8f5ab1478ceed14a115fd6f3;hb=dc4ac4f37ac6b92014ec41f6233ada96c8484adb;hp=b39197ce7a46060db3ec09205894b5f554793d85;hpb=51dcb10758c6b5b33fab57aee5d16485fd344d9d;p=sid.git diff --git a/sid/bts.py b/sid/bts.py index b39197c..82b31d4 100644 --- a/sid/bts.py +++ b/sid/bts.py @@ -25,16 +25,23 @@ from .plugin import Plugin, botcmd class Bugs(Plugin): """Gets bugs info from the BTS + + .. note:: + This plugin depends on external module: **python-debianbts** """ re_bugs = re_compile(r'(?<=#)(\d{6,7})') re_pkg = re_compile(r'(?P[0-9a-z.+-]+)$') def __init__(self, bot): Plugin.__init__(self, bot) - bot.add_event_handler("muc::%s::message" % self.bot.room, self.muc_message) + bot.add_event_handler("muc::%s::message" % + self.bot.room, self.muc_message) def muc_message(self, msg): - """Handler method dealing with MUC incoming messages""" + """Handler method dealing with MUC incoming messages. + + Intercepts bugs number in MUC messages (as #629234), replies a bug + summary.""" # Does not reply to myself if msg['mucnick'] == self.bot.nick: return @@ -65,8 +72,8 @@ class Bugs(Plugin): @botcmd def bugs(self, rcv, args): - """Intercepts bugs number in messages (as #629234), reply a bug summary. - !bugs pkg-name : Returns latest bug reports if any + """ + **command** ``!bugs pkg-name`` : Returns latest bug reports if any """ if not args: return @@ -83,11 +90,9 @@ class Bugs(Plugin): return reports = debianbts.get_status(reports_ids) reports = sorted(reports, key=lambda r: r.date) - rprt_nb = len(reports) - msg = ['Open reports for {1} (total {0})'.format(rprt_nb, pkg.string)] + msg = ['Latest reports for {1} (total {0})'.format(len(reports), pkg.string)] # Reverse and take last reports for rep in reports[::-1][:4]: msg.append('{r.bug_num}: {r.date:%Y-%m-%d} {r.subject}'.format(r=rep)) message = {'mbody': '\n'.join(msg)} self.reply(rcv, message) -