aboutsummaryrefslogtreecommitdiffstats
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
commit89cc9517383f7e01e7d2f3bd4781048d3c1139fb (patch)
tree72332eb7b519c3ff25183022bbad3bc3f52dcd30
parent31bf2d4d296347eece924dcfa690390f9a72deaf (diff)
reaktor: name must not be able to kill patterns
-rw-r--r--config.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/config.py b/config.py
index 4ca6d37..48406bf 100644
--- a/config.py
+++ b/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',