summaryrefslogtreecommitdiffstats
path: root/Reaktor/config.py
diff options
context:
space:
mode:
authormakefu <root@pigstarter.de>2014-04-25 14:19:51 +0200
committermakefu <root@pigstarter.de>2014-04-25 14:22:28 +0200
commitfe0a555e87f5e522e4d4e4a4f27a09c02e267590 (patch)
tree19c84c87642d519e135487515de1e4e914c5bfff /Reaktor/config.py
parent3560697a49050d74b04a537a994b34e1e4a4c807 (diff)
parent018441364e956c6128fe9e898f7176a324875ded (diff)
Merge branch 'master' of https://github.com/krebscode/painload
Conflicts: Reaktor/config.py
Diffstat (limited to 'Reaktor/config.py')
-rw-r--r--Reaktor/config.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/Reaktor/config.py b/Reaktor/config.py
index 5858532e..424019a7 100644
--- a/Reaktor/config.py
+++ b/Reaktor/config.py
@@ -26,15 +26,25 @@ config_filename = abspath(__file__)
me = '\\b' + re.escape(name) + '\\b'
me_or_us = '(?:' + me + '|\\*)'
-def default_command(cmd, env=None):
+def default_command(cap, cmd=None, env=None):
if not env: env = {}
+ if cmd == None: cmd=cap
return {
- 'capname': cmd,
- 'pattern': '^' + me_or_us + ':\\s*' + cmd + '\\s*(?:\\s+(?P<args>.*))?$',
+ 'capname': cap,
+ 'pattern': '^' + me_or_us + ':\\s*' + cap + '\\s*(?:\\s+(?P<args>.*))?$',
'argv': [ 'commands/' + cmd ],
'env': env
}
+def simple_command(cap, cmd=None, env={}):
+ if cmd == None: cmd=cap
+ return {
+ 'capname': cap,
+ 'pattern': '^' + cap + '\\s*(?:\\s+(?P<args>.*))?$',
+ 'argv' : [ 'commands/' + cmd ],
+ 'env': env
+ }
+
public_commands = [
default_command('caps', env={
'config_filename': config_filename
@@ -44,12 +54,9 @@ public_commands = [
default_command('rev'),
default_command('uptime'),
default_command('nocommand'),
- {
- 'capname': 'tell',
- 'pattern': '^' + me_or_us + ':\\s*' + 'tell' + '\\s*(?:\\s+(?P<args>.*))?$',
- 'argv': [ 'commands/tell-on_privmsg' ],
- 'env': { 'state_file': workdir + '/tell.txt' }
- },
+ default_command('tell', cmd='tell-on_privmsg', env={
+ 'state_file': workdir + '/tell.txt'
+ }),
# command not found
{ 'pattern': '^' + me_or_us + ':.*',
'argv': [ 'commands/respond','You are made of stupid!'] },
@@ -57,9 +64,9 @@ public_commands = [
{ 'pattern': '.*' + me + '.*',
'argv': [ 'commands/say', 'I\'m famous' ] },
# identify via direct connect
- { 'capname': 'identify',
- 'pattern': '^identify' + '\\s*(?:\\s+(?P<args>.*))?$',
- 'argv' : [ 'commands/identify' ]}
+ simple_command('identify', env={
+ 'config_filename': config_filename
+ })
]
commands = [
default_command('reload')