Updated a ton of configuration variables.

This commit is contained in:
Jeremy Fincher 2004-04-30 02:13:42 +00:00
parent 65ad15dd45
commit dc1bc4ba55
9 changed files with 130 additions and 88 deletions

View File

@ -1,3 +1,10 @@
* Changed and moved several configuration variables.
supybot.{throttleTime,maxHistoryLength,pingServer,pingInterval}
all moved to supybot.protocols.irc; supybot.httpPeekSize moved to
supybot.protocols.http; supybot.threadAllCommands moved to
supybot.debug.threadAllCommands, and probably a few others I
forgot to mention.
* Added Http.zipinfo, which returns a veritable plethora of * Added Http.zipinfo, which returns a veritable plethora of
information about the supplied zip code. information about the supplied zip code.

View File

@ -30,7 +30,7 @@
### ###
""" """
Handles "factoids," little tidbits of information held in a database and Handles 'factoids,' little tidbits of information held in a database and
available on demand via several commands. available on demand via several commands.
""" """

View File

@ -226,7 +226,8 @@ class User(callbacks.Privmsg):
"""<name> <hostmask> [<password>] """<name> <hostmask> [<password>]
Removes the hostmask <hostmask> from the record of the user specified Removes the hostmask <hostmask> from the record of the user specified
by <name>. The <password> may only be required if the user is not by <name>. If the hostmask is 'all' then all hostmasks will be
removed. The <password> may only be required if the user is not
recognized by his hostmask. If you include the <password> parameter, recognized by his hostmask. If you include the <password> parameter,
this message must be sent to the bot privately (not on a channel). this message must be sent to the bot privately (not on a channel).
""" """
@ -240,12 +241,17 @@ class User(callbacks.Privmsg):
return return
if user.checkHostmask(msg.prefix) or user.checkPassword(password): if user.checkHostmask(msg.prefix) or user.checkPassword(password):
try: try:
user.removeHostmask(hostmask) s = ''
if hostmask == 'all':
user.hostmasks[:] = []
s = 'All hostmasks removed.'
else:
user.removeHostmask(hostmask)
except ValueError: except ValueError:
irc.error('There was no such hostmask.') irc.error('There was no such hostmask.')
return return
ircdb.users.setUser(id, user) ircdb.users.setUser(id, user)
irc.replySuccess() irc.replySuccess(s)
else: else:
irc.error(conf.supybot.replies.incorrectAuthentication()) irc.error(conf.supybot.replies.incorrectAuthentication())
return return

View File

@ -542,7 +542,7 @@ class IrcObjectProxy(RichReplyMethods):
return return
command = getattr(cb, name) command = getattr(cb, name)
Privmsg.handled = True Privmsg.handled = True
if cb.threaded or conf.supybot.threadAllCommands(): if cb.threaded or conf.supybot.debug.threadAllCommands():
t = CommandThread(target=self._callCommand, t = CommandThread(target=self._callCommand,
args=(name, command, cb)) args=(name, command, cb))
t.start() t.start()

View File

