Added configurable command prefix

This commit is contained in:
Luke Rogers 2011-11-21 00:03:49 +13:00
parent 664b67c5c0
commit 6f37dfa9bc
2 changed files with 5 additions and 3 deletions

3
config
View file

@ -14,6 +14,7 @@
"disabled_plugins": [], "disabled_plugins": [],
"disabled_commands": [], "disabled_commands": [],
"acls": {}, "acls": {},
"prefix": ".",
"api_keys": {"geoip":"NULL","mc":["USER","PASS"]}, "api_keys": {"geoip":"NULL","mc":["USER","PASS"]},
"censored_strings": "censored_strings":
[ [
@ -27,5 +28,5 @@
"!coz", "!coz",
"!tell /x" "!tell /x"
], ],
"admins": ["TheLuke","Luke"] "admins": ["USERNAME"]
} }

View file

@ -143,6 +143,7 @@ def match_command(command):
def main(conn, out): def main(conn, out):
inp = Input(conn, *out) inp = Input(conn, *out)
commandprefix = bot.config['prefix']
# EVENTS # EVENTS
for func, args in bot.events[inp.command] + bot.events['*']: for func, args in bot.events[inp.command] + bot.events['*']:
@ -151,9 +152,9 @@ def main(conn, out):
if inp.command == 'PRIVMSG': if inp.command == 'PRIVMSG':
# COMMANDS # COMMANDS
if inp.chan == inp.nick: # private message, no command prefix if inp.chan == inp.nick: # private message, no command prefix
prefix = r'^(?:[.]?|' prefix = r'^(?:[' + commandprefix + ']?|'
else: else:
prefix = r'^(?:[.]|' prefix = r'^(?:[' + commandprefix + ']|'
command_re = prefix + inp.conn.nick command_re = prefix + inp.conn.nick
command_re += r'[:]+\s+)(\w+)(?:$|\s+)(.*)' command_re += r'[:]+\s+)(\w+)(?:$|\s+)(.*)'