summaryrefslogtreecommitdiffstats
path: root/Reaktor
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
parent3560697a49050d74b04a537a994b34e1e4a4c807 (diff)
parent018441364e956c6128fe9e898f7176a324875ded (diff)
Merge branch 'master' of https://github.com/krebscode/painload
Conflicts: Reaktor/config.py
Diffstat (limited to 'Reaktor')
-rwxr-xr-xReaktor/commands/caps2
-rw-r--r--Reaktor/config.py31
-rw-r--r--Reaktor/titlebot/titlebot.py5
3 files changed, 23 insertions, 15 deletions
diff --git a/Reaktor/commands/caps b/Reaktor/commands/caps
index d0245575..b5d6642d 100755
--- a/Reaktor/commands/caps
+++ b/Reaktor/commands/caps
@@ -10,4 +10,4 @@ def load_config(filename):
config = load_config(os.environ['config_filename'])
print('Private: '+' '.join(filter(None,[ x.get('capname',None) for x in config.commands])))
-print('Public: '+' '.join(filter(None,[ x.get('capname',None) for x in config.public_commands])))
+print('Public: '+' '.join(filter(None,[ x.get('capname',None) for x in config.public_commands])))
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')
diff --git a/Reaktor/titlebot/titlebot.py b/Reaktor/titlebot/titlebot.py
index b5195d53..05ff612e 100644
--- a/Reaktor/titlebot/titlebot.py
+++ b/Reaktor/titlebot/titlebot.py
@@ -1,6 +1,7 @@
-from os import environ,mkdir,abspath
+from os import environ,mkdir
+from os.path import abspath, expanduser
-debug = True
+debug = False
# CAVEAT name should not contains regex magic
name = 'bgt_titlebot'