X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=sid%2Fbts.py;h=305ef717b50318c750f8a0a1e26bdd18ca77e1df;hb=cf4e0e61fd723ec820449c6dd26a820514404c63;hp=1a7fea46640ceb48340ec85191f6085adad5d7c0;hpb=912b046c8bdf24a2e8a477269256ad99593f0728;p=sid.git diff --git a/sid/bts.py b/sid/bts.py index 1a7fea4..305ef71 100644 --- a/sid/bts.py +++ b/sid/bts.py @@ -1,20 +1,7 @@ # -*- coding: utf-8 -*- - -# Copyright (C) 2010, 2011 Anaël Verrier -# Copyright (C) 2015, 2020 kaliko - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, version 3 only. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - +# SPDX-FileCopyrightText: 2015, 2021 kaliko +# SPDX-FileCopyrightText: 2010, 2011 Anaël Verrier +# SPDX-License-Identifier: GPL-3.0-or-later from re import compile as re_compile @@ -25,8 +12,13 @@ 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})') + #: Bug id regexp, intercepts bug id in strings : "#629234", "bugs.debian.org/629234" and "bugreport.cgi?bug=629234" + re_bugs = re_compile(r'(?:(?<=#)|(?<=bugreport\.cgi\?bug=)|(?<=bugs\.debian\.org/))(\d{6,7})') + #: Package name regexp re_pkg = re_compile(r'(?P[0-9a-z.+-]+)$') def __init__(self, bot): @@ -35,12 +27,13 @@ class Bugs(Plugin): 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 - if '#' not in msg['body']: - return bugs = list() for bug_id in set(Bugs.re_bugs.findall(msg['body'].strip())): self.log.debug('got bug id: %s', bug_id) @@ -66,8 +59,9 @@ 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 + """Gets bugs info from the BTS + + ``!bugs pkg-name`` : Returns latest bug reports if any """ if not args: return