now that we have meta.strip_bot_name_from_input there is no need to overload on_pubmsg

This commit is contained in:
Brian S. Stephan 2010-09-08 19:51:18 -05:00
parent 338c1e759f
commit 3e91000acc
1 changed files with 0 additions and 48 deletions

View File

@ -47,54 +47,6 @@ class MegaHAL(Module):
def reload(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
"""Broken. Don't do anything."""
def on_pubmsg(self, connection, event):
"""
Handle pubmsg events. Does some variable setup and initial sanity checking before
calling Module.do, which should be implemented by subclasses and what can be
ultimately responsible for the work.
"""
nick = irclib.nm_to_n(event.source())
userhost = irclib.nm_to_uh(event.source())
replypath = event.target()
what = event.arguments()[0]
admin_unlocked = False
try:
if userhost == self.config.get('dr.botzo', 'admin_userhost'):
admin_unlocked = True
except NoOptionError: pass
# only do commands if the bot has been addressed directly
addressed_pattern = '^' + connection.get_nickname() + '[:,]?\s+'
addressed_re = re.compile(addressed_pattern)
need_prefix = True
try:
need_prefix = self.config.getboolean(self.__class__.__name__, 'meta.pubmsg_needs_bot_prefix')
except NoOptionError: pass
except NoSectionError: pass
re_add_nick = False
if not addressed_re.match(what) and need_prefix:
return
else:
if addressed_re.match(what):
re_add_nick = True
what = addressed_re.sub('', what)
if replypath is not None:
what = self.try_recursion(connection, event, nick, userhost, replypath, what, admin_unlocked)
# try reloading
self.reload(connection, event, nick, userhost, replypath, what, admin_unlocked)
if re_add_nick:
self.do(connection, event, nick, userhost, replypath, connection.get_nickname() + ": " + what, admin_unlocked)
else:
self.do(connection, event, nick, userhost, replypath, what, admin_unlocked)
def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
"""
Say something on IRC if the bot is being addressed, or at least learn what