@ -175,7 +175,6 @@ whether the bot will ignore unregistered users by default. Of course, that'll
make it particularly hard for those users to register with the bot, but that's make it particularly hard for those users to register with the bot, but that's
your problem to solve.""")) your problem to solve."""))
supybot.register('humanTimestampFormat', registry.String('%I:%M %p, %B %d, %Y', supybot.register('humanTimestampFormat', registry.String('%I:%M %p, %B %d, %Y',
"""Determines how timestamps printed for human reading should be formatted. """Determines how timestamps printed for human reading should be formatted.
Refer to the Python documentation for the time module to see valid formatting Refer to the Python documentation for the time module to see valid formatting
@ -272,8 +271,6 @@ don't address it (either via its nick or a prefix character). If you set this
to True, you almost certainly want to set supybot.reply.whenNotCommand to to True, you almost certainly want to set supybot.reply.whenNotCommand to
False.""")) False."""))
# XXX: Removed requireRegistration: it wasn't being used.
supybot.reply.register('requireChannelCommandsToBeSentInChannel', supybot.reply.register('requireChannelCommandsToBeSentInChannel',
registry.Boolean(False, """Determines whether the bot will allow you to send registry.Boolean(False, """Determines whether the bot will allow you to send
channel-related commands outside of that channel. Sometimes people find it channel-related commands outside of that channel. Sometimes people find it
@ -349,7 +346,7 @@ registerChannelValue(supybot.replies, 'genericNoCapability',
that anti-capability. Or, it could be because the channel or the global that anti-capability. Or, it could be because the channel or the global
defaultAllow is set to False, meaning that no commands are allowed unless defaultAllow is set to False, meaning that no commands are allowed unless
explicitly in your capabilities. Either way, you can't do what you want explicitly in your capabilities. Either way, you can't do what you want
to do.""", """Dertermines what generic error message is given when the bot to do.""", """Determines what generic error message is given when the bot
is telling someone that they aren't cool enough to use the command they is telling 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 tried to use, and the author of the code calling errorNoCapability didn't
provide an explicit capability for whatever reason.""")) provide an explicit capability for whatever reason."""))
@ -369,40 +366,17 @@ registerChannelValue(supybot.replies, 'possibleBug',
# End supybot.replies. # End supybot.replies.
### ###
supybot.register('maxHistoryLength', registry.Integer(1000, """Determines
how many old messages the bot will keep around in its history. Changing this
variable will not take effect until the bot is restarted."""))
supybot.register('nickmods', registry.CommaSeparatedListOfStrings( supybot.register('nickmods', registry.CommaSeparatedListOfStrings(
'__%s__,%s^,%s`,%s_,%s__,_%s,__%s,[%s]'.split(','), '__%s__,%s^,%s`,%s_,%s__,_%s,__%s,[%s]'.split(','),
"""A list of modifications to be made to a nick when the nick the bot tries """A list of modifications to be made to a nick when the nick the bot tries
to get from the server is in use. There should be one %s in each string; to get from the server is in use. There should be one %s in each string;
this will get replaced with the original nick.""")) this will get replaced with the original nick."""))
supybot.register('throttleTime', registry.Float(1.0, """A floating point
number of seconds to throttle queued messages -- that is, messages will not
be sent faster than once per throttleTime seconds."""))
supybot.register('snarfThrottle', registry.Float(10.0, """A floating point supybot.register('snarfThrottle', registry.Float(10.0, """A floating point
number of seconds to throttle snarfed URLs, in order to prevent loops between number of seconds to throttle snarfed URLs, in order to prevent loops between
two bots snarfing the same URLs and having the snarfed URL in the output of two bots snarfing the same URLs and having the snarfed URL in the output of
the snarf message.""")) the snarf message."""))
supybot.register('threadAllCommands', registry.Boolean(False, """Determines
whether the bot will automatically thread all commands. At this point this
option exists almost exclusively for debugging purposes; it can do very little
except to take up more CPU."""))
supybot.register('pingServer', 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."""))
supybot.register('pingInterval', registry.Integer(120, """Determines the
number of seconds between sending pings to the server, if pings are being sent
to the server."""))
supybot.register('upkeepInterval', registry.PositiveInteger(3600, """Determines supybot.register('upkeepInterval', registry.PositiveInteger(3600, """Determines
the number of seconds between running the upkeep function that flushes the number of seconds between running the upkeep function that flushes
(commits) open databases, collects garbage, and records some useful statistics (commits) open databases, collects garbage, and records some useful statistics
@ -416,11 +390,6 @@ 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 permanent, you must bot, your changes won't be flushed. To make this change permanent, you must
edit the registry yourself.""")) edit the registry yourself."""))
supybot.register('httpPeekSize', registry.PositiveInteger(4096, """Determines
how many bytes the bot will '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."""))
class SocketTimeout(registry.PositiveInteger): class SocketTimeout(registry.PositiveInteger):
def setValue(self, v): def setValue(self, v):
registry.PositiveInteger.setValue(self, v) registry.PositiveInteger.setValue(self, v)
@ -439,65 +408,70 @@ required for changes to this variable to take effect."""))
### ###
# supybot.drivers. For stuff relating to Supybot's drivers (duh!) # supybot.drivers. For stuff relating to Supybot's drivers (duh!)
### ###
supybot.register('drivers') registerGroup(supybot, 'drivers')
supybot.drivers.register('poll', registry.Float(1.0, """Determines the default registerGlobalValue(supybot.drivers, 'poll',
length of time a driver should block waiting for input.""")) registry.Float(1.0, """Determines the default length of time a driver should
block waiting for input."""))
class ValidDriverModule(registry.OnlySomeStrings): class ValidDriverModule(registry.OnlySomeStrings):
validStrings = ('socketDrivers', 'twistedDrivers', 'asyncoreDrivers') validStrings = ('default', 'socketDrivers',
'twistedDrivers', 'asyncoreDrivers')
supybot.drivers.register('module', ValidDriverModule('socketDrivers', """ registerGlobalValue(supybot.drivers, 'module',
Determines what driver module the bot will use. socketDrivers, a simple ValidDriverModule('default', """Determines what driver module the bot will
driver based on timeout sockets, is used by default because it's simple and use. socketDrivers, a simple driver based on timeout sockets, is used by
stable. asyncoreDrivers is a bit older (and less well-maintained) but allows default because it's simple and stable. asyncoreDrivers is a bit older (and
you to integrate with asyncore-based applications. twistedDrivers is very less well-maintained) but allows you to integrate with asyncore-based
stable and simple, and if you've got Twisted installed, is probably your best applications. twistedDrivers is very stable and simple, and if you've got
bet.""")) Twisted installed, is probably your best bet."""))
supybot.register('directories') ###
supybot.directories.register('conf', registry.String('conf', """ # supybot.directories, for stuff relating to directories.
Determines what directory configuration data is put into.""")) ###
supybot.directories.register('data', registry.String('data', """ registerGroup(supybot, 'directories')
Determines what directory data is put into.""")) registerGlobalValue(supybot.directories, 'conf',
supybot.directories.register('plugins', registry.String('conf', """Determines what directory configuration data is
registry.CommaSeparatedListOfStrings([_srcDir,_pluginsDir], put into."""))
"""Determines what directories the bot will look for plugins in. Accepts a registerGlobalValue(supybot.directories, 'data',
comma-separated list of strings. This means that to add another directory, registry.String('data', """Determines what directory data is put into."""))
you can nest the former value and add a new one. E.g. you can say: bot: registerGlobalValue(supybot.directories, 'plugins',
'config supybot.directories.plugins [config supybot.directories.plugins], registry.CommaSeparatedListOfStrings([_srcDir,_pluginsDir], """Determines
newPluginDirectory'.""")) what directories the bot will look for plugins in. Accepts a
comma-separated list of strings. 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 [config supybot.directories.plugins],
newPluginDirectory'."""))
supybot.register('plugins') # This will be used by plugins, but not here.
### ###
# supybot.databases. For stuff relating to Supybot's databases (duh!) # supybot.databases. For stuff relating to Supybot's databases (duh!)
### ###
supybot.register('databases') registerGroup(supybot, 'databases')
supybot.databases.register('users') registerGroup(supybot.databases, 'users')
supybot.databases.users.register('filename', registry.String('users.conf', """ registerGlobalValue(supybot.databases.users, 'filename',
Determines what filename will be used for the users database. This file will registry.String('users.conf', """Determines what filename will be used for
go into the directory specified by the supybot.directories.conf the users database. This file will go into the directory specified by the
variable.""")) supybot.directories.conf variable."""))
supybot.databases.users.register('timeoutIdentification', registerGlobalValue(supybot.databases.users, 'timeoutIdentification',
registry.Integer(0, """Determines how long it takes identification to time registry.Integer(0, """Determines how long it takes identification to time
out. If the value is less than or equal to zero, identification never out. If the value is less than or equal to zero, identification never times
times out.""")) out."""))
supybot.databases.users.register('hash', registry.Boolean(False, """ registerGlobalValue(supybot.databases.users, 'hash',
Determines whether the passwords in the user database will be hashed by registry.Boolean(False, """Determines whether the passwords in the user
default.""")) database will be hashed by default."""))
supybot.databases.register('ignores') registerGroup(supybot.databases, 'ignores')
supybot.databases.ignores.register('filename', registry.String('ignores.conf', registerGlobalValue(supybot.databases.ignores, 'filename',
"""Determines what filename will be used for the ignores database. This file registry.String('ignores.conf', """Determines what filename will be used for
will go into the directory specified by the supybot.directories.conf the ignores database. This file will go into the directory specified by the
variable.""")) supybot.directories.conf variable."""))
supybot.databases.register('channels') registerGroup(supybot.databases, 'channels')
supybot.databases.channels.register('filename',registry.String('channels.conf', registerGlobalValue(supybot.databases.channels, 'filename',
"""Determines what filename will be used for the channels database. This file registry.String('channels.conf', """Determines what filename will be used
will go into the directory specified by the supybot.directories.conf for the channels database. This file will go into the directory specified
variable.""")) by the supybot.directories.conf variable."""))
supybot.register('plugins') # This will be used by plugins, but not here.
### ###
# Protocol information. # Protocol information.
@ -524,4 +498,46 @@ registerGlobalValue(supybot.protocols.irc, 'strictRfc',
currently this only affects what strings are considered to be nicks. If 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 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 False.""")) as services@this.network.server then you you should set this to False."""))
registerGlobalValue(supybot.protocols.irc, 'maxHistoryLength',
registry.Integer(1000, """Determines how many old messages the bot will keep
around in its history. Changing this variable will not take effect until
the bot is restarted."""))
registerGlobalValue(supybot.protocols.irc, 'throttleTime',
registry.Float(1.0, """A floating point number of seconds to throttle queued
messages -- that is, messages will not be sent faster than once per
throttleTime seconds."""))
registerGlobalValue(supybot.protocols.irc, 'ping',
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."""))
registerGlobalValue(supybot.protocols.irc.ping, 'interval',
registry.Integer(120, """Determines the number of seconds between sending
pings to the server, if pings are being sent to the server."""))
registerGroup(supybot.protocols, 'http')
registerGlobalValue(supybot.protocols.http, 'peekSize',
registry.PositiveInteger(4096, """Determines how many bytes the bot will
'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
found what it was looking for."""))
###
# Debugging options.
###
registerGroup(supybot, 'debug')
registerGlobalValue(supybot.debug, 'threadAllCommands',
registry.Boolean(False, """Determines whether the bot will automatically
thread all commands."""))
registerGlobalValue(supybot.debug, 'flushVeryOften',
registry.Boolean(False, """Determines whether the bot will automatically
flush all flushers *very* often. Useful for debugging when you don't know
what's breaking or when, but think that it might be logged."""))
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -115,6 +115,13 @@ def newDriver(server, irc, moduleName=None):
conf.supybot.driverModule to determine what driver to pick.""" conf.supybot.driverModule to determine what driver to pick."""
if moduleName is None: if moduleName is None:
moduleName = conf.supybot.drivers.module() moduleName = conf.supybot.drivers.module()
if moduleName == 'default':
try:
import twistedDrivers
moduleName = 'twistedDrivers'
except ImportError:
del sys.modules['twistedDrivers']
moduleName = 'socketDrivers'
driver = __import__(moduleName).Driver(server, irc) driver = __import__(moduleName).Driver(server, irc)
irc.driver = driver irc.driver = driver
return driver return driver

View File

@ -269,7 +269,7 @@ class IrcState(IrcCommandDispatcher):
__metaclass__ = log.MetaFirewall __metaclass__ = log.MetaFirewall
__firewalled__ = {'addMsg': None} __firewalled__ = {'addMsg': None}
def __init__(self): def __init__(self):
self.history = RingBuffer(conf.supybot.maxHistoryLength()) self.history=RingBuffer(conf.supybot.protocols.irc.maxHistoryLength())
self.reset() self.reset()
def reset(self): def reset(self):
@ -530,8 +530,7 @@ class Irc(IrcCommandDispatcher):
if self.fastqueue: if self.fastqueue:
msg = self.fastqueue.dequeue() msg = self.fastqueue.dequeue()
elif self.queue: elif self.queue:
if not world.testing and now - self.lastTake <= \ if now-self.lastTake <= conf.supybot.protocols.irc.throttleTime():
conf.supybot.throttleTime():
log.debug('Irc.takeMsg throttling.') log.debug('Irc.takeMsg throttling.')
else: else:
self.lastTake = now self.lastTake = now

View File

@ -77,6 +77,12 @@ def flush():
except Exception, e: except Exception, e:
log.exception('Uncaught exception in flusher #%s (%s):', i, f) log.exception('Uncaught exception in flusher #%s (%s):', i, f)
def debugFlush(s=''):
if conf.supybot.debug.flushVeryOften():
if s:
log.debug(s)
flush()
def upkeep(scheduleNext=True): def upkeep(scheduleNext=True):
"""Does upkeep (like flushing, garbage collection, etc.)""" """Does upkeep (like flushing, garbage collection, etc.)"""
sys.exc_clear() # Just in case, let's clear the exception info. sys.exc_clear() # Just in case, let's clear the exception info.

View File

@ -49,6 +49,7 @@ supybot.log.level: DEBUG
supybot.log.detailedTracebacks: False supybot.log.detailedTracebacks: False
supybot.throttleTime: 0 supybot.throttleTime: 0
supybot.prefixChars: @ supybot.prefixChars: @
supybot.protocols.irc.throttleTime: -1
""") """)
fd.close() fd.close()