2005-01-19 14:14:38 +01:00
|
|
|
###
|
2005-01-19 14:33:05 +01:00
|
|
|
# Copyright (c) 2002-2005, Jeremiah Fincher
|
2011-06-07 03:44:15 +02:00
|
|
|
# Copyright (c) 2008-2009,2011, James Vega
|
2005-01-19 14:14:38 +01:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above copyright notice,
|
|
|
|
# this list of conditions, and the following disclaimer.
|
|
|
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
# this list of conditions, and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
# * Neither the name of the author of this software nor the name of
|
|
|
|
# contributors to this software may be used to endorse or promote products
|
|
|
|
# derived from this software without specific prior written consent.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
###
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
import socket
|
|
|
|
|
|
|
|
import supybot.utils as utils
|
|
|
|
import supybot.registry as registry
|
|
|
|
import supybot.ircutils as ircutils
|
2010-10-20 18:27:58 +02:00
|
|
|
from supybot.i18n import PluginInternationalization
|
|
|
|
_ = PluginInternationalization()
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
###
|
|
|
|
# version: This should be pretty obvious.
|
|
|
|
###
|
2010-08-20 16:31:05 +02:00
|
|
|
from supybot.version import version
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
###
|
|
|
|
# *** The following variables are affected by command-line options. They are
|
|
|
|
# not registry variables for a specific reason. Do *not* change these to
|
|
|
|
# registry variables without first consulting people smarter than yourself.
|
|
|
|
###
|
|
|
|
|
|
|
|
###
|
|
|
|
# daemonized: This determines whether or not the bot has been daemonized
|
|
|
|
# (i.e., set to run in the background). Obviously, this defaults
|
|
|
|
# to False. A command-line option for obvious reasons.
|
|
|
|
###
|
|
|
|
daemonized = False
|
|
|
|
|
|
|
|
###
|
|
|
|
# allowDefaultOwner: True if supybot.capabilities is allowed not to include
|
|
|
|
# '-owner' -- that is, if all users should be automatically
|
|
|
|
# recognized as owners. That would suck, hence we require a
|
|
|
|
# command-line option to allow this stupidity.
|
|
|
|
###
|
|
|
|
allowDefaultOwner = False
|
|
|
|
|
2005-01-27 07:59:08 +01:00
|
|
|
###
|
|
|
|
# Here we replace values in other modules as appropriate.
|
|
|
|
###
|
|
|
|
utils.web.defaultHeaders['User-agent'] = \
|
|
|
|
'Mozilla/5.0 (Compatible; Supybot %s)' % version
|
|
|
|
|
2005-01-19 14:14:38 +01:00
|
|
|
###
|
|
|
|
# The standard registry.
|
|
|
|
###
|
|
|
|
supybot = registry.Group()
|
|
|
|
supybot.setName('supybot')
|
|
|
|
|
|
|
|
def registerGroup(Group, name, group=None, **kwargs):
|
|
|
|
if kwargs:
|
|
|
|
group = registry.Group(**kwargs)
|
|
|
|
return Group.register(name, group)
|
|
|
|
|
|
|
|
def registerGlobalValue(group, name, value):
|
|
|
|
value.channelValue = False
|
|
|
|
return group.register(name, value)
|
|
|
|
|
|
|
|
def registerChannelValue(group, name, value):
|
|
|
|
value._supplyDefault = True
|
|
|
|
value.channelValue = True
|
|
|
|
g = group.register(name, value)
|
|
|
|
gname = g._name.lower()
|
2012-08-05 15:47:30 +02:00
|
|
|
for name in registry._cache.keys():
|
2005-01-19 14:14:38 +01:00
|
|
|
if name.lower().startswith(gname) and len(gname) < len(name):
|
|
|
|
name = name[len(gname)+1:] # +1 for .
|
|
|
|
parts = registry.split(name)
|
|
|
|
if len(parts) == 1 and parts[0] and ircutils.isChannel(parts[0]):
|
|
|
|
# This gets the channel values so they always persist.
|
|
|
|
g.get(parts[0])()
|
|
|
|
|
|
|
|
def registerPlugin(name, currentValue=None, public=True):
|
|
|
|
group = registerGlobalValue(supybot.plugins, name,
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether this plugin is loaded
|
2011-08-06 18:51:46 +02:00
|
|
|
by default."""), showDefault=False))
|
2005-01-19 14:14:38 +01:00
|
|
|
supybot.plugins().add(name)
|
|
|
|
registerGlobalValue(group, 'public',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(public, _("""Determines whether this plugin is
|
|
|
|
publicly visible.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
if currentValue is not None:
|
|
|
|
supybot.plugins.get(name).setValue(currentValue)
|
|
|
|
registerGroup(users.plugins, name)
|
|
|
|
return group
|
|
|
|
|
|
|
|
def get(group, channel=None):
|
|
|
|
if group.channelValue and \
|
|
|
|
channel is not None and ircutils.isChannel(channel):
|
|
|
|
return group.get(channel)()
|
|
|
|
else:
|
|
|
|
return group()
|
|
|
|
|
|
|
|
###
|
|
|
|
# The user info registry.
|
|
|
|
###
|
|
|
|
users = registry.Group()
|
|
|
|
users.setName('users')
|
|
|
|
registerGroup(users, 'plugins', orderAlphabetically=True)
|
|
|
|
|
|
|
|
def registerUserValue(group, name, value):
|
|
|
|
assert group._name.startswith('users')
|
|
|
|
value._supplyDefault = True
|
|
|
|
group.register(name, value)
|
|
|
|
|
|
|
|
class ValidNick(registry.String):
|
|
|
|
"""Value must be a valid IRC nick."""
|
|
|
|
def setValue(self, v):
|
|
|
|
if not ircutils.isNick(v):
|
|
|
|
self.error()
|
|
|
|
else:
|
|
|
|
registry.String.setValue(self, v)
|
|
|
|
|
2011-10-27 12:31:37 +02:00
|
|
|
class ValidNickOrEmpty(ValidNick):
|
|
|
|
"""Value must be a valid IRC nick or empty."""
|
|
|
|
def setValue(self, v):
|
|
|
|
if v != '' and not ircutils.isNick(v):
|
|
|
|
self.error()
|
|
|
|
else:
|
|
|
|
registry.String.setValue(self, v)
|
|
|
|
|
2005-01-19 14:14:38 +01:00
|
|
|
class ValidNicks(registry.SpaceSeparatedListOf):
|
|
|
|
Value = ValidNick
|
|
|
|
|
|
|
|
class ValidNickAllowingPercentS(ValidNick):
|
|
|
|
"""Value must be a valid IRC nick, with the possible exception of a %s
|
|
|
|
in it."""
|
|
|
|
def setValue(self, v):
|
|
|
|
# If this works, it's a valid nick, aside from the %s.
|
|
|
|
try:
|
|
|
|
ValidNick.setValue(self, v.replace('%s', ''))
|
|
|
|
# It's valid aside from the %s, we'll let it through.
|
|
|
|
registry.String.setValue(self, v)
|
|
|
|
except registry.InvalidRegistryValue:
|
|
|
|
self.error()
|
|
|
|
|
|
|
|
class ValidNicksAllowingPercentS(ValidNicks):
|
|
|
|
Value = ValidNickAllowingPercentS
|
|
|
|
|
|
|
|
class ValidChannel(registry.String):
|
|
|
|
"""Value must be a valid IRC channel name."""
|
|
|
|
def setValue(self, v):
|
2005-04-04 05:05:52 +02:00
|
|
|
self.channel = v
|
2005-01-19 14:14:38 +01:00
|
|
|
if ',' in v:
|
|
|
|
# To prevent stupid users from: a) trying to add a channel key
|
|
|
|
# with a comma in it, b) trying to add channels separated by
|
|
|
|
# commas instead of spaces
|
|
|
|
try:
|
|
|
|
(channel, _) = v.split(',')
|
|
|
|
except ValueError:
|
|
|
|
self.error()
|
|
|
|
else:
|
|
|
|
channel = v
|
|
|
|
if not ircutils.isChannel(channel):
|
|
|
|
self.error()
|
|
|
|
else:
|
|
|
|
registry.String.setValue(self, v)
|
|
|
|
|
2005-04-04 05:05:52 +02:00
|
|
|
def error(self):
|
|
|
|
try:
|
|
|
|
super(ValidChannel, self).error()
|
2012-08-05 15:47:30 +02:00
|
|
|
except registry.InvalidRegistryValue as e:
|
2005-04-04 05:05:52 +02:00
|
|
|
e.channel = self.channel
|
|
|
|
raise e
|
|
|
|
|
2005-02-09 01:39:11 +01:00
|
|
|
class ValidHostmask(registry.String):
|
|
|
|
"""Value must be a valid user hostmask."""
|
|
|
|
def setValue(self, v):
|
|
|
|
if not ircutils.isUserHostmask(v):
|
|
|
|
self.error()
|
|
|
|
super(ValidHostmask, self).setValue(v)
|
|
|
|
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot, 'nick',
|
2010-10-20 18:27:58 +02:00
|
|
|
ValidNick('supybot', _("""Determines the bot's default nick.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot.nick, 'alternates',
|
2010-10-20 18:27:58 +02:00
|
|
|
ValidNicksAllowingPercentS(['%s`', '%s_'], _("""Determines what alternative
|
2005-01-19 14:14:38 +01:00
|
|
|
nicks will be used if the primary nick (supybot.nick) isn't available. A
|
|
|
|
%s in this nick is replaced by the value of supybot.nick when used. If no
|
|
|
|
alternates are given, or if all are used, the supybot.nick will be perturbed
|
2010-10-20 18:27:58 +02:00
|
|
|
appropriately until an unused nick is found.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot, 'ident',
|
2011-06-13 11:25:19 +02:00
|
|
|
ValidNick('limnoria', _("""Determines the bot's ident string, if the server
|
2010-10-20 18:27:58 +02:00
|
|
|
doesn't provide one by default.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
class VersionIfEmpty(registry.String):
|
|
|
|
def __call__(self):
|
|
|
|
ret = registry.String.__call__(self)
|
|
|
|
if not ret:
|
|
|
|
ret = 'Supybot %s' % version
|
|
|
|
return ret
|
|
|
|
|
|
|
|
registerGlobalValue(supybot, 'user',
|
2010-10-20 18:27:58 +02:00
|
|
|
VersionIfEmpty('', _("""Determines the user the bot sends to the server.
|
2005-01-19 14:14:38 +01:00
|
|
|
A standard user using the current version of the bot will be generated if
|
2010-10-20 18:27:58 +02:00
|
|
|
this is left empty.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
class Networks(registry.SpaceSeparatedSetOfStrings):
|
|
|
|
List = ircutils.IrcSet
|
|
|
|
|
|
|
|
registerGlobalValue(supybot, 'networks',
|
2010-10-20 18:27:58 +02:00
|
|
|
Networks([], _("""Determines what networks the bot will connect to."""),
|
2005-01-19 14:14:38 +01:00
|
|
|
orderAlphabetically=True))
|
|
|
|
|
|
|
|
class Servers(registry.SpaceSeparatedListOfStrings):
|
|
|
|
def normalize(self, s):
|
|
|
|
if ':' not in s:
|
|
|
|
s += ':6667'
|
|
|
|
return s
|
|
|
|
|
|
|
|
def convert(self, s):
|
|
|
|
s = self.normalize(s)
|
|
|
|
(server, port) = s.split(':')
|
|
|
|
port = int(port)
|
|
|
|
return (server, port)
|
|
|
|
|
|
|
|
def __call__(self):
|
|
|
|
L = registry.SpaceSeparatedListOfStrings.__call__(self)
|
2012-08-05 15:47:30 +02:00
|
|
|
return list(map(self.convert, L))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return ' '.join(registry.SpaceSeparatedListOfStrings.__call__(self))
|
|
|
|
|
|
|
|
def append(self, s):
|
|
|
|
L = registry.SpaceSeparatedListOfStrings.__call__(self)
|
|
|
|
L.append(s)
|
|
|
|
|
|
|
|
class SpaceSeparatedSetOfChannels(registry.SpaceSeparatedListOf):
|
|
|
|
sorted = True
|
|
|
|
List = ircutils.IrcSet
|
|
|
|
Value = ValidChannel
|
|
|
|
def join(self, channel):
|
2012-08-05 15:47:30 +02:00
|
|
|
from . import ircmsgs # Don't put this globally! It's recursive.
|
2005-01-19 14:14:38 +01:00
|
|
|
key = self.key.get(channel)()
|
|
|
|
if key:
|
|
|
|
return ircmsgs.join(channel, key)
|
|
|
|
else:
|
|
|
|
return ircmsgs.join(channel)
|
|
|
|
|
2011-12-03 12:36:16 +01:00
|
|
|
def registerNetwork(name, password='', ssl=False, sasl_username='',
|
|
|
|
sasl_password=''):
|
2005-01-19 14:14:38 +01:00
|
|
|
network = registerGroup(supybot.networks, name)
|
|
|
|
registerGlobalValue(network, 'password', registry.String(password,
|
2010-10-20 18:27:58 +02:00
|
|
|
_("""Determines what password will be used on %s. Yes, we know that
|
2005-01-19 14:14:38 +01:00
|
|
|
technically passwords are server-specific and not network-specific,
|
2010-10-20 18:27:58 +02:00
|
|
|
but this is the best we can do right now.""") % name, private=True))
|
2005-01-19 14:14:38 +01:00
|
|
|
registryServers = registerGlobalValue(network, 'servers', Servers([],
|
2010-10-20 18:27:58 +02:00
|
|
|
_("""Determines what servers the bot will connect to for %s. Each will
|
2005-01-19 14:14:38 +01:00
|
|
|
be tried in order, wrapping back to the first when the cycle is
|
2010-10-20 18:27:58 +02:00
|
|
|
completed.""") % name))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(network, 'channels', SpaceSeparatedSetOfChannels([],
|
2010-10-20 18:27:58 +02:00
|
|
|
_("""Determines what channels the bot will join only on %s.""") %
|
|
|
|
name))
|
2005-12-14 05:20:04 +01:00
|
|
|
registerGlobalValue(network, 'ssl', registry.Boolean(ssl,
|
2010-10-20 18:27:58 +02:00
|
|
|
_("""Determines whether the bot will attempt to connect with SSL
|
|
|
|
sockets to %s.""") % name))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerChannelValue(network.channels, 'key', registry.String('',
|
2010-10-20 18:27:58 +02:00
|
|
|
_("""Determines what key (if any) will be used to join the
|
|
|
|
channel.""")))
|
2011-10-27 12:31:37 +02:00
|
|
|
registerGlobalValue(network, 'nick', ValidNickOrEmpty('', _("""Determines
|
|
|
|
what nick the bot will use on this network. If empty, defaults to
|
|
|
|
supybot.nick.""")))
|
2012-08-06 15:59:00 +02:00
|
|
|
registerGlobalValue(network, 'umodes',
|
|
|
|
registry.String('', _("""Determines what user modes the bot will request
|
|
|
|
from the server when it first connects. If empty, defaults to
|
|
|
|
supybot.protocols.irc.umodes""")))
|
2011-09-13 11:07:52 +02:00
|
|
|
sasl = registerGroup(network, 'sasl')
|
2011-09-13 19:55:31 +02:00
|
|
|
registerGlobalValue(sasl, 'username', registry.String(sasl_username,
|
2011-09-13 11:07:52 +02:00
|
|
|
_("""Determines what SASL username will be used on %s. This should
|
|
|
|
be the bot's account name. Due to the way SASL works, you can't use
|
|
|
|
any grouped nick.""") % name, private=False))
|
2011-12-03 12:36:16 +01:00
|
|
|
registerGlobalValue(sasl, 'password', registry.String(sasl_password,
|
2011-09-13 17:01:18 +02:00
|
|
|
_("""Determines what SASL password will be used on %s.""") \
|
|
|
|
% name, private=True))
|
2005-01-19 14:14:38 +01:00
|
|
|
return network
|
|
|
|
|
|
|
|
# Let's fill our networks.
|
2012-08-05 15:47:30 +02:00
|
|
|
for (name, s) in registry._cache.items():
|
2005-01-19 14:14:38 +01:00
|
|
|
if name.startswith('supybot.networks.'):
|
|
|
|
parts = name.split('.')
|
|
|
|
name = parts[2]
|
|
|
|
if name != 'default':
|
|
|
|
registerNetwork(name)
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
# Reply/error tweaking.
|
|
|
|
###
|
|
|
|
registerGroup(supybot, 'reply')
|
|
|
|
|
|
|
|
registerGroup(supybot.reply, 'format')
|
2012-07-31 15:12:33 +02:00
|
|
|
registerChannelValue(supybot.reply.format, 'url',
|
|
|
|
registry.String('<%s>', _("""Determines how urls should be formatted.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerChannelValue(supybot.reply.format, 'time',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.String('%I:%M %p, %B %d, %Y', _("""Determines how timestamps
|
|
|
|
printed for human reading should be formatted. Refer to the Python
|
|
|
|
documentation for the time module to see valid formatting characters for
|
|
|
|
time formats.""")))
|
2005-01-28 16:23:18 +01:00
|
|
|
def timestamp(t):
|
2005-02-01 10:53:08 +01:00
|
|
|
if t is None:
|
|
|
|
t = time.time()
|
2005-01-28 16:23:18 +01:00
|
|
|
t = time.localtime(t)
|
2005-02-01 12:57:50 +01:00
|
|
|
format = get(supybot.reply.format.time, dynamic.channel)
|
2005-01-28 16:23:18 +01:00
|
|
|
return time.strftime(format, t)
|
|
|
|
utils.str.timestamp = timestamp
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGroup(supybot.reply.format.time, 'elapsed')
|
|
|
|
registerChannelValue(supybot.reply.format.time.elapsed, 'short',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether elapsed times will be given
|
|
|
|
as "1 day, 2 hours, 3 minutes, and 15 seconds" or as "1d 2h 3m 15s".""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
2005-02-15 14:57:57 +01:00
|
|
|
originalTimeElapsed = utils.timeElapsed
|
2005-01-19 14:14:38 +01:00
|
|
|
def timeElapsed(*args, **kwargs):
|
|
|
|
kwargs['short'] = supybot.reply.format.time.elapsed.short()
|
|
|
|
return originalTimeElapsed(*args, **kwargs)
|
2005-02-15 14:57:57 +01:00
|
|
|
utils.timeElapsed = timeElapsed
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot.reply, 'maximumLength',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Integer(512*256, _("""Determines the absolute maximum length of
|
|
|
|
the bot's reply -- no reply will be passed through the bot with a length
|
|
|
|
greater than this.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.reply, 'mores',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(True, _("""Determines whether the bot will break up long
|
2005-01-19 14:14:38 +01:00
|
|
|
messages into chunks and allow users to use the 'more' command to get the
|
2010-10-20 18:27:58 +02:00
|
|
|
remaining chunks.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.reply.mores, 'maximum',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.PositiveInteger(50, _("""Determines what the maximum number of
|
|
|
|
chunks (for use with the 'more' command) will be.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.reply.mores, 'length',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.NonNegativeInteger(0, _("""Determines how long individual chunks
|
2005-01-19 14:14:38 +01:00
|
|
|
will be. If set to 0, uses our super-tweaked,
|
2010-10-20 18:27:58 +02:00
|
|
|
get-the-most-out-of-an-individual-message default.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.reply.mores, 'instant',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.PositiveInteger(1, _("""Determines how many mores will be sent
|
2005-01-19 14:14:38 +01:00
|
|
|
instantly (i.e., without the use of the more command, immediately when
|
|
|
|
they are formed). Defaults to 1, which means that a more command will be
|
2010-10-20 18:27:58 +02:00
|
|
|
required for all but the first chunk.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
2012-08-10 14:27:25 +02:00
|
|
|
registerChannelValue(supybot.reply, 'oneToOne',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(True, _("""Determines whether the bot will send
|
2005-01-19 14:14:38 +01:00
|
|
|
multi-message replies in a single message or in multiple messages. For
|
|
|
|
safety purposes (so the bot is less likely to flood) it will normally send
|
2010-10-20 18:27:58 +02:00
|
|
|
everything in a single message, using mores if necessary.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.reply, 'whenNotCommand',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(True, _("""Determines whether the bot will reply with an
|
2005-01-19 14:14:38 +01:00
|
|
|
error message when it is addressed but not given a valid command. If this
|
|
|
|
value is False, the bot will remain silent, as long as no other plugins
|
2010-10-20 18:27:58 +02:00
|
|
|
override the normal behavior.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGroup(supybot.reply, 'error')
|
|
|
|
registerGlobalValue(supybot.reply.error, 'detailed',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether error messages that result
|
2005-01-19 14:14:38 +01:00
|
|
|
from bugs in the bot will show a detailed error message (the uncaught
|
2010-10-20 18:27:58 +02:00
|
|
|
exception) or a generic error message.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerChannelValue(supybot.reply.error, 'inPrivate',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot will send error
|
2005-01-19 14:14:38 +01:00
|
|
|
messages to users in private. You might want to do this in order to keep
|
|
|
|
channel traffic to minimum. This can be used in combination with
|
2010-10-20 18:27:58 +02:00
|
|
|
supybot.reply.error.withNotice.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerChannelValue(supybot.reply.error, 'withNotice',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot will send error
|
2005-01-19 14:14:38 +01:00
|
|
|
messages to users via NOTICE instead of PRIVMSG. You might want to do this
|
|
|
|
so users can ignore NOTICEs from the bot and not have to see error
|
|
|
|
messages; or you might want to use it in combination with
|
|
|
|
supybot.reply.errorInPrivate so private errors don't open a query window
|
2010-10-20 18:27:58 +02:00
|
|
|
in most IRC clients.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerChannelValue(supybot.reply.error, 'noCapability',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot will send an error
|
2005-01-19 14:14:38 +01:00
|
|
|
message to users who attempt to call a command for which they do not have
|
|
|
|
the necessary capability. You may wish to make this True if you don't want
|
|
|
|
users to understand the underlying security system preventing them from
|
2010-10-20 18:27:58 +02:00
|
|
|
running certain commands.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.reply, 'inPrivate',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot will reply
|
2012-09-10 18:10:18 +02:00
|
|
|
privately when replying in a channel, rather than replying to the whole
|
2010-10-20 18:27:58 +02:00
|
|
|
channel.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.reply, 'withNotice',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot will reply with a
|
2005-01-19 14:14:38 +01:00
|
|
|
notice when replying in a channel, rather than replying with a privmsg as
|
2010-10-20 18:27:58 +02:00
|
|
|
normal.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
# XXX: User value.
|
|
|
|
registerGlobalValue(supybot.reply, 'withNoticeWhenPrivate',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot will reply with a
|
2005-01-19 14:14:38 +01:00
|
|
|
notice when it is sending a private message, in order not to open a /query
|
|
|
|
window in clients. This can be overridden by individual users via the user
|
2010-10-20 18:27:58 +02:00
|
|
|
configuration variable reply.withNoticeWhenPrivate.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.reply, 'withNickPrefix',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(True, _("""Determines whether the bot will always prefix
|
|
|
|
theuser's nick to its reply to that user's command.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.reply, 'whenNotAddressed',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot should attempt to
|
2005-01-19 14:14:38 +01:00
|
|
|
reply to all messages even if they don't address it (either via its nick
|
|
|
|
or a prefix character). If you set this to True, you almost certainly want
|
2010-10-20 18:27:58 +02:00
|
|
|
to set supybot.reply.whenNotCommand to False.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.reply, 'requireChannelCommandsToBeSentInChannel',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot will allow you to
|
2005-01-19 14:14:38 +01:00
|
|
|
send channel-related commands outside of that channel. Sometimes people
|
|
|
|
find it confusing if a channel-related command (like Filter.outfilter)
|
|
|
|
changes the behavior of the channel but was sent outside the channel
|
2010-10-20 18:27:58 +02:00
|
|
|
itself.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot, 'followIdentificationThroughNickChanges',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot will unidentify
|
2005-01-19 14:14:38 +01:00
|
|
|
someone when that person changes his or her nick. Setting this to True
|
|
|
|
will cause the bot to track such changes. It defaults to False for a
|
2010-10-20 18:27:58 +02:00
|
|
|
little greater security.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
2012-01-02 14:15:01 +01:00
|
|
|
registerChannelValue(supybot, 'alwaysJoinOnInvite',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot will always join a
|
2005-01-19 14:14:38 +01:00
|
|
|
channel when it's invited. If this value is False, the bot will only join
|
|
|
|
a channel if the user inviting it has the 'admin' capability (or if it's
|
2012-04-23 21:55:21 +02:00
|
|
|
explicitly told to join the channel using the Admin.join command).""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.reply, 'showSimpleSyntax',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Supybot normally replies with the full help
|
2005-01-19 14:14:38 +01:00
|
|
|
whenever a user misuses a command. If this value is set to True, the bot
|
|
|
|
will only reply with the syntax of the command (the first line of the
|
2010-10-20 18:27:58 +02:00
|
|
|
help) rather than the full help.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
class ValidPrefixChars(registry.String):
|
2012-08-02 15:26:44 +02:00
|
|
|
"""Value must contain only ~!@#$%^&*()_-+=[{}]\\|'\";:,<.>/?"""
|
2005-01-19 14:14:38 +01:00
|
|
|
def setValue(self, v):
|
2012-08-04 22:47:16 +02:00
|
|
|
if any([x not in '`~!@#$%^&*()_-+=[{}]\\|\'";:,<.>/?' for x in v]):
|
2005-01-19 14:14:38 +01:00
|
|
|
self.error()
|
|
|
|
registry.String.setValue(self, v)
|
|
|
|
|
|
|
|
registerGroup(supybot.reply, 'whenAddressedBy')
|
|
|
|
registerChannelValue(supybot.reply.whenAddressedBy, 'chars',
|
2010-10-20 18:27:58 +02:00
|
|
|
ValidPrefixChars('', _("""Determines what prefix characters the bot will
|
2005-01-19 14:14:38 +01:00
|
|
|
reply to. A prefix character is a single character that the bot will use
|
|
|
|
to determine what messages are addressed to it; when there are no prefix
|
|
|
|
characters set, it just uses its nick. Each character in this string is
|
|
|
|
interpreted individually; you can have multiple prefix chars
|
|
|
|
simultaneously, and if any one of them is used as a prefix the bot will
|
2010-10-20 18:27:58 +02:00
|
|
|
assume it is being addressed.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.reply.whenAddressedBy, 'strings',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.SpaceSeparatedSetOfStrings([], _("""Determines what strings the
|
|
|
|
bot will reply to when they are at the beginning of the message. Whereas
|
2005-01-19 14:14:38 +01:00
|
|
|
prefix.chars can only be one character (although there can be many of
|
|
|
|
them), this variable is a space-separated list of strings, so you can
|
|
|
|
set something like '@@ ??' and the bot will reply when a message is
|
2010-10-20 18:27:58 +02:00
|
|
|
prefixed by either @@ or ??.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerChannelValue(supybot.reply.whenAddressedBy, 'nick',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(True, _("""Determines whether the bot will reply when
|
|
|
|
people address it by its nick, rather than with a prefix character.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerChannelValue(supybot.reply.whenAddressedBy.nick, 'atEnd',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot will reply when
|
2005-01-19 14:14:38 +01:00
|
|
|
people address it by its nick at the end of the message, rather than at
|
2010-10-20 18:27:58 +02:00
|
|
|
the beginning.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerChannelValue(supybot.reply.whenAddressedBy, 'nicks',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.SpaceSeparatedSetOfStrings([], _("""Determines what extra nicks
|
|
|
|
the bot will always respond to when addressed by, even if its current nick
|
|
|
|
is something else.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
###
|
|
|
|
# Replies
|
|
|
|
###
|
|
|
|
registerGroup(supybot, 'replies')
|
|
|
|
|
|
|
|
registerChannelValue(supybot.replies, 'success',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.NormalizedString(_("""The operation succeeded."""),
|
|
|
|
_("""Determines what message the bot replies with when a command succeeded.
|
|
|
|
If this configuration variable is empty, no success message will be
|
|
|
|
sent.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.replies, 'error',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.NormalizedString(_("""An error has occurred and has been logged.
|
|
|
|
Please contact this bot's administrator for more information."""), _("""
|
2005-01-19 14:14:38 +01:00
|
|
|
Determines what error message the bot gives when it wants to be
|
2010-10-20 18:27:58 +02:00
|
|
|
ambiguous.""")))
|
2011-06-22 21:37:34 +02:00
|
|
|
|
|
|
|
registerChannelValue(supybot.replies, 'errorOwner',
|
|
|
|
registry.NormalizedString(_("""An error has occurred and has been logged.
|
|
|
|
Check the logs for more informations."""), _("""Determines what error
|
|
|
|
message the bot gives to the owner when it wants to be ambiguous.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.replies, 'incorrectAuthentication',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.NormalizedString(_("""Your hostmask doesn't match or your password
|
|
|
|
is wrong."""), _("""Determines what message the bot replies with when
|
2011-08-06 18:51:46 +02:00
|
|
|
someone tries to use a command that requires being identified or having a
|
2010-10-20 18:27:58 +02:00
|
|
|
password and neither credential is correct.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
# XXX: This should eventually check that there's one and only one %s here.
|
|
|
|
registerChannelValue(supybot.replies, 'noUser',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.NormalizedString(_("""I can't find %s in my user
|
2005-01-19 14:14:38 +01:00
|
|
|
database. If you didn't give a user name, then I might not know what your
|
2010-10-20 18:27:58 +02:00
|
|
|
user is, and you'll need to identify before this command might work."""),
|
|
|
|
_("""Determines what error message the bot replies with when someone tries
|
|
|
|
to accessing some information on a user the bot doesn't know about.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.replies, 'notRegistered',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.NormalizedString(_("""You must be registered to use this command.
|
2005-01-19 14:14:38 +01:00
|
|
|
If you are already registered, you must either identify (using the identify
|
|
|
|
command) or add a hostmask matching your current hostmask (using the
|
2010-10-20 18:27:58 +02:00
|
|
|
"hostmask add" command)."""), _("""Determines what error message the bot
|
2005-05-18 04:38:41 +02:00
|
|
|
replies with when someone tries to do something that requires them to be
|
2010-10-20 18:27:58 +02:00
|
|
|
registered but they're not currently recognized.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.replies, 'noCapability',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.NormalizedString(_("""You don't have the %s capability. If you
|
2005-01-19 14:14:38 +01:00
|
|
|
think that you should have this capability, be sure that you are identified
|
|
|
|
before trying again. The 'whoami' command can tell you if you're
|
2010-10-20 18:27:58 +02:00
|
|
|
identified."""), _("""Determines what error message is given when the bot
|
|
|
|
is telling someone they aren't cool enough to use the command they tried to
|
|
|
|
use.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.replies, 'genericNoCapability',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.NormalizedString(_("""You're missing some capability you need.
|
2005-01-19 14:14:38 +01:00
|
|
|
This could be because you actually possess the anti-capability for the
|
|
|
|
capability that's required of you, or because the channel provides that
|
|
|
|
anti-capability by default, or because the global capabilities include
|
|
|
|
that anti-capability. Or, it could be because the channel or
|
|
|
|
supybot.capabilities.default is set to False, meaning that no commands are
|
|
|
|
allowed unless explicitly in your capabilities. Either way, you can't do
|
2010-10-20 18:27:58 +02:00
|
|
|
what you want to do."""),
|
|
|
|
_("""Determines what generic error message is given when the bot is telling
|
2005-01-19 14:14:38 +01:00
|
|
|
someone that they aren't cool enough to use the command they tried to use,
|
|
|
|
and the author of the code calling errorNoCapability didn't provide an
|
2010-10-20 18:27:58 +02:00
|
|
|
explicit capability for whatever reason.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.replies, 'requiresPrivacy',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.NormalizedString(_("""That operation cannot be done in a
|
|
|
|
channel."""), _("""Determines what error messages the bot sends to people
|
|
|
|
who try to do things in a channel that really should be done in
|
|
|
|
private.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerChannelValue(supybot.replies, 'possibleBug',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.NormalizedString(_("""This may be a bug. If you think it is,
|
|
|
|
please file a bug report at
|
2011-08-06 18:51:46 +02:00
|
|
|
<https://github.com/ProgVal/Limnoria/issues>."""),
|
2010-10-20 18:27:58 +02:00
|
|
|
_("""Determines what message the bot sends when it thinks you've
|
|
|
|
encountered a bug that the developers don't know about.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
###
|
|
|
|
# End supybot.replies.
|
|
|
|
###
|
|
|
|
|
|
|
|
registerGlobalValue(supybot, 'snarfThrottle',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Float(10.0, _("""A floating point number of seconds to throttle
|
2005-01-19 14:14:38 +01:00
|
|
|
snarfed URLs, in order to prevent loops between two bots snarfing the same
|
2010-10-20 18:27:58 +02:00
|
|
|
URLs and having the snarfed URL in the output of the snarf message.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot, 'upkeepInterval',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.PositiveInteger(3600, _("""Determines the number of seconds
|
|
|
|
between running the upkeep function that flushes (commits) open databases,
|
|
|
|
collects garbage, and records some useful statistics at the debugging
|
|
|
|
level.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot, 'flush',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(True, _("""Determines whether the bot will periodically
|
2005-01-19 14:14:38 +01:00
|
|
|
flush data and configuration files to disk. Generally, the only time
|
|
|
|
you'll want to set this to False is when you want to modify those
|
|
|
|
configuration files by hand and don't want the bot to flush its current
|
|
|
|
version over your modifications. Do note that if you change this to False
|
|
|
|
inside the bot, your changes won't be flushed. To make this change
|
2010-10-20 18:27:58 +02:00
|
|
|
permanent, you must edit the registry yourself.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
# supybot.commands. For stuff relating to commands.
|
|
|
|
###
|
|
|
|
registerGroup(supybot, 'commands')
|
|
|
|
|
|
|
|
class ValidQuotes(registry.Value):
|
|
|
|
"""Value must consist solely of \", ', and ` characters."""
|
|
|
|
def setValue(self, v):
|
|
|
|
if [c for c in v if c not in '"`\'']:
|
|
|
|
self.error()
|
|
|
|
super(ValidQuotes, self).setValue(v)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return str(self.value)
|
|
|
|
|
|
|
|
registerChannelValue(supybot.commands, 'quotes',
|
2010-10-20 18:27:58 +02:00
|
|
|
ValidQuotes('"', _("""Determines what characters are valid for quoting
|
2005-01-19 14:14:38 +01:00
|
|
|
arguments to commands in order to prevent them from being tokenized.
|
2010-10-20 18:27:58 +02:00
|
|
|
""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
# This is a GlobalValue because bot owners should be able to say, "There will
|
|
|
|
# be no nesting at all on this bot." Individual channels can just set their
|
|
|
|
# brackets to the empty string.
|
|
|
|
registerGlobalValue(supybot.commands, 'nested',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(True, _("""Determines whether the bot will allow nested
|
|
|
|
commands, which rule. You definitely should keep this on.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.commands.nested, 'maximum',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.PositiveInteger(10, _("""Determines what the maximum number of
|
2005-01-19 14:14:38 +01:00
|
|
|
nested commands will be; users will receive an error if they attempt
|
2010-10-20 18:27:58 +02:00
|
|
|
commands more nested than this.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
class ValidBrackets(registry.OnlySomeStrings):
|
|
|
|
validStrings = ('', '[]', '<>', '{}', '()')
|
|
|
|
|
|
|
|
registerChannelValue(supybot.commands.nested, 'brackets',
|
2010-10-20 18:27:58 +02:00
|
|
|
ValidBrackets('[]', _("""Supybot allows you to specify what brackets are
|
|
|
|
used for your nested commands. Valid sets of brackets include [], <>, and
|
|
|
|
{} (). [] has strong historical motivation, as well as being the brackets
|
2005-01-19 14:14:38 +01:00
|
|
|
that don't require shift. <> or () might be slightly superior because they
|
|
|
|
cannot occur in a nick. If this string is empty, nested commands will
|
2010-10-20 18:27:58 +02:00
|
|
|
not be allowed in this channel.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerChannelValue(supybot.commands.nested, 'pipeSyntax',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Supybot allows nested commands. Enabling this
|
2005-01-19 14:14:38 +01:00
|
|
|
option will allow nested commands with a syntax similar to UNIX pipes, for
|
2010-10-20 18:27:58 +02:00
|
|
|
example: 'bot: foo | bar'.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGroup(supybot.commands, 'defaultPlugins',
|
2010-10-31 13:41:36 +01:00
|
|
|
orderAlphabetically=True, help=_("""Determines what commands have default
|
2005-01-27 07:59:08 +01:00
|
|
|
plugins set, and which plugins are set to be the default for each of those
|
2010-10-31 13:41:36 +01:00
|
|
|
commands."""))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.commands.defaultPlugins, 'importantPlugins',
|
|
|
|
registry.SpaceSeparatedSetOfStrings(
|
2005-02-09 08:07:11 +01:00
|
|
|
['Admin', 'Channel', 'Config', 'Misc', 'Owner', 'Plugin', 'User'],
|
2010-10-20 18:27:58 +02:00
|
|
|
_("""Determines what plugins automatically get precedence over all
|
|
|
|
other plugins when selecting a default plugin for a command. By
|
|
|
|
default, this includes the standard loaded plugins. You probably
|
|
|
|
shouldn't change this if you don't know what you're doing; if you do
|
|
|
|
know what you're doing, then also know that this set is
|
|
|
|
case-sensitive.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
# supybot.commands.disabled moved to callbacks for canonicalName.
|
|
|
|
|
|
|
|
###
|
|
|
|
# supybot.abuse. For stuff relating to abuse of the bot.
|
|
|
|
###
|
|
|
|
registerGroup(supybot, 'abuse')
|
|
|
|
registerGroup(supybot.abuse, 'flood')
|
|
|
|
registerGlobalValue(supybot.abuse.flood, 'command',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(True, _("""Determines whether the bot will defend itself
|
|
|
|
against command-flooding.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.abuse.flood.command, 'maximum',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.PositiveInteger(12, _("""Determines how many commands users are
|
2005-01-19 14:14:38 +01:00
|
|
|
allowed per minute. If a user sends more than this many commands in any
|
|
|
|
60 second period, he or she will be ignored for
|
2010-10-20 18:27:58 +02:00
|
|
|
supybot.abuse.flood.command.punishment seconds.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.abuse.flood.command, 'punishment',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.PositiveInteger(300, _("""Determines how many seconds the bot
|
|
|
|
will ignore users who flood it with commands.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot.abuse.flood.command, 'invalid',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(True, _("""Determines whether the bot will defend itself
|
|
|
|
against invalid command-flooding.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.abuse.flood.command.invalid, 'maximum',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.PositiveInteger(5, _("""Determines how many invalid commands users
|
2005-01-19 14:14:38 +01:00
|
|
|
are allowed per minute. If a user sends more than this many invalid
|
|
|
|
commands in any 60 second period, he or she will be ignored for
|
|
|
|
supybot.abuse.flood.command.invalid.punishment seconds. Typically, this
|
|
|
|
value is lower than supybot.abuse.flood.command.maximum, since it's far
|
|
|
|
less likely (and far more annoying) for users to flood with invalid
|
2010-10-20 18:27:58 +02:00
|
|
|
commands than for them to flood with valid commands.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.abuse.flood.command.invalid, 'punishment',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.PositiveInteger(600, _("""Determines how many seconds the bot
|
2005-01-19 14:14:38 +01:00
|
|
|
will ignore users who flood it with invalid commands. Typically, this
|
|
|
|
value is higher than supybot.abuse.flood.command.punishment, since it's far
|
2011-08-06 18:51:46 +02:00
|
|
|
less likely (and far more annoying) for users to flood with invalid
|
2010-10-20 18:27:58 +02:00
|
|
|
commands than for them to flood with valid commands.""")))
|
2009-06-09 17:40:05 +02:00
|
|
|
registerGlobalValue(supybot.abuse.flood.command.invalid, 'notify',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(True, _("""Determines whether the bot will notify people
|
|
|
|
that they're being ignored for invalid command flooding.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
# supybot.drivers. For stuff relating to Supybot's drivers (duh!)
|
|
|
|
###
|
|
|
|
registerGroup(supybot, 'drivers')
|
|
|
|
registerGlobalValue(supybot.drivers, 'poll',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.PositiveFloat(1.0, _("""Determines the default length of time a
|
|
|
|
driver should block waiting for input.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
class ValidDriverModule(registry.OnlySomeStrings):
|
|
|
|
validStrings = ('default', 'Socket', 'Twisted')
|
|
|
|
|
|
|
|
registerGlobalValue(supybot.drivers, 'module',
|
2010-10-20 18:27:58 +02:00
|
|
|
ValidDriverModule('default', _("""Determines what driver module the bot
|
|
|
|
will use. Socket, a simple driver based on timeout sockets, is used by
|
|
|
|
default because it's simple and stable. Twisted is very stable and simple,
|
|
|
|
and if you've got Twisted installed, is probably your best bet.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
2005-05-20 01:38:13 +02:00
|
|
|
registerGlobalValue(supybot.drivers, 'maxReconnectWait',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.PositiveFloat(300.0, _("""Determines the maximum time the bot will
|
2005-05-20 01:38:13 +02:00
|
|
|
wait before attempting to reconnect to an IRC server. The bot may, of
|
2010-10-20 18:27:58 +02:00
|
|
|
course, reconnect earlier if possible.""")))
|
2005-05-20 01:38:13 +02:00
|
|
|
|
2005-01-19 14:14:38 +01:00
|
|
|
###
|
|
|
|
# supybot.directories, for stuff relating to directories.
|
|
|
|
###
|
|
|
|
|
|
|
|
# XXX This shouldn't make directories willy-nilly. As it is now, if it's
|
|
|
|
# configured, it'll still make the default directories, I think.
|
|
|
|
class Directory(registry.String):
|
|
|
|
def __call__(self):
|
|
|
|
# ??? Should we perhaps always return an absolute path here?
|
|
|
|
v = super(Directory, self).__call__()
|
|
|
|
if not os.path.exists(v):
|
|
|
|
os.mkdir(v)
|
|
|
|
return v
|
|
|
|
|
|
|
|
def dirize(self, filename):
|
|
|
|
myself = self()
|
|
|
|
if os.path.isabs(filename):
|
|
|
|
filename = os.path.abspath(filename)
|
|
|
|
selfAbs = os.path.abspath(myself)
|
|
|
|
commonPrefix = os.path.commonprefix([selfAbs, filename])
|
|
|
|
filename = filename[len(commonPrefix):]
|
|
|
|
elif not os.path.isabs(myself):
|
|
|
|
if filename.startswith(myself):
|
|
|
|
filename = filename[len(myself):]
|
|
|
|
filename = filename.lstrip(os.path.sep) # Stupid os.path.join!
|
|
|
|
return os.path.join(myself, filename)
|
|
|
|
|
|
|
|
class DataFilename(registry.String):
|
|
|
|
def __call__(self):
|
|
|
|
v = super(DataFilename, self).__call__()
|
|
|
|
dataDir = supybot.directories.data()
|
|
|
|
if not v.startswith(dataDir):
|
|
|
|
v = os.path.basename(v)
|
|
|
|
v = os.path.join(dataDir, v)
|
|
|
|
self.setValue(v)
|
|
|
|
return v
|
|
|
|
|
|
|
|
class DataFilenameDirectory(DataFilename, Directory):
|
|
|
|
def __call__(self):
|
|
|
|
v = DataFilename.__call__(self)
|
|
|
|
v = Directory.__call__(self)
|
|
|
|
return v
|
|
|
|
|
|
|
|
registerGroup(supybot, 'directories')
|
|
|
|
registerGlobalValue(supybot.directories, 'conf',
|
2010-10-20 18:27:58 +02:00
|
|
|
Directory('conf', _("""Determines what directory configuration data is
|
|
|
|
put into.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.directories, 'data',
|
2010-10-20 18:27:58 +02:00
|
|
|
Directory('data', _("""Determines what directory data is put into.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.directories, 'backup',
|
2010-10-20 18:27:58 +02:00
|
|
|
Directory('backup', _("""Determines what directory backup data is put
|
2012-04-17 11:49:03 +02:00
|
|
|
into. Set it to /dev/null to disable backup (it is a special value,
|
2012-03-15 20:22:46 +01:00
|
|
|
so it also works on Windows and systems without /dev/null).""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.directories.data, 'tmp',
|
2010-10-20 18:27:58 +02:00
|
|
|
DataFilenameDirectory('tmp', _("""Determines what directory temporary files
|
|
|
|
are put into.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
2005-01-27 07:59:08 +01:00
|
|
|
utils.file.AtomicFile.default.tmpDir = supybot.directories.data.tmp
|
|
|
|
utils.file.AtomicFile.default.backupDir = supybot.directories.backup
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot.directories, 'plugins',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.CommaSeparatedListOfStrings([], _("""Determines what directories
|
|
|
|
the bot will look for plugins in. Accepts a comma-separated list of
|
|
|
|
strings.
|
2009-03-12 19:50:46 +01:00
|
|
|
This means that to add another directory, you can nest the former value and
|
|
|
|
add a new one. E.g. you can say: bot: 'config supybot.directories.plugins
|
2010-10-20 18:27:58 +02:00
|
|
|
[config supybot.directories.plugins], newPluginDirectory'.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot, 'plugins',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.SpaceSeparatedSetOfStrings([], _("""Determines what plugins will
|
|
|
|
be loaded."""), orderAlphabetically=True))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.plugins, 'alwaysLoadImportant',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(True, _("""Determines whether the bot will always load
|
2005-01-19 14:14:38 +01:00
|
|
|
important plugins (Admin, Channel, Config, Misc, Owner, and User)
|
|
|
|
regardless of what their configured state is. Generally, if these plugins
|
|
|
|
are configured not to load, you didn't do it on purpose, and you still
|
|
|
|
want them to load. Users who don't want to load these plugins are smart
|
2010-10-20 18:27:58 +02:00
|
|
|
enough to change the value of this variable appropriately :)""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
###
|
|
|
|
# supybot.databases. For stuff relating to Supybot's databases (duh!)
|
|
|
|
###
|
|
|
|
class Databases(registry.SpaceSeparatedListOfStrings):
|
|
|
|
def __call__(self):
|
|
|
|
v = super(Databases, self).__call__()
|
|
|
|
if not v:
|
|
|
|
v = ['anydbm', 'cdb', 'flat', 'pickle']
|
|
|
|
if 'sqlite' in sys.modules:
|
|
|
|
v.insert(0, 'sqlite')
|
2010-04-16 22:06:00 +02:00
|
|
|
if 'sqlite3' in sys.modules:
|
|
|
|
v.insert(0, 'sqlite3')
|
|
|
|
if 'pysqlite2' in sys.modules: # for python 2.4
|
|
|
|
v.insert(0, 'sqlite3')
|
2005-01-19 14:14:38 +01:00
|
|
|
return v
|
|
|
|
|
|
|
|
def serialize(self):
|
|
|
|
return ' '.join(self.value)
|
|
|
|
|
|
|
|
registerGlobalValue(supybot, 'databases',
|
2010-10-20 18:27:58 +02:00
|
|
|
Databases([], _("""Determines what databases are available for use. If this
|
2005-01-19 14:14:38 +01:00
|
|
|
value is not configured (that is, if its value is empty) then sane defaults
|
2010-10-20 18:27:58 +02:00
|
|
|
will be provided.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGroup(supybot.databases, 'users')
|
|
|
|
registerGlobalValue(supybot.databases.users, 'filename',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.String('users.conf', _("""Determines what filename will be used
|
|
|
|
for the users database. This file will go into the directory specified by
|
|
|
|
the supybot.directories.conf variable.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.databases.users, 'timeoutIdentification',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Integer(0, _("""Determines how long it takes identification to
|
|
|
|
time out. If the value is less than or equal to zero, identification never
|
|
|
|
times out.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.databases.users, 'allowUnregistration',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot will allow users to
|
2005-01-19 14:14:38 +01:00
|
|
|
unregister their users. This can wreak havoc with already-existing
|
|
|
|
databases, so by default we don't allow it. Enable this at your own risk.
|
|
|
|
(Do also note that this does not prevent the owner of the bot from using
|
|
|
|
the unregister command.)
|
2010-10-20 18:27:58 +02:00
|
|
|
""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGroup(supybot.databases, 'ignores')
|
|
|
|
registerGlobalValue(supybot.databases.ignores, 'filename',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.String('ignores.conf', _("""Determines what filename will be used
|
2005-01-19 14:14:38 +01:00
|
|
|
for the ignores database. This file will go into the directory specified
|
2010-10-20 18:27:58 +02:00
|
|
|
by the supybot.directories.conf variable.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGroup(supybot.databases, 'channels')
|
|
|
|
registerGlobalValue(supybot.databases.channels, 'filename',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.String('channels.conf', _("""Determines what filename will be used
|
2005-01-19 14:14:38 +01:00
|
|
|
for the channels database. This file will go into the directory specified
|
2010-10-20 18:27:58 +02:00
|
|
|
by the supybot.directories.conf variable.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
# TODO This will need to do more in the future (such as making sure link.allow
|
|
|
|
# will let the link occur), but for now let's just leave it as this.
|
|
|
|
class ChannelSpecific(registry.Boolean):
|
|
|
|
def getChannelLink(self, channel):
|
|
|
|
channelSpecific = supybot.databases.plugins.channelSpecific
|
|
|
|
channels = [channel]
|
|
|
|
def hasLinkChannel(channel):
|
|
|
|
if not get(channelSpecific, channel):
|
|
|
|
lchannel = get(channelSpecific.link, channel)
|
|
|
|
if not get(channelSpecific.link.allow, lchannel):
|
|
|
|
return False
|
|
|
|
return channel != lchannel
|
|
|
|
return False
|
|
|
|
lchannel = channel
|
|
|
|
while hasLinkChannel(lchannel):
|
|
|
|
lchannel = get(channelSpecific.link, lchannel)
|
|
|
|
if lchannel not in channels:
|
|
|
|
channels.append(lchannel)
|
|
|
|
else:
|
|
|
|
# Found a cyclic link. We'll just use the current channel
|
|
|
|
lchannel = channel
|
|
|
|
break
|
|
|
|
return lchannel
|
|
|
|
|
|
|
|
registerGroup(supybot.databases, 'plugins')
|
|
|
|
registerChannelValue(supybot.databases.plugins, 'channelSpecific',
|
2010-10-20 18:27:58 +02:00
|
|
|
ChannelSpecific(True, _("""Determines whether database-based plugins that
|
2005-01-19 14:14:38 +01:00
|
|
|
can be channel-specific will be so. This can be overridden by individual
|
|
|
|
channels. Do note that the bot needs to be restarted immediately after
|
|
|
|
changing this variable or your db plugins may not work for your channel;
|
|
|
|
also note that you may wish to set
|
|
|
|
supybot.databases.plugins.channelSpecific.link appropriately if you wish
|
2010-10-20 18:27:58 +02:00
|
|
|
to share a certain channel's databases globally.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerChannelValue(supybot.databases.plugins.channelSpecific, 'link',
|
2010-10-20 18:27:58 +02:00
|
|
|
ValidChannel('#', _("""Determines what channel global
|
|
|
|
(non-channel-specific) databases will be considered a part of. This is
|
|
|
|
helpful if you've been running channel-specific for awhile and want to turn
|
|
|
|
the databases for your primary channel into global databases. If
|
2005-01-19 14:14:38 +01:00
|
|
|
supybot.databases.plugins.channelSpecific.link.allow prevents linking, the
|
|
|
|
current channel will be used. Do note that the bot needs to be restarted
|
|
|
|
immediately after changing this variable or your db plugins may not work
|
2010-10-20 18:27:58 +02:00
|
|
|
for your channel.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerChannelValue(supybot.databases.plugins.channelSpecific.link, 'allow',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(True, _("""Determines whether another channel's global
|
2005-01-19 14:14:38 +01:00
|
|
|
(non-channel-specific) databases will be allowed to link to this channel's
|
|
|
|
databases. Do note that the bot needs to be restarted immediately after
|
|
|
|
changing this variable or your db plugins may not work for your channel.
|
2010-10-20 18:27:58 +02:00
|
|
|
""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
class CDB(registry.Boolean):
|
|
|
|
def connect(self, filename):
|
2009-01-19 22:12:23 +01:00
|
|
|
import supybot.cdb as cdb
|
2005-01-19 14:14:38 +01:00
|
|
|
basename = os.path.basename(filename)
|
|
|
|
journalName = supybot.directories.data.tmp.dirize(basename+'.journal')
|
2012-08-05 15:47:30 +02:00
|
|
|
return cdb.open_db(filename, 'c',
|
2005-01-19 14:14:38 +01:00
|
|
|
journalName=journalName,
|
|
|
|
maxmods=self.maximumModifications())
|
|
|
|
|
|
|
|
registerGroup(supybot.databases, 'types')
|
2010-10-20 18:27:58 +02:00
|
|
|
registerGlobalValue(supybot.databases.types, 'cdb', CDB(True, _("""Determines
|
|
|
|
whether CDB databases will be allowed as a database implementation.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.databases.types.cdb, 'maximumModifications',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Probability(0.5, _("""Determines how often CDB databases will have
|
2009-09-12 00:09:38 +02:00
|
|
|
their modifications flushed to disk. When the number of modified records
|
|
|
|
is greater than this fraction of the total number of records, the database
|
2010-10-20 18:27:58 +02:00
|
|
|
will be entirely flushed to disk.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
# XXX Configuration variables for dbi, sqlite, flat, mysql, etc.
|
|
|
|
|
|
|
|
###
|
|
|
|
# Protocol information.
|
|
|
|
###
|
|
|
|
originalIsNick = ircutils.isNick
|
|
|
|
def isNick(s, strictRfc=None, **kw):
|
|
|
|
if strictRfc is None:
|
|
|
|
strictRfc = supybot.protocols.irc.strictRfc()
|
|
|
|
return originalIsNick(s, strictRfc=strictRfc, **kw)
|
|
|
|
ircutils.isNick = isNick
|
|
|
|
|
|
|
|
###
|
|
|
|
# supybot.protocols
|
|
|
|
###
|
|
|
|
registerGroup(supybot, 'protocols')
|
|
|
|
|
|
|
|
###
|
|
|
|
# supybot.protocols.irc
|
|
|
|
###
|
|
|
|
registerGroup(supybot.protocols, 'irc')
|
2009-01-19 22:12:36 +01:00
|
|
|
|
|
|
|
class Banmask(registry.SpaceSeparatedSetOfStrings):
|
|
|
|
validStrings = ('exact', 'nick', 'user', 'host')
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
assert self.validStrings, 'There must be some valid strings. ' \
|
|
|
|
'This is a bug.'
|
|
|
|
self.__parent = super(Banmask, self)
|
|
|
|
self.__parent.__init__(*args, **kwargs)
|
|
|
|
self.__doc__ = format('Valid values include %L.',
|
2012-08-05 15:47:30 +02:00
|
|
|
list(map(repr, self.validStrings)))
|
2009-01-19 22:12:36 +01:00
|
|
|
|
|
|
|
def help(self):
|
|
|
|
strings = [s for s in self.validStrings if s]
|
|
|
|
return format('%s Valid strings: %L.', self._help, strings)
|
|
|
|
|
|
|
|
def normalize(self, s):
|
|
|
|
lowered = s.lower()
|
|
|
|
L = list(map(str.lower, self.validStrings))
|
|
|
|
try:
|
|
|
|
i = L.index(lowered)
|
|
|
|
except ValueError:
|
|
|
|
return s # This is handled in setValue.
|
|
|
|
return self.validStrings[i]
|
|
|
|
|
|
|
|
def setValue(self, v):
|
2012-08-05 15:47:30 +02:00
|
|
|
v = list(map(self.normalize, v))
|
2009-01-19 22:12:36 +01:00
|
|
|
for s in v:
|
|
|
|
if s not in self.validStrings:
|
|
|
|
self.error()
|
|
|
|
self.__parent.setValue(self.List(v))
|
|
|
|
|
|
|
|
def makeBanmask(self, hostmask, options=None):
|
|
|
|
"""Create a banmask from the given hostmask. If a style of banmask
|
|
|
|
isn't specified via options, the value of
|
|
|
|
conf.supybot.protocols.irc.banmask is used.
|
|
|
|
|
|
|
|
options - A list specifying which parts of the hostmask should
|
|
|
|
explicitly be matched: nick, user, host. If 'exact' is given, then
|
|
|
|
only the exact hostmask will be used."""
|
2009-11-01 16:26:08 +01:00
|
|
|
channel = dynamic.channel
|
|
|
|
assert channel is None or ircutils.isChannel(channel)
|
2009-01-19 22:12:36 +01:00
|
|
|
(nick, user, host) = ircutils.splitHostmask(hostmask)
|
|
|
|
bnick = '*'
|
|
|
|
buser = '*'
|
|
|
|
bhost = '*'
|
|
|
|
if not options:
|
2009-11-01 16:26:08 +01:00
|
|
|
options = get(supybot.protocols.irc.banmask, channel)
|
2009-01-19 22:12:36 +01:00
|
|
|
for option in options:
|
|
|
|
if option == 'nick':
|
|
|
|
bnick = nick
|
|
|
|
elif option == 'user':
|
|
|
|
buser = user
|
|
|
|
elif option == 'host':
|
|
|
|
bhost = host
|
|
|
|
elif option == 'exact':
|
|
|
|
return hostmask
|
2011-12-27 11:55:50 +01:00
|
|
|
if (bnick, buser, bhost) == ('*', '*', '*') and \
|
|
|
|
ircutils.isUserHostmask(hostmask):
|
|
|
|
return hostmask
|
2009-01-19 22:12:36 +01:00
|
|
|
return ircutils.joinHostmask(bnick, buser, bhost)
|
|
|
|
|
|
|
|
registerChannelValue(supybot.protocols.irc, 'banmask',
|
2010-10-20 18:27:58 +02:00
|
|
|
Banmask(['user', 'host'], _("""Determines what will be used as the
|
|
|
|
default banmask style.""")))
|
2009-01-19 22:12:36 +01:00
|
|
|
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.protocols.irc, 'strictRfc',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(True, _("""Determines whether the bot will strictly follow
|
2005-01-19 14:14:38 +01:00
|
|
|
the RFC; currently this only affects what strings are considered to be
|
|
|
|
nicks. If you're using a server or a network that requires you to message
|
|
|
|
a nick such as services@this.network.server then you you should set this to
|
2010-10-20 18:27:58 +02:00
|
|
|
False.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot.protocols.irc, 'umodes',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.String('', _("""Determines what user modes the bot will request
|
|
|
|
from the server when it first connects. Many people might choose +i; some
|
2005-01-19 14:14:38 +01:00
|
|
|
networks allow +x, which indicates to the auth services on those networks
|
2010-10-20 18:27:58 +02:00
|
|
|
that you should be given a fake host.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot.protocols.irc, 'vhost',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.String('', _("""Determines what vhost the bot will bind to before
|
|
|
|
connecting to the IRC server.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot.protocols.irc, 'maxHistoryLength',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Integer(1000, _("""Determines how many old messages the bot will
|
2005-01-19 14:14:38 +01:00
|
|
|
keep around in its history. Changing this variable will not take effect
|
2010-10-20 18:27:58 +02:00
|
|
|
until the bot is restarted.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot.protocols.irc, 'throttleTime',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Float(1.0, _("""A floating point number of seconds to throttle
|
2005-01-19 14:14:38 +01:00
|
|
|
queued messages -- that is, messages will not be sent faster than once per
|
2010-10-20 18:27:58 +02:00
|
|
|
throttleTime seconds.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot.protocols.irc, 'ping',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(True, _("""Determines whether the bot will send PINGs to
|
|
|
|
the server it's connected to in order to keep the connection alive and
|
|
|
|
discover earlier when it breaks. Really, this option only exists for
|
|
|
|
debugging purposes: you always should make it True unless you're testing
|
|
|
|
some strange server issues.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot.protocols.irc.ping, 'interval',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Integer(120, _("""Determines the number of seconds between sending
|
|
|
|
pings to the server, if pings are being sent to the server.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
2005-04-14 02:56:26 +02:00
|
|
|
registerGroup(supybot.protocols.irc, 'queuing')
|
|
|
|
registerGlobalValue(supybot.protocols.irc.queuing, 'duplicates',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot will refuse
|
2011-08-06 18:51:46 +02:00
|
|
|
duplicated messages to be queued for delivery to the server. This is a
|
2010-10-20 18:27:58 +02:00
|
|
|
safety mechanism put in place to prevent plugins from sending the same
|
|
|
|
message multiple times; most of the time it doesn't matter, unless you're
|
|
|
|
doing certain kinds of plugin hacking.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
2005-04-14 03:35:35 +02:00
|
|
|
registerGroup(supybot.protocols.irc.queuing, 'rateLimit')
|
|
|
|
registerGlobalValue(supybot.protocols.irc.queuing.rateLimit, 'join',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Float(0, _("""Determines how many seconds must elapse between
|
|
|
|
JOINs sent to the server.""")))
|
2005-04-14 03:35:35 +02:00
|
|
|
|
2005-01-19 14:14:38 +01:00
|
|
|
###
|
|
|
|
# supybot.protocols.http
|
|
|
|
###
|
|
|
|
registerGroup(supybot.protocols, 'http')
|
|
|
|
registerGlobalValue(supybot.protocols.http, 'peekSize',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.PositiveInteger(4096, _("""Determines how many bytes the bot will
|
2005-01-19 14:14:38 +01:00
|
|
|
'peek' at when looking through a URL for a doctype or title or something
|
|
|
|
similar. It'll give up after it reads this many bytes, even if it hasn't
|
2010-10-20 18:27:58 +02:00
|
|
|
found what it was looking for.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot.protocols.http, 'proxy',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.String('', _("""Determines what proxy all HTTP requests should go
|
|
|
|
through. The value should be of the form 'host:port'.""")))
|
2005-01-27 07:59:08 +01:00
|
|
|
utils.web.proxy = supybot.protocols.http.proxy
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
###
|
2011-06-24 14:31:29 +02:00
|
|
|
# HTTP server
|
2005-01-19 14:14:38 +01:00
|
|
|
###
|
2011-06-24 14:31:29 +02:00
|
|
|
registerGroup(supybot, 'servers')
|
|
|
|
registerGroup(supybot.servers, 'http')
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
class IP(registry.String):
|
|
|
|
"""Value must be a valid IP."""
|
|
|
|
def setValue(self, v):
|
2011-06-07 03:44:15 +02:00
|
|
|
if v and not utils.net.isIP(v):
|
2005-01-19 14:14:38 +01:00
|
|
|
self.error()
|
|
|
|
else:
|
|
|
|
registry.String.setValue(self, v)
|
|
|
|
|
2012-09-30 18:54:30 +02:00
|
|
|
registerGlobalValue(supybot.servers.http, 'hosts4',
|
|
|
|
IP('0.0.0.0', _("""Space-separated list of IPv4 hosts the HTTP server
|
|
|
|
will bind.""")))
|
|
|
|
registerGlobalValue(supybot.servers.http, 'hosts6',
|
|
|
|
IP('', _("""Space-separated list of IPv6 hosts the HTTP server will
|
|
|
|
bind.""")))
|
2011-06-24 14:31:29 +02:00
|
|
|
registerGlobalValue(supybot.servers.http, 'port',
|
|
|
|
registry.Integer(8080, _("""Determines what port the HTTP server will
|
|
|
|
bind.""")))
|
|
|
|
registerGlobalValue(supybot.servers.http, 'keepAlive',
|
2012-04-23 21:55:21 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the server will stay
|
2011-10-29 12:13:09 +02:00
|
|
|
alive if no plugin is using it. This also means that the server will
|
|
|
|
start even if it is not used.""")))
|
|
|
|
registerGlobalValue(supybot.servers.http, 'robots',
|
|
|
|
registry.String('', _("""Determines the content of the robots.txt file,
|
2011-10-29 12:23:19 +02:00
|
|
|
served on the server to search engine.""")))
|
2012-09-03 10:35:54 +02:00
|
|
|
registerGlobalValue(supybot.servers.http, 'favicon',
|
|
|
|
registry.String('', _("""Determines the path of the file served as
|
|
|
|
favicon to browsers.""")))
|
2011-06-24 14:31:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
# Especially boring stuff.
|
|
|
|
###
|
|
|
|
registerGlobalValue(supybot, 'defaultIgnore',
|
|
|
|
registry.Boolean(False, _("""Determines whether the bot will ignore
|
|
|
|
unregistered users by default. Of course, that'll make it particularly
|
|
|
|
hard for those users to register or identify with the bot, but that's your
|
|
|
|
problem to solve.""")))
|
|
|
|
|
|
|
|
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot, 'externalIP',
|
2010-10-20 18:27:58 +02:00
|
|
|
IP('', _("""A string that is the external IP of the bot. If this is the
|
|
|
|
empty string, the bot will attempt to find out its IP dynamically (though
|
|
|
|
sometimes that doesn't work, hence this variable).""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
class SocketTimeout(registry.PositiveInteger):
|
|
|
|
"""Value must be an integer greater than supybot.drivers.poll and must be
|
|
|
|
greater than or equal to 1."""
|
|
|
|
def setValue(self, v):
|
|
|
|
if v < supybot.drivers.poll() or v < 1:
|
|
|
|
self.error()
|
|
|
|
registry.PositiveInteger.setValue(self, v)
|
|
|
|
socket.setdefaulttimeout(self.value)
|
|
|
|
|
|
|
|
registerGlobalValue(supybot, 'defaultSocketTimeout',
|
2010-10-20 18:27:58 +02:00
|
|
|
SocketTimeout(10, _("""Determines what the default timeout for socket
|
|
|
|
objects will be. This means that *all* sockets will timeout when this many
|
|
|
|
seconds has gone by (unless otherwise modified by the author of the code
|
|
|
|
that uses the sockets).""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
registerGlobalValue(supybot, 'pidFile',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.String('', _("""Determines what file the bot should write its PID
|
2005-01-19 14:14:38 +01:00
|
|
|
(Process ID) to, so you can kill it more easily. If it's left unset (as is
|
|
|
|
the default) then no PID file will be written. A restart is required for
|
2010-10-20 18:27:58 +02:00
|
|
|
changes to this variable to take effect.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
|
|
|
|
###
|
|
|
|
# Debugging options.
|
|
|
|
###
|
|
|
|
registerGroup(supybot, 'debug')
|
|
|
|
registerGlobalValue(supybot.debug, 'threadAllCommands',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot will automatically
|
|
|
|
thread all commands.""")))
|
2005-01-19 14:14:38 +01:00
|
|
|
registerGlobalValue(supybot.debug, 'flushVeryOften',
|
2010-10-20 18:27:58 +02:00
|
|
|
registry.Boolean(False, _("""Determines whether the bot will automatically
|
2005-01-19 14:14:38 +01:00
|
|
|
flush all flushers *very* often. Useful for debugging when you don't know
|
2010-10-20 18:27:58 +02:00
|
|
|
what's breaking or when, but think that it might be logged.""")))
|
2005-02-18 09:30:35 +01:00
|
|
|
|
2005-01-19 14:14:38 +01:00
|
|
|
|
2006-02-11 16:52:51 +01:00
|
|
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|