From 2fbd76dba662e0d15ff16c4b81bc3c91532fe9aa Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Tue, 19 May 2015 21:55:11 -0500 Subject: [PATCH] seen: make handle_seeing a @staticmethod --- dr_botzo/seen/ircplugin.py | 46 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/dr_botzo/seen/ircplugin.py b/dr_botzo/seen/ircplugin.py index 3b03c4f..f8fe5bd 100644 --- a/dr_botzo/seen/ircplugin.py +++ b/dr_botzo/seen/ircplugin.py @@ -20,8 +20,8 @@ class Seen(Plugin): def start(self): """Hook handler functions into the IRC library.""" - self.connection.add_global_handler('pubmsg', handle_seeing) - self.connection.add_global_handler('privmsg', handle_seeing) + self.connection.add_global_handler('pubmsg', self.handle_seeing) + self.connection.add_global_handler('privmsg', self.handle_seeing) self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!seen\s+(\S+)$', self.handle_seen) @@ -30,13 +30,32 @@ class Seen(Plugin): def stop(self): """Unhook handler functions into the IRC library.""" - self.connection.remove_global_handler('pubmsg', handle_seeing) - self.connection.remove_global_handler('privmsg', handle_seeing) + self.connection.remove_global_handler('pubmsg', self.handle_seeing) + self.connection.remove_global_handler('privmsg', self.handle_seeing) self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_seen) super(Seen, self).stop() + @staticmethod + def handle_seeing(connection, event): + """Track pubmsg/privmsg events.""" + + userhost = event.source + nick = irc.client.NickMask(event.source).nick + where = event.target + what = event.arguments[0] + + log.debug("userhost %s, nick %s, where %s, what '%s'", userhost, nick, where, what) + + # store the event. only learn events with real wheres + if where: + seen_nick, c = SeenNick.objects.get_or_create(nick=nick, channel=where) + seen_nick.host = userhost + seen_nick.what = what + seen_nick.seen_time = timezone.now() + seen_nick.save() + def handle_seen(self, connection, event, match): """Report on when a nick was last seen in a channel.""" @@ -55,23 +74,4 @@ class Seen(Plugin): return self.bot.reply(event, "i have not seen {0:s} in {1:s}.".format(query_nick, source)) -def handle_seeing(connection, event): - """Track pubmsg/privmsg events.""" - - userhost = event.source - nick = irc.client.NickMask(event.source).nick - where = event.target - what = event.arguments[0] - - log.debug("userhost %s, nick %s, where %s, what '%s'", userhost, nick, where, what) - - # store the event. only learn events with real wheres - if where: - seen_nick, c = SeenNick.objects.get_or_create(nick=nick, channel=where) - seen_nick.host = userhost - seen_nick.what = what - seen_nick.seen_time = timezone.now() - seen_nick.save() - - plugin = Seen