remove_global_handler() for pubmsg and privmsg by default, since Module does the add_global_handler() (last commit)

This commit is contained in:
Brian S. Stephan 2010-07-30 18:53:58 -05:00
parent eb1efa4919
commit 594c4d297d
6 changed files with 3 additions and 22 deletions

View File

@ -68,12 +68,13 @@ class Module(object):
Unhook handler functions from the IRC library. Inverse of the above. Unhook handler functions from the IRC library. Inverse of the above.
This is called by reload, to remove the soon-to-be old object from the server This is called by reload, to remove the soon-to-be old object from the server
global handlers (or whatever has been added via register_handlers). Classes global handlers (or whatever has been added via register_handlers). Classes
inheriting from Module should implement this, e.g.: inheriting from Module could implement this, e.g.:
server.remove_global_handler('privmsg', self.on_privmsg) server.remove_global_handler('privmsg', self.on_privmsg)
""" """
print "looks like someone forgot to implement unregister_handlers!" self.server.remove_global_handler('pubmsg', self.on_pubmsg)
self.server.remove_global_handler('privmsg', self.on_privmsg)
def on_pubmsg(self, connection, event): def on_pubmsg(self, connection, event):
""" """

View File

@ -28,10 +28,6 @@ from Module import Module
class Countdown(Module): class Countdown(Module):
def unregister_handlers(self):
self.server.remove_global_handler('pubmsg', self.on_pubmsg)
self.server.remove_global_handler('privmsg', self.on_privmsg)
def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked): def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
whats = what.split(' ') whats = what.split(' ')
if whats[0] == 'countdown' and len(whats) >= 2: if whats[0] == 'countdown' and len(whats) >= 2:

View File

@ -25,10 +25,6 @@ from Module import Module
class Dice(Module): class Dice(Module):
def unregister_handlers(self):
self.server.remove_global_handler('pubmsg', self.on_pubmsg)
self.server.remove_global_handler('privmsg', self.on_privmsg)
def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked): def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
overallroll = what overallroll = what

View File

@ -27,10 +27,6 @@ from Module import Module
class FactFile(Module): class FactFile(Module):
def unregister_handlers(self):
self.server.remove_global_handler('pubmsg', self.on_pubmsg)
self.server.remove_global_handler('privmsg', self.on_privmsg)
def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked): def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
whats = what.split(' ') whats = what.split(' ')
try: try:

View File

@ -27,10 +27,6 @@ from Module import Module
class GoogleTranslate(Module): class GoogleTranslate(Module):
def unregister_handlers(self):
self.server.remove_global_handler('pubmsg', self.on_pubmsg)
self.server.remove_global_handler('privmsg', self.on_privmsg)
def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked): def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
whats = what.split(' ') whats = what.split(' ')
if whats[0] == 'translate' and len(whats) >= 4: if whats[0] == 'translate' and len(whats) >= 4:

View File

@ -28,10 +28,6 @@ from Module import Module
class Seen(Module): class Seen(Module):
def unregister_handlers(self):
self.server.remove_global_handler('pubmsg', self.on_pubmsg)
self.server.remove_global_handler('privmsg', self.on_privmsg)
# Overriding the default because we need stuff to occur before the addressed # Overriding the default because we need stuff to occur before the addressed
# and so on checks. # and so on checks.