diff --git a/pyircbot/irccore.py b/pyircbot/irccore.py index 43644e7..3648541 100644 --- a/pyircbot/irccore.py +++ b/pyircbot/irccore.py @@ -134,11 +134,10 @@ class IRCCore(object): self.fire_hook(command, args=args, prefix=prefix, trailing=trailing) def sendRaw(self, data): - self.log.warning(">>> {}".format(repr(data))) + self.log.debug(">>> {}".format(repr(data))) + self.fire_hook('_SEND', args=None, prefix=None, trailing=None) self.writer.write((data + "\r\n").encode("UTF-8")) - - " Module related code " def initHooks(self): """Defines hooks that modules can listen for events of""" @@ -146,6 +145,7 @@ class IRCCore(object): '_CONNECT', '_DISCONNECT', '_RECV', + '_SEND', 'NOTICE', 'MODE', 'PING', diff --git a/pyircbot/modules/PingResponder.py b/pyircbot/modules/PingResponder.py index 251f632..97138bb 100755 --- a/pyircbot/modules/PingResponder.py +++ b/pyircbot/modules/PingResponder.py @@ -18,7 +18,8 @@ class PingResponder(ModuleBase): self.timer = PingRespondTimer(self) self.hooks = [ ModuleHook("PING", self.pingrespond), - ModuleHook("_RECV", self.resettimer) + ModuleHook("_RECV", self.resettimer), + ModuleHook("_SEND", self.resettimer) ] def pingrespond(self, args, prefix, trailing): @@ -56,8 +57,8 @@ class PingRespondTimer(Thread): def run(self): while self.alive: sleep(5) - if time() - self.lastping > 300: # TODO: configurable timeout - self.master.log.info("No pings in %s seconds. Reconnecting" % str(time() - self.lastping)) + if time() - self.lastping > self.config.get("activity_timeout", 300): + self.master.log.info("No activity in %s seconds. Reconnecting" % str(time() - self.lastping)) self.master.bot.disconnect("Reconnecting...") self.reset()