aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-07-15 12:12:28 +0200
committertv <tv@shackspace.de>2014-07-15 12:12:28 +0200
commit0f626437e0816d15602051f9b2252095bfcdabaf (patch)
treeb847a0acd04baaab0e8f2695588fcd8eaf1033ff
parentc21d8f1f55651607f82a9f60b3f89402fb9fdc47 (diff)
Reaktor on_ping -> nag
-rw-r--r--IRC/ircasy.py4
-rwxr-xr-xIRC/reaktor.py6
-rw-r--r--config.py18
3 files changed, 23 insertions, 5 deletions
diff --git a/IRC/ircasy.py b/IRC/ircasy.py
index 99fbc32..38f202f 100644
--- a/IRC/ircasy.py
+++ b/IRC/ircasy.py
@@ -110,6 +110,7 @@ class asybot(asychat):
if command == 'PING':
self.push('PONG :%s' % rest)
self.log.debug("Replying to servers PING with PONG :%s" %rest)
+ self.on_ping(prefix, command, params, rest)
elif command == 'PRIVMSG':
self.on_privmsg(prefix, command, params, rest)
@@ -185,6 +186,9 @@ class asybot(asychat):
def on_join(self, prefix, command, params, rest):
pass
+ def on_ping(self, prefix, command, params, rest):
+ pass
+
def on_privmsg(self, prefix, command, params, rest):
pass
diff --git a/IRC/reaktor.py b/IRC/reaktor.py
index 9a3424a..799fe55 100755
--- a/IRC/reaktor.py
+++ b/IRC/reaktor.py
@@ -39,6 +39,12 @@ class Reaktor(asybot):
for command in getconf('on_join', []):
self.execute_command(command, None, prefix, params)
+ def on_ping(self, prefix, command, params, rest):
+ for command in 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'):
y = match(command['pattern'], rest)
diff --git a/config.py b/config.py
index 1741be2..98f17d6 100644
--- a/config.py
+++ b/config.py
@@ -71,11 +71,6 @@ public_commands = [
]
commands = [
default_command('reload'),
- default_command('nag', env={
- 'workdir': workdir,
- 'hostsdir': '/home/tv/krebs/hosts',
- 'servicesdir': '/home/tv/krebs/services'
- })
]
on_join = [
@@ -85,3 +80,16 @@ on_join = [
'env': { 'state_file': workdir + '/tell.txt' }
}
]
+
+on_ping = [
+ {
+ 'capname': 'nag',
+ 'argv': [ 'commands/nag' ],
+ 'env': {
+ 'workdir': workdir,
+ 'hostsdir': '/home/tv/krebs/hosts',
+ 'servicesdir': '/home/tv/krebs/services'
+ },
+ 'targets': irc_channels
+ }
+]