aboutsummaryrefslogtreecommitdiffstats
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
commita23f8d14ebf1cd5cbf5900d02978ac6f78bbee67 (patch)
tree1d37e16397f123b5cbeba157f13b76a042e6667a
parent871e2f164a81e33e82cb64ddf1447ba98f0e75aa (diff)
parent1e80665ab64bbcd783188c1c87afa5e81c126694 (diff)
Merge branch 'master' of https://github.com/krebscode/painload
Conflicts: Reaktor/config.py
-rwxr-xr-xcommands/caps2
-rw-r--r--config.py31
-rw-r--r--titlebot/titlebot.py5
3 files changed, 23 insertions, 15 deletions
diff --git a/commands/caps b/commands/caps
index d024557..b5d6642 100755
--- a/commands/caps
+++ b/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/config.py b/config.py
index 5858532..424019a 100644
--- a/config.py
+++ b/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/titlebot/titlebot.py b/titlebot/titlebot.py
index b5195d5..05ff612 100644
--- a/titlebot/titlebot.py
+++ b/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'