2006-10-19 14:39:11 +00:00
|
|
|
###
|
2007-01-23 23:42:45 +00:00
|
|
|
# Copyright (c) 2006,2007 Dennis Kaarsemaker
|
2006-10-19 14:39:11 +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.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
|
2006-06-26 17:57:20 +00:00
|
|
|
import supybot.conf as conf
|
|
|
|
import supybot.registry as registry
|
|
|
|
|
2010-03-17 10:14:07 +00:00
|
|
|
class ValidTypes(registry.OnlySomeStrings):
|
|
|
|
"""Invalid type, valid types are: 'removal', 'ban' or 'quiet'."""
|
|
|
|
validStrings = ('removal', 'ban', 'quiet')
|
|
|
|
|
|
|
|
class SpaceSeparatedListOfTypes(registry.SpaceSeparatedListOf):
|
|
|
|
Value = ValidTypes
|
|
|
|
|
|
|
|
|
2010-03-31 03:03:13 +00:00
|
|
|
# This little hack allows me to store last time bans were checked for review
|
|
|
|
# and guarantee that nobody will edit it.
|
|
|
|
# I'm using a registry option instead of the SQL db because this is much simpler.
|
|
|
|
class ReadOnlyValue(registry.Integer):
|
|
|
|
"""This is a read only option."""
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(ReadOnlyValue, self).__init__(*args, **kwargs)
|
|
|
|
self.value = None
|
|
|
|
|
2010-03-30 20:13:00 +00:00
|
|
|
def set(self, s):
|
|
|
|
try:
|
2010-03-31 03:03:13 +00:00
|
|
|
if not self.value:
|
|
|
|
self.setValue(int(s))
|
|
|
|
else:
|
2010-03-30 20:13:00 +00:00
|
|
|
raise ValueError
|
|
|
|
except ValueError:
|
|
|
|
self.error()
|
|
|
|
|
|
|
|
|
2006-06-26 17:57:20 +00:00
|
|
|
def configure(advanced):
|
|
|
|
conf.registerPlugin('Bantracker', True)
|
|
|
|
|
|
|
|
Bantracker = conf.registerPlugin('Bantracker')
|
2010-03-17 00:46:18 +00:00
|
|
|
conf.registerChannelValue(Bantracker, 'enabled',
|
2006-06-26 17:57:20 +00:00
|
|
|
registry.Boolean(False, """Enable the bantracker"""))
|
2010-03-17 00:46:18 +00:00
|
|
|
conf.registerGlobalValue(Bantracker, 'database',
|
2009-10-12 18:26:35 +00:00
|
|
|
registry.String('', "Filename of the bans database", private=True))
|
2010-03-17 00:46:18 +00:00
|
|
|
conf.registerGlobalValue(Bantracker, 'bansite',
|
2008-05-05 15:28:59 +00:00
|
|
|
registry.String('', "Web site for the bantracker, without the 'bans.cgi' appended", private=True))
|
2010-03-15 16:12:51 +00:00
|
|
|
|
2010-03-16 02:26:19 +00:00
|
|
|
conf.registerGroup(Bantracker, 'commentRequest')
|
2010-03-17 10:14:07 +00:00
|
|
|
conf.registerChannelValue(Bantracker.commentRequest, 'type',
|
|
|
|
SpaceSeparatedListOfTypes(['removal', 'ban', 'quiet'],
|
|
|
|
"List of events for which the bot should request a comment."))
|
2010-03-16 02:26:19 +00:00
|
|
|
conf.registerChannelValue(Bantracker.commentRequest, 'ignore',
|
2010-03-15 16:12:51 +00:00
|
|
|
registry.SpaceSeparatedListOfStrings([],
|
2010-03-15 23:51:32 +00:00
|
|
|
"List of nicks for which the bot won't request to comment a ban/quiet/removal."\
|
|
|
|
" Is case insensible and wildcards * ? are accepted."))
|
2010-03-16 02:26:19 +00:00
|
|
|
conf.registerChannelValue(Bantracker.commentRequest, 'forward',
|
2010-03-15 23:51:32 +00:00
|
|
|
registry.SpaceSeparatedListOfStrings([],
|
2010-03-16 02:26:19 +00:00
|
|
|
"List of nicks for which the bot will forward the request to"\
|
|
|
|
" the channels/nicks defined in forwards.channels option."\
|
2010-03-15 23:51:32 +00:00
|
|
|
" Is case insensible and wildcards * ? are accepted."))
|
2010-03-16 02:26:19 +00:00
|
|
|
conf.registerChannelValue(Bantracker.commentRequest.forward, 'channels',
|
2010-03-15 23:51:32 +00:00
|
|
|
registry.SpaceSeparatedListOfStrings([],
|
2010-03-16 02:26:19 +00:00
|
|
|
"List of channels/nicks to forward the request if the op that set the ban/quiet"\
|
|
|
|
" is in the forward list."))
|
2010-03-15 23:51:32 +00:00
|
|
|
|
2010-03-30 16:32:28 +00:00
|
|
|
|
|
|
|
# temp config
|
|
|
|
conf.registerGlobalValue(Bantracker, 'reviewTime',
|
2010-03-31 03:03:13 +00:00
|
|
|
ReadOnlyValue(0,
|
|
|
|
"Timestamp used internally for identify bans that need review. Can't and shouldn't be edited."))
|
2010-03-30 16:32:28 +00:00
|
|
|
conf.registerGlobalValue(Bantracker, 'reviewAfterTime',
|
2010-03-31 03:03:13 +00:00
|
|
|
registry.Float(7,
|
|
|
|
"Days after which the bot will request for review a ban. Can be an integer or decimal value."))
|