reference handlers directly rather than w/getattr

mostly just picking a convention
This commit is contained in:
Brian S. Stephan 2015-05-15 22:21:15 -05:00
parent 903a8f5c80
commit 53caf2b94b
4 changed files with 18 additions and 17 deletions

View File

@ -14,14 +14,14 @@ class Echo(Plugin):
"""Set up the handlers."""
self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!echo\s+(.*)$',
getattr(self, 'handle_echo'), -20)
self.handle_echo, -20)
super(Echo, self).start()
def stop(self):
"""Tear down handlers."""
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], getattr(self, 'handle_echo'))
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_echo)
super(Echo, self).stop()

View File

@ -15,20 +15,20 @@ class ChannelManagement(Plugin):
"""Set up the handlers."""
self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!join\s+([\S]+)',
getattr(self, 'handle_join'), -20)
self.handle_join, -20)
self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!part\s+([\S]+)',
getattr(self, 'handle_part'), -20)
self.handle_part, -20)
self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!quit\s*(.*)',
getattr(self, 'handle_quit'), -20)
self.handle_quit, -20)
super(ChannelManagement, self).start()
def stop(self):
"""Tear down handlers."""
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], getattr(self, 'handle_join'))
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], getattr(self, 'handle_part'))
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], getattr(self, 'handle_quit'))
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_join)
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_part)
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_quit)
super(ChannelManagement, self).stop()

View File

@ -17,21 +17,22 @@ class Markov(Plugin):
def start(self):
"""Set up the handlers."""
self.connection.add_global_handler('pubmsg', getattr(self, 'handle_chatter'), -20)
self.connection.add_global_handler('privmsg', getattr(self, 'handle_chatter'), -20)
self.connection.add_global_handler('pubmsg', self.handle_chatter, -20)
self.connection.add_global_handler('privmsg', self.handle_chatter, -20)
self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!markov\s+reply(\s+min=(\d+))?(\s+max=(\d+))?(\s+(.*)$|$)',
getattr(self, 'handle_reply'), -20)
self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'],
r'^!markov\s+reply(\s+min=(\d+))?(\s+max=(\d+))?(\s+(.*)$|$)',
self.handle_reply, -20)
super(Markov, self).start()
def stop(self):
"""Tear down handlers."""
self.connection.remove_global_handler('pubmsg', getattr(self, 'handle_chatter'))
self.connection.remove_global_handler('privmsg', getattr(self, 'handle_chatter'))
self.connection.remove_global_handler('pubmsg', self.handle_chatter)
self.connection.remove_global_handler('privmsg', self.handle_chatter)
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], getattr(self, 'handle_reply'))
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_reply)
super(Markov, self).stop()

View File

@ -16,14 +16,14 @@ class Weather(Plugin):
"""Set up the handlers."""
self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!weather\s+(.*)$',
getattr(self, 'handle_weather'), -20)
self.handle_weather, -20)
super(Weather, self).start()
def stop(self):
"""Tear down handlers."""
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], getattr(self, 'handle_weather'))
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_weather)
super(Weather, self).stop()