summaryrefslogtreecommitdiffstats
path: root/Reaktor/config.py
diff options
context:
space:
mode:
authortv <tv@nomic.retiolum>2014-04-25 13:08:46 +0200
committertv <tv@nomic.retiolum>2014-04-25 13:08:46 +0200
commit4fbc3dd22e5ee5c04fd346a9424f796e671a6f05 (patch)
tree791fb1fcc56821e6f442147bfc448a87a4a6559d /Reaktor/config.py
parent2ff3166d78710db3f6346cdb743f8ff7d3e7e1a3 (diff)
reaktor: name must not be able to kill patterns
Diffstat (limited to 'Reaktor/config.py')
-rw-r--r--Reaktor/config.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Reaktor/config.py b/Reaktor/config.py
index 4ca6d377..48406bf9 100644
--- a/Reaktor/config.py
+++ b/Reaktor/config.py
@@ -1,8 +1,8 @@
from os.path import expanduser
+import re
debug = True
-# CAVEAT name should not contains regex magic
name = 'crabmanner'
workdir = expanduser('~') + '/state'
@@ -19,10 +19,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)
+
def default_command(cmd):
return {
'capname': cmd,
- 'pattern': '^(?:' + name + '|\\*):\\s*' + cmd + '\\s*(?:\\s+(?P<args>.*))?$',
+ 'pattern': '^(?:' + name_re + '|\\*):\\s*' + cmd + '\\s*(?:\\s+(?P<args>.*))?$',
'argv': [ 'commands/' + cmd ] }
public_commands = [
@@ -34,15 +38,15 @@ public_commands = [
default_command('nocommand'),
{
'capname': 'tell',
- 'pattern': '^' + name + ':\\s*' + 'tell' + '\\s*(?:\\s+(?P<args>.*))?$',
+ 'pattern': '^' + name_re + ':\\s*' + 'tell' + '\\s*(?:\\s+(?P<args>.*))?$',
'argv': [ 'commands/tell-on_privmsg' ],
'env': { 'state_file': workdir + '/tell.txt' }
},
# command not found
- { 'pattern': '^(?:' + name + '|\\*):.*',
+ { 'pattern': '^(?:' + name_re + '|\\*):.*',
'argv': [ 'commands/respond','You are made of stupid!'] },
# "highlight"
- { 'pattern': '.*\\b' + name + '\\b.*',
+ { 'pattern': '.*\\b' + name_re + '\\b.*',
'argv': [ 'commands/say', 'I\'m famous' ] },
# identify via direct connect
{ 'capname': 'identify',