summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xReaktor/IRC/asybot.py7
-rw-r--r--Reaktor/TODO4
-rwxr-xr-xReaktor/commands/caps24
-rw-r--r--Reaktor/config.py1
4 files changed, 30 insertions, 6 deletions
diff --git a/Reaktor/IRC/asybot.py b/Reaktor/IRC/asybot.py
index 048b94ce..38f0df11 100755
--- a/Reaktor/IRC/asybot.py
+++ b/Reaktor/IRC/asybot.py
@@ -2,6 +2,7 @@
#
# //Reaktor/IRC/asybot.py
#
+import os
from translate_colors import translate_colors
def is_executable(x):
import os
@@ -18,8 +19,11 @@ from sys import exit
from re import split, search, match
from textwrap import TextWrapper
import logging,logging.handlers
+
+config_filename = 'config.py'
+
from getconf import make_getconf
-getconf = make_getconf('config.py')
+getconf = make_getconf(config_filename)
log = logging.getLogger('asybot')
hdlr = logging.handlers.SysLogHandler(facility=logging.handlers.SysLogHandler.LOG_DAEMON)
formatter = logging.Formatter( '%(filename)s: %(levelname)s: %(message)s')
@@ -142,6 +146,7 @@ class asybot(asychat):
env = {}
env['_from'] = prefix.split('!', 1)[0]
+ env['config_filename'] = os.path.abspath(config_filename)
start = time()
try:
p = popen(myargv, bufsize=1, stdout=PIPE, stderr=PIPE, env=env)
diff --git a/Reaktor/TODO b/Reaktor/TODO
index c56ac00a..9dc65636 100644
--- a/Reaktor/TODO
+++ b/Reaktor/TODO
@@ -1,3 +1,7 @@
+commands/caps: merge load_config with IRC/getconf.py
+commands/caps: generalize for UDP
+commands/caps: replace map/filter with more pythonic way
+
getconf: reload inotify
apropros caps: commands need access to config
diff --git a/Reaktor/commands/caps b/Reaktor/commands/caps
index caa1fe06..eb1d97a6 100755
--- a/Reaktor/commands/caps
+++ b/Reaktor/commands/caps
@@ -1,5 +1,19 @@
-#! /bin/sh
-exec echo 'TODO: need access to config.json'
-set -euf
-cd public_commands
-echo `ls`
+#! /usr/bin/env python
+import imp
+import os
+
+def load_config(filename):
+ dirname = os.path.dirname(filename)
+ modname, ext = os.path.splitext(os.path.basename(filename))
+ file, pathname, description = imp.find_module(modname, [ dirname ])
+ return imp.load_module(modname, file, pathname, description)
+
+def not_none(x):
+ return x != None
+
+def pluck(name):
+ return lambda x: name in x.keys() and x[name] or None
+
+config = load_config(os.environ['config_filename'])
+
+print(' '.join(filter(not_none, map(pluck('capname'), config.irc_commands))))
diff --git a/Reaktor/config.py b/Reaktor/config.py
index ec4abcb1..ed8c5efb 100644
--- a/Reaktor/config.py
+++ b/Reaktor/config.py
@@ -16,6 +16,7 @@ irc_channels = [
def default_command(cmd):
return {
+ 'capname': cmd,
'pattern': '^(?:' + name + '|\\*):\\s*' + cmd + '\\s*$',
'argv': [ 'commands/' + cmd ] }