From e1571b5a5cda983234cd6d5c4998ab883cc46115 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 25 Apr 2014 13:19:50 +0200 Subject: reaktor config: unify ^(|*): --- Reaktor/config.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index 48406bf9..90540340 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -20,13 +20,14 @@ irc_channels = [ admin_file='admin.lst' auth_file='auth.lst' -# name_re is used, so name cannot kill our patterns below -name_re = re.escape(name) +# me is used, so name cannot kill our patterns below +me = '\\b' + re.escape(name) + '\\b' +me_or_us = '(?:' + me + '|\\*)' def default_command(cmd): return { 'capname': cmd, - 'pattern': '^(?:' + name_re + '|\\*):\\s*' + cmd + '\\s*(?:\\s+(?P.*))?$', + 'pattern': '^' + me_or_us + ':\\s*' + cmd + '\\s*(?:\\s+(?P.*))?$', 'argv': [ 'commands/' + cmd ] } public_commands = [ @@ -38,19 +39,19 @@ public_commands = [ default_command('nocommand'), { 'capname': 'tell', - 'pattern': '^' + name_re + ':\\s*' + 'tell' + '\\s*(?:\\s+(?P.*))?$', + 'pattern': '^' + me_or_us + ':\\s*' + 'tell' + '\\s*(?:\\s+(?P.*))?$', 'argv': [ 'commands/tell-on_privmsg' ], 'env': { 'state_file': workdir + '/tell.txt' } }, # command not found - { 'pattern': '^(?:' + name_re + '|\\*):.*', + { 'pattern': '^' + me_or_us + ':.*', 'argv': [ 'commands/respond','You are made of stupid!'] }, # "highlight" - { 'pattern': '.*\\b' + name_re + '\\b.*', + { 'pattern': '.*' + me + '.*', 'argv': [ 'commands/say', 'I\'m famous' ] }, # identify via direct connect { 'capname': 'identify', - 'pattern': '^identify' + '\\s*(?:\\s+(?P.*))?$', + 'pattern': '^identify' + '\\s*(?:\\s+(?P.*))?$', 'argv' : [ 'commands/identify' ]} ] commands = [ -- cgit v1.2.3