2010-05-24 13:38:06 +00:00
# -*- Encoding: utf-8 -*-
2006-06-26 17:57:20 +00:00
###
2007-01-23 23:42:45 +00:00
# Copyright (c) 2005-2007 Dennis Kaarsemaker
2011-05-28 06:33:21 +00:00
# Copyright (c) 2008-2011 Terence Simpson
2020-06-20 21:04:04 +00:00
# Copyright (c) 2017- Krytarik Raido
2006-06-26 17:57:20 +00:00
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# 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.
#
###
import supybot . conf as conf
import supybot . registry as registry
import supybot . ircutils as ircutils
2020-06-20 21:04:04 +00:00
import supybot . log as supylog
from . trackers import defined_bugtrackers
class Bugtrackers ( registry . SpaceSeparatedListOfStrings ) :
List = ircutils . IrcSet
2006-06-26 17:57:20 +00:00
def configure ( advanced ) :
2010-05-29 13:36:43 +00:00
from supybot . questions import expect , something , yn , output
2010-05-28 22:51:28 +00:00
def anything ( prompt , default = None ) :
""" Because supybot is pure fail """
from supybot . questions import expect
return expect ( prompt , [ ] , default = default )
2010-05-29 13:36:43 +00:00
Bugtracker = conf . registerPlugin ( ' Bugtracker ' , True )
def getRepeatdelay ( ) :
output ( " How many seconds should the bot wait before repeating bug information? " )
2018-03-09 18:56:04 +00:00
repeatdelay = something ( " Enter a number greater or equal to 0. " , default = Bugtracker . repeatdelay . _default )
2010-05-29 13:36:43 +00:00
try :
repeatdelay = int ( repeatdelay )
if repeatdelay < 0 :
raise TypeError
except TypeError :
2018-03-09 18:56:04 +00:00
output ( " Invalid value ' %s ' , it must be an integer greater or equal to 0. " % repeatdelay )
2010-05-29 13:36:43 +00:00
return getRepeatdelay ( )
else :
return repeatdelay
2020-06-21 07:04:04 +00:00
output ( " Each of the next 4 questions can be set per-channel with the ' @config channel ' command. " )
2020-06-20 21:04:04 +00:00
bugSnarfer = yn ( " Enable detecting bug numbers and URLs in all channels? " , default = Bugtracker . bugSnarfer . _default )
2020-06-21 07:04:04 +00:00
commitSnarfer = yn ( " Enable detecting commit hashes and URLs in all channels? " , default = Bugtracker . commitSnarfer . _default )
2020-06-20 21:04:04 +00:00
cveSnarfer = yn ( " Enable detecting CVE numbers and URLs in all channels? " , default = Bugtracker . cveSnarfer . _default )
2011-02-16 14:45:27 +00:00
oopsSnarfer = yn ( " Enable detecting Launchpad OOPS IDs in all channels? " , default = Bugtracker . oopsSnarfer . _default )
2021-12-02 21:13:04 +00:00
2010-05-29 13:36:43 +00:00
if advanced :
2018-03-09 18:56:04 +00:00
replyNoBugtracker = something ( " What should the bot reply with when a user requests information from an unknown bug tracker? " , default = Bugtracker . replyNoBugtracker . _default )
snarfTarget = something ( " What should be the default bug tracker used when none is specified? " , default = Bugtracker . snarfTarget . _default )
2011-05-28 06:33:21 +00:00
replyWhenNotFound = yn ( " Should the bot report when a bug is not found? " , default = Bugtracker . replyWhenNotFound . _default )
2020-06-07 19:13:04 +00:00
replyWhenError = yn ( " Should the bot report when an error occurs on getting a bug? " , default = Bugtracker . replyWhenError . _default )
2010-05-29 13:36:43 +00:00
repeatdelay = getRepeatdelay ( )
else :
replyNoBugtracker = Bugtracker . replyNoBugtracker . _default
snarfTarget = Bugtracker . snarfTarget . _default
replyWhenNotFound = Bugtracker . replyWhenNotFound . _default
2020-06-07 19:13:04 +00:00
replyWhenError = Bugtracker . replyWhenError . _default
2010-05-29 13:36:43 +00:00
repeatdelay = Bugtracker . repeatdelay . _default
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 )
2019-07-08 00:45:04 +00:00
saveDiscoveredTrackers = yn ( " Save automatically discovered trackers to configuration? " , default = Bugtracker . saveDiscoveredTrackers . _default )
2010-05-29 13:36:43 +00:00
Bugtracker . bugSnarfer . setValue ( bugSnarfer )
2020-06-21 07:04:04 +00:00
Bugtracker . commitSnarfer . setValue ( commitSnarfer )
2011-02-16 14:45:27 +00:00
Bugtracker . cveSnarfer . setValue ( cveSnarfer )
Bugtracker . oopsSnarfer . setValue ( oopsSnarfer )
2010-05-29 13:36:43 +00:00
Bugtracker . replyNoBugtracker . setValue ( replyNoBugtracker )
Bugtracker . snarfTarget . setValue ( snarfTarget )
Bugtracker . replyWhenNotFound . setValue ( replyWhenNotFound )
2020-06-07 19:13:04 +00:00
Bugtracker . replyWhenError . setValue ( replyWhenError )
2010-05-29 13:36:43 +00:00
Bugtracker . repeatdelay . setValue ( repeatdelay )
Bugtracker . showassignee . setValue ( showassignee )
Bugtracker . extended . setValue ( extended )
2019-07-08 00:45:04 +00:00
Bugtracker . saveDiscoveredTrackers . setValue ( saveDiscoveredTrackers )
2006-06-26 17:57:20 +00:00
Bugtracker = conf . registerPlugin ( ' Bugtracker ' )
2010-05-19 13:55:10 +00:00
conf . registerChannelValue ( Bugtracker , ' bugSnarfer ' ,
2006-06-26 17:57:20 +00:00
registry . Boolean ( False , """ Determines whether the bug snarfer will be
2018-03-09 18:56:04 +00:00
enabled , such that any bugtracker URLs and bug ### seen in the channel
2006-06-26 17:57:20 +00:00
will have their information reported into the channel . """ ))
2010-05-19 13:55:10 +00:00
2020-06-21 07:04:04 +00:00
conf . registerChannelValue ( Bugtracker , ' commitSnarfer ' ,
registry . Boolean ( False , """ Determines whether the commit snarfer will be
enabled , such that any commit URLs and commit ### seen in the channel
will have their information reported into the channel . """ ))
2011-02-16 14:45:27 +00:00
conf . registerChannelValue ( Bugtracker , ' cveSnarfer ' ,
registry . Boolean ( False , """ Determines whether the CVE snarfer will be
enabled , such that any CVE URLs and CVE - ? ? ? ? - ? ? ? ? seen in the channel
will have their information reported into the channel . """ ))
conf . registerChannelValue ( Bugtracker , ' oopsSnarfer ' ,
registry . Boolean ( False , """ Determines whether the OOPS snarfer will be
enabled , such that any OOPS ### seen in the channel
will have their information reported into the channel . """ ))
2010-05-19 13:55:10 +00:00
conf . registerChannelValue ( Bugtracker , ' replyNoBugtracker ' ,
2018-03-09 18:56:04 +00:00
registry . String ( " I have no bugtracker ' %s ' " , """ Determines the phrase
2006-06-26 17:57:20 +00:00
to use when notifying the user that there is no information about that
bugtracker site . """ ))
2010-05-19 13:55:10 +00:00
conf . registerChannelValue ( Bugtracker , ' snarfTarget ' ,
2019-07-08 00:45:04 +00:00
registry . String ( ' launchpad ' , """ Determines the bugtracker to query when the snarf command is triggered """ ) )
2006-06-26 17:57:20 +00:00
2020-06-20 21:04:04 +00:00
conf . registerGlobalValue ( Bugtracker , ' bugtrackers ' ,
Bugtrackers ( [ ] , """ Determines what bugtrackers will be added to the bot when it starts. """ ) )
2010-05-19 13:55:10 +00:00
conf . registerGlobalValue ( Bugtracker , ' replyWhenNotFound ' ,
2019-07-08 00:45:04 +00:00
registry . Boolean ( False , """ Whether to send a message when a bug could not be found """ ) )
2010-05-19 13:55:10 +00:00
2020-06-07 19:13:04 +00:00
conf . registerGlobalValue ( Bugtracker , ' replyWhenError ' ,
registry . Boolean ( False , """ Whether to send a message when an error occurred on getting a bug """ ) )
2010-05-19 13:55:10 +00:00
conf . registerChannelValue ( Bugtracker , ' repeatdelay ' ,
2006-12-27 14:33:59 +00:00
registry . Integer ( 60 , """ Number of seconds to wait between repeated bug calls """ ) )
2010-05-19 13:55:10 +00:00
conf . registerChannelValue ( Bugtracker , ' showassignee ' ,
2007-09-17 19:00:51 +00:00
registry . Boolean ( False , """ Whether to show the assignee in bug reports """ ) )
2010-05-19 13:55:10 +00:00
conf . registerChannelValue ( Bugtracker , ' extended ' ,
2018-03-09 18:56:04 +00:00
registry . Boolean ( False , """ Whether to show extended bug information, specific to trackers """ ) )
2019-07-08 00:45:04 +00:00
conf . registerGlobalValue ( Bugtracker , ' saveDiscoveredTrackers ' ,
registry . Boolean ( False , """ Whether to save automatically discovered trackers to configuration """ ) )
2020-06-20 21:04:04 +00:00
def registerBugtracker ( name , url = ' ' , description = ' ' , trackertype = ' ' , aliases = [ ] ) :
Bugtracker . bugtrackers ( ) . add ( name )
group = conf . registerGroup ( Bugtracker . bugtrackers , name )
URL = conf . registerGlobalValue ( group , ' url ' , registry . String ( ' ' , ' URL of the tracker. ' ) )
DESC = conf . registerGlobalValue ( group , ' description ' , registry . String ( ' ' , ' Full name of the tracker. ' ) )
TRACKERTYPE = conf . registerGlobalValue ( group , ' trackertype ' , registry . String ( ' ' , ' Type of the tracker. ' ) )
ALIASES = conf . registerGlobalValue ( group , ' aliases ' , registry . SpaceSeparatedSetOfStrings ( [ ] , ' Aliases of the tracker. ' ) )
if url :
URL . setValue ( url )
if description :
DESC . setValue ( description )
if aliases :
ALIASES . setValue ( aliases )
if trackertype :
if trackertype in defined_bugtrackers :
TRACKERTYPE . setValue ( trackertype )
else :
supylog . warning ( " Bugtracker: Unknown trackertype ' %s ' ( %s ) " % ( trackertype , name ) )
for name in Bugtracker . bugtrackers ( ) :
registerBugtracker ( name )
default_bugtrackers = {
' mozilla ' : ( ' https://bugzilla.mozilla.org ' , ' Mozilla ' , ' bugzilla ' , [ ] ) ,
' gtk ' : ( ' https://gitlab.gnome.org/GNOME/gtk/-/issues ' , ' GTK ' , ' gitlab ' , [ ] ) ,
' kde ' : ( ' https://bugs.kde.org ' , ' KDE ' , ' bugzilla ' , [ ] ) ,
' lxde ' : ( ' https://sourceforge.net/p/lxde/bugs ' , ' LXDE ' , ' sourceforge ' , [ ] ) ,
' openoffice ' : ( ' https://bz.apache.org/ooo ' , ' OpenOffice ' , ' bugzilla ' , [ ] ) ,
' launchpad ' : ( ' https://launchpad.net ' , ' Launchpad ' , ' launchpad ' , [ ' lp ' , ' ubuntu ' , ' ubottu ' ] ) ,
' debian ' : ( ' https://bugs.debian.org ' , ' Debian ' , ' debbugs ' , [ ] ) ,
' irssi ' : ( ' https://github.com/irssi/irssi/issues ' , ' Irssi ' , ' github ' , [ ] ) ,
2020-06-22 05:04:04 +00:00
' cgit ' : ( ' https://git.zx2c4.com/cgit/commit ' , ' CGit ' , ' cgit ' , [ ] ) ,
2020-06-20 21:04:04 +00:00
' mantis ' : ( ' https://www.mantisbt.org/bugs ' , ' Mantis ' , ' mantis ' , [ ] ) ,
' trac ' : ( ' https://trac.edgewall.org/ticket ' , ' Trac ' , ' trac ' , [ ] ) ,
' pidgin ' : ( ' https://developer.pidgin.im/ticket ' , ' Pidgin ' , ' trac ' , [ ] )
}