diff options
-rwxr-xr-x | Reaktor/commands/caps | 2 | ||||
-rw-r--r-- | Reaktor/config.py | 31 | ||||
-rw-r--r-- | Reaktor/titlebot/titlebot.py | 5 |
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' |