Merge pull request #107 from craisins/master

Added support for custom bot prefixes
This commit is contained in:
Ryan Hitchman 2014-05-09 15:04:57 -07:00
commit c14cc2d1b0
2 changed files with 4 additions and 2 deletions

View File

@ -19,6 +19,7 @@ if not os.path.exists('config'):
"channels": ["#test"] "channels": ["#test"]
} }
}, },
"prefix": ".",
"disabled_plugins": [], "disabled_plugins": [],
"disabled_commands": [], "disabled_commands": [],
"acls": {}, "acls": {},

View File

@ -163,10 +163,11 @@ def main(conn, out):
if inp.command == 'PRIVMSG': if inp.command == 'PRIVMSG':
# COMMANDS # COMMANDS
bot_prefix = re.escape(bot.config.get("prefix", "."))
if inp.chan == inp.nick: # private message, no command prefix if inp.chan == inp.nick: # private message, no command prefix
prefix = r'^(?:[.]?|' prefix = r'^(?:['+bot_prefix+']?|'
else: else:
prefix = r'^(?:[.]|' prefix = r'^(?:['+bot_prefix+']|'
command_re = prefix + inp.conn.nick command_re = prefix + inp.conn.nick
command_re += r'[:,]+\s+)(\w+)(?:$|\s+)(.*)' command_re += r'[:,]+\s+)(\w+)(?:$|\s+)(.*)'