DrBotIRC: remove connection argument from reply()

we only have one connection, we don't need to be told what to reply to
This commit is contained in:
Brian S. Stephan 2012-12-19 20:32:18 -06:00
parent 456671615b
commit e4225abba4
1 changed files with 8 additions and 9 deletions

View File

@ -390,25 +390,25 @@ class DrBotIRC(irclib.IRC):
self.config.set('Alias', whats[2], ' '.join(whats[3:])) self.config.set('Alias', whats[2], ' '.join(whats[3:]))
replystr = "Added alias '{0:s}'.".format(whats[2]) replystr = "Added alias '{0:s}'.".format(whats[2])
return self.reply(connection, event, replystr) return self.reply(event, replystr)
if whats[0] == '!alias' and whats[1] == 'remove' and len(whats) >= 3: if whats[0] == '!alias' and whats[1] == 'remove' and len(whats) >= 3:
if not self.config.has_section('Alias'): if not self.config.has_section('Alias'):
self.config.add_section('Alias') self.config.add_section('Alias')
if self.config.remove_option('Alias', whats[2]): if self.config.remove_option('Alias', whats[2]):
replystr = "Removed alias '{0:s}'.".format(whats[2]) replystr = "Removed alias '{0:s}'.".format(whats[2])
return self.reply(connection, event, replystr) return self.reply(event, replystr)
elif whats[0] == '!alias' and whats[1] == 'list': elif whats[0] == '!alias' and whats[1] == 'list':
try: try:
if len(whats) > 2: if len(whats) > 2:
alias = self.config.get('Alias', whats[2]) alias = self.config.get('Alias', whats[2])
return self.reply(connection, event, alias) return self.reply(event, alias)
else: else:
alist = self.config.options('Alias') alist = self.config.options('Alias')
alist.remove('debug') alist.remove('debug')
alist.sort() alist.sort()
liststr = ', '.join(alist) liststr = ', '.join(alist)
return self.reply(connection, event, liststr) return self.reply(event, liststr)
except NoSectionError: pass except NoSectionError: pass
except NoOptionError: pass except NoOptionError: pass
except NoSectionError: pass except NoSectionError: pass
@ -524,11 +524,10 @@ class DrBotIRC(irclib.IRC):
log.info("Bot shutting down.") log.info("Bot shutting down.")
sys.exit() sys.exit()
def reply(self, connection, event, replystr, stop=False): def reply(self, event, replystr, stop=False):
"""Reply over IRC to replypath or return a string with the reply. """Reply over IRC to replypath or return a string with the reply.
Args: Args:
connection source connection
event incoming event event incoming event
replystr the message to reply with replystr the message to reply with
stop whether or not to let other handlers see this stop whether or not to let other handlers see this
@ -541,8 +540,8 @@ class DrBotIRC(irclib.IRC):
replypath = event.target() replypath = event.target()
# check for privmsg # if this is a privmsg, reply to the sender
if replypath == connection.get_nickname(): if replypath == self.server.get_nickname():
replypath = irclib.nm_to_n(event.source()) replypath = irclib.nm_to_n(event.source())
if replystr is not None: if replystr is not None:
@ -551,7 +550,7 @@ class DrBotIRC(irclib.IRC):
else: else:
replies = replystr.split('\n') replies = replystr.split('\n')
for reply in replies: for reply in replies:
connection.privmsg(replypath, reply) self.server.privmsg(replypath, reply)
if stop: if stop:
return "NO MORE" return "NO MORE"