have Module inherit from object, remove some debugging stuff in Module, implemeent a skeleton of a GoogleTranslate module, use that to test

This commit is contained in:
Brian S. Stephan 2010-07-25 20:14:53 -05:00
parent c25af51088
commit 11ddb9af27
1 changed files with 11 additions and 4 deletions

View File

@ -12,7 +12,7 @@ from dateutil.relativedelta import *
from dateutil.tz import *
import irclib
class Module:
class Module(object):
"""Base class used for creating classes that have real functionality.
"""
@ -37,8 +37,6 @@ class Module:
"""
print "looks like someone forgot to implement register_handlers!"
server.add_global_handler('pubmsg', self.on_pubmsg)
server.add_global_handler('privmsg', self.on_privmsg)
def on_pubmsg(self, connection, event):
"""Does some variable setup and initial sanity checking before calling Module.do,
@ -96,6 +94,15 @@ class Module:
print "looks like someone forgot to implement do!"
class GoogleTranslate(Module):
"""Class that translates text via Google Translate.
http://code.google.com/apis/ajaxlanguage/documentation/
"""
def __init__(self, config, server):
super(GoogleTranslate, self).__init__(config, server)
#####
# sub_join_channel
# join a channel when told to by an admin
@ -467,7 +474,7 @@ server.add_global_handler('privmsg', on_privmsg)
server.add_global_handler('pubmsg', on_pubmsg)
# test
module = Module(config, server)
gt = GoogleTranslate(config, server)
# loop forever
irc.process_forever()