aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2015-08-28 11:05:44 +0200
committermakefu <github@syntax-fehler.de>2015-08-28 11:05:44 +0200
commit8a8abdde5b9b834fb4f51fcfb44df239e572b8af (patch)
tree5d12f09eb2653774d92983000a3c530b7129ec87
parent50d9d22aea21701ddde0a349ddb92ffb6b1c66e2 (diff)
Reaktor: IRC -> reaktor
Remove Obsolete README, remove obsolete index
-rw-r--r--IRC/README.md49
-rwxr-xr-xIRC/index6
-rw-r--r--reaktor/__init__.py0
-rwxr-xr-xreaktor/core.py (renamed from IRC/reaktor.py)49
-rw-r--r--reaktor/getconf.py (renamed from IRC/getconf.py)0
-rw-r--r--reaktor/ircasy.py (renamed from IRC/ircasy.py)0
-rw-r--r--reaktor/translate_colors.py (renamed from IRC/translate_colors.py)0
7 files changed, 33 insertions, 71 deletions
diff --git a/IRC/README.md b/IRC/README.md
deleted file mode 100644
index 63a0ebd..0000000
--- a/IRC/README.md
+++ /dev/null
@@ -1,49 +0,0 @@
-# //Reaktor/IRC
-
-This component implements a remote shell daemon that exposes the
-executable files (which may be symlinks) below
-`//Reaktor/public_commands/` through IRC.
-
-## Security
-
-Access to the IRC server implies full access to all the exposed executable
-files. The daemon is executing the commands without dropping privileges.
-
-## Quickstart
-
- #? /bin/sh
- set -euf
-
- export nick="$LOGNAME|$HOSTNAME"
- export host=irc.freenode.org
- export target='#tincspasm'
-
- exec Reaktor/IRC/index
-
-## Environment variables
-
-The following environment variables are processed by `//Reaktor/IRC`:
-
-### nick
-
-Use a specific nickname.
-
-Optional if the node running `//Reaktor/IRC` is part of Retiolum, in
-which case it defaults to `Name` in `/etc/tinc/retiolum/tinc.conf`.
-
-### host and port
-
-Connect to a specific IRC server.
-
-Optional if the node running `//Reaktor/IRC` is part of Retiolum, in
-which case it defaults to `supernode` and `6667` (well, it always
-defaults to these two, but they only make science in Retiolum^_^).
-
-### target
-
-Join a specific channel.
-
-As always, this does the right thing for properly configured hosts: it
-uses the default `#retiolum`, which is the only really relevant
-channel.^_^
-
diff --git a/IRC/index b/IRC/index
deleted file mode 100755
index af557a8..0000000
--- a/IRC/index
+++ /dev/null
@@ -1,6 +0,0 @@
-#! /bin/sh
-set -xeuf
-
-# cd //Reaktor
-cd $(dirname $(readlink -f $0))/..
-exec IRC/reaktor.py "$@"
diff --git a/reaktor/__init__.py b/reaktor/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/reaktor/__init__.py
diff --git a/IRC/reaktor.py b/reaktor/core.py
index 124fa01..15166d9 100755
--- a/IRC/reaktor.py
+++ b/reaktor/core.py
@@ -1,17 +1,16 @@
#!/usr/bin/env python3
import os
-from ircasy import asybot
+from reaktor.ircasy import asybot
from asyncore import loop
-from translate_colors import translate_colors
+from reaktor.translate_colors import translate_colors
import shlex
from re import split, search, match
default_config = './config.py'
-from getconf import make_getconf
-getconf = None
+from reaktor.getconf import make_getconf
import logging,logging.handlers
-log = logging.getLogger('asybot')
+log = logging.getLogger('Reaktor')
#hdlr = logging.handlers.SysLogHandler(address='/dev/log', facility=logging.handlers.SysLogHandler.LOG_DAEMON)
#formatter = logging.Formatter( '%(filename)s: %(levelname)s: %(message)s')
#hdlr.setFormatter(formatter)
@@ -20,14 +19,27 @@ log = logging.getLogger('asybot')
class Reaktor(asybot):
- def __init__(self,config=default_config):
+ def __init__(self,config=default_config,getconf=None):
self.config = config
+
+ if not getconf:
+ self.getconf = make_getconf(self.conf)
+ else:
+ self.getconf = getconf
log.info("using config file %s"%(config))
- asybot.__init__(self, getconf('irc_server'), getconf('irc_port'), getconf('irc_nickname'), getconf('irc_channels'), hammer_interval=getconf('irc_hammer_interval'), alarm_timeout=getconf('irc_alarm_timeout'), kill_timeout=getconf('irc_kill_timeout'))
+
+ asybot.__init__(self,
+ getconf('irc_server'),
+ getconf('irc_port'),
+ getconf('irc_nickname'),
+ getconf('irc_channels'),
+ hammer_interval=getconf('irc_hammer_interval'),
+ alarm_timeout=getconf('irc_alarm_timeout'),
+ kill_timeout=getconf('irc_kill_timeout'))
def is_admin(self,prefix):
try:
- with open(getconf('auth_file')) as f:
+ with open(self.getconf('auth_file')) as f:
for line in f:
if line.strip() == prefix:
return True
@@ -36,17 +48,17 @@ class Reaktor(asybot):
return False
def on_join(self, prefix, command, params, rest):
- for command in getconf('on_join', []):
+ for command in self.getconf('on_join', []):
self.execute_command(command, None, prefix, params)
def on_ping(self, prefix, command, params, rest):
- for command in getconf('on_ping', []):
+ for command in self.getconf('on_ping', []):
prefix = '!' # => env = { _prefix: '!', _from: '' }
params = command.get('targets') # TODO why don't we get a list here and use ','.join() ?
self.execute_command(command, None, prefix, params)
def on_privmsg(self, prefix, command, params, rest):
- for command in getconf('commands'):
+ for command in self.getconf('commands'):
y = match(command['pattern'], rest)
if y:
if not self.is_admin(prefix):
@@ -54,7 +66,7 @@ class Reaktor(asybot):
else:
return self.execute_command(command, y, prefix, params)
- for command in getconf('public_commands'):
+ for command in self.getconf('public_commands'):
y = match(command['pattern'], rest)
if y:
return self.execute_command(command, y, prefix, params)
@@ -74,7 +86,7 @@ class Reaktor(asybot):
except:
log.info("cannot parse args!")
- cwd = getconf('workdir')
+ cwd = self.getconf('workdir')
if not os.access(cwd,os.W_OK):
log.error("Workdir '%s' is not Writable! Falling back to root dir"%cwd)
cwd = "/"
@@ -116,10 +128,15 @@ class Reaktor(asybot):
if code != 0:
self.ME(target, 'mimimi')
-if __name__ == "__main__":
+def main():
import sys
conf = sys.argv[1] if len(sys.argv) == 2 else default_config
getconf = make_getconf(conf)
- logging.basicConfig(level = logging.DEBUG if getconf('debug') else logging.INFO)
- Reaktor(conf)
+ logging.basicConfig(level = logging.DEBUG if getconf('debug') else
+ logging.INFO)
+ log.debug("Debug enabled")
+ Reaktor(conf,getconf)
loop()
+
+if __name__ == "__main__":
+ main()
diff --git a/IRC/getconf.py b/reaktor/getconf.py
index 168c908..168c908 100644
--- a/IRC/getconf.py
+++ b/reaktor/getconf.py
diff --git a/IRC/ircasy.py b/reaktor/ircasy.py
index 38f202f..38f202f 100644
--- a/IRC/ircasy.py
+++ b/reaktor/ircasy.py
diff --git a/IRC/translate_colors.py b/reaktor/translate_colors.py
index bd71661..bd71661 100644
--- a/IRC/translate_colors.py
+++ b/reaktor/translate_colors.py