diff options
| author | tv <tv@shackspace.de> | 2014-07-15 12:12:28 +0200 | 
|---|---|---|
| committer | tv <tv@shackspace.de> | 2014-07-15 12:12:28 +0200 | 
| commit | e2b4d5270b996322583038e3e1037b4e5c339bb9 (patch) | |
| tree | ae0cb08bbbc887aa834ce117f3728cabe6d54db6 /Reaktor | |
| parent | 72ba736b99ea62499322f310f3ecfbd6c0cca344 (diff) | |
Reaktor on_ping -> nag
Diffstat (limited to 'Reaktor')
| -rw-r--r-- | Reaktor/IRC/ircasy.py | 4 | ||||
| -rwxr-xr-x | Reaktor/IRC/reaktor.py | 6 | ||||
| -rw-r--r-- | Reaktor/config.py | 18 | 
3 files changed, 23 insertions, 5 deletions
diff --git a/Reaktor/IRC/ircasy.py b/Reaktor/IRC/ircasy.py index 99fbc324..38f202fc 100644 --- a/Reaktor/IRC/ircasy.py +++ b/Reaktor/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/Reaktor/IRC/reaktor.py b/Reaktor/IRC/reaktor.py index 9a3424a6..799fe555 100755 --- a/Reaktor/IRC/reaktor.py +++ b/Reaktor/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/Reaktor/config.py b/Reaktor/config.py index 1741be20..98f17d67 100644 --- a/Reaktor/config.py +++ b/Reaktor/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 +  } +]  | 
