Restricted the characters that a prefix character can be.

This commit is contained in:
Jeremy Fincher 2003-11-22 06:53:34 +00:00
parent 7642def926
commit 877d376988
3 changed files with 16 additions and 3 deletions

View File

@ -439,7 +439,12 @@ def main():
import callbacks import callbacks
conf.prefixChars = anything('What would you like your bot\'s ' conf.prefixChars = anything('What would you like your bot\'s '
'prefix character(s) to be?') 'prefix character(s) to be?')
while callbacks.canonicalName(conf.prefixChars) != conf.prefixChars: invalidPrefixChar = True
while invalidPrefixChar:
for c in conf.prefixChars:
if c not in conf.validPrefixChars:
invalidPrefixChar = True
myPrint('%r is not a valid prefixChar.' % c)
conf.prefixChars = anything('That includes one or more invalid ' conf.prefixChars = anything('That includes one or more invalid '
'prefix characters. What would you' 'prefix characters. What would you'
'like your bot\'s prefix character(s)' 'like your bot\'s prefix character(s)'

View File

@ -244,8 +244,10 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
Sets the prefix chars by which the bot can be addressed. Sets the prefix chars by which the bot can be addressed.
""" """
s = privmsgs.getArgs(args) s = privmsgs.getArgs(args)
if s.translate(string.ascii, string.ascii_letters) == '': for c in s:
irc.error(msg, 'Prefixes cannot contain letters.') if c not in conf.validPrefixChars:
s = 'PrefixChars must be something in %r'%conf.validPrefixChars
irc.error(msg, s)
else: else:
conf.prefixChars = s conf.prefixChars = s
irc.reply(msg, conf.replySuccess) irc.reply(msg, conf.replySuccess)

View File

@ -222,6 +222,12 @@ ignores = []
### ###
prefixChars = '@' prefixChars = '@'
###
# validPrefixChars: A string of chars that are allowed to be used as
# prefixChars.
###
validPrefixChars = '`~!@#$%^&*()_-+=[{}]\\|\'";:,<.>/?'
### ###
# detailedTracebacks: A boolean describing whether or not the bot will give # detailedTracebacks: A boolean describing whether or not the bot will give
# *extremely* detailed tracebacks. Be cautioned, this eats # *extremely* detailed tracebacks. Be cautioned, this eats