adds an on off config option for logging of joins parts and quits in ChannelLogger plugin

This commit is contained in:
resistivecorpse 2012-09-22 16:01:29 -04:00
parent 3a43229755
commit 54a6425e55
2 changed files with 21 additions and 16 deletions

View File

@ -48,6 +48,8 @@ conf.registerGlobalValue(ChannelLogger, 'flushImmediately',
registry.Boolean(False, _("""Determines whether channel logfiles will be registry.Boolean(False, _("""Determines whether channel logfiles will be
flushed anytime they're written to, rather than being buffered by the flushed anytime they're written to, rather than being buffered by the
operating system."""))) operating system.""")))
conf.registerChannelValue(ChannelLogger, 'showJoinParts',
registry.Boolean(True, _("""Determines wether joins and parts are logged""")))
conf.registerChannelValue(ChannelLogger, 'stripFormatting', conf.registerChannelValue(ChannelLogger, 'stripFormatting',
registry.Boolean(True, _("""Determines whether formatting characters (such registry.Boolean(True, _("""Determines whether formatting characters (such
as bolding, color, etc.) are removed when writing the logs to disk."""))) as bolding, color, etc.) are removed when writing the logs to disk.""")))

View File

@ -206,10 +206,11 @@ class ChannelLogger(callbacks.Plugin):
self.doLog(irc, channel, self.doLog(irc, channel,
'*** %s is now known as %s\n', oldNick, newNick) '*** %s is now known as %s\n', oldNick, newNick)
def doJoin(self, irc, msg): def doJoin(self, irc, msg):
for channel in msg.args[0].split(','): if(self.registryValue('showJoinParts', msg.args[0])):
self.doLog(irc, channel, for channel in msg.args[0].split(','):
'*** %s <%s> has joined %s\n', self.doLog(irc, channel,
msg.nick, msg.prefix, channel) '*** %s <%s> has joined %s\n',
msg.nick, msg.prefix, channel)
def doKick(self, irc, msg): def doKick(self, irc, msg):
if len(msg.args) == 3: if len(msg.args) == 3:
@ -226,14 +227,15 @@ class ChannelLogger(callbacks.Plugin):
'*** %s was kicked by %s\n', target, msg.nick) '*** %s was kicked by %s\n', target, msg.nick)
def doPart(self, irc, msg): def doPart(self, irc, msg):
if len(msg.args) > 1: if(self.registryValue('showJoinParts', msg.args[0])):
reason = " (%s)" % msg.args[1] if len(msg.args) > 1:
else: reason = " (%s)" % msg.args[1]
reason = "" else:
for channel in msg.args[0].split(','): reason = ""
self.doLog(irc, channel, for channel in msg.args[0].split(','):
'*** %s <%s> has left %s%s\n', self.doLog(irc, channel,
msg.nick, msg.prefix, channel, reason) '*** %s <%s> has left %s%s\n',
msg.nick, msg.prefix, channel, reason)
def doMode(self, irc, msg): def doMode(self, irc, msg):
channel = msg.args[0] channel = msg.args[0]
@ -258,10 +260,11 @@ class ChannelLogger(callbacks.Plugin):
if not isinstance(irc, irclib.Irc): if not isinstance(irc, irclib.Irc):
irc = irc.getRealIrc() irc = irc.getRealIrc()
for (channel, chan) in self.lastStates[irc].channels.iteritems(): for (channel, chan) in self.lastStates[irc].channels.iteritems():
if msg.nick in chan.users: if(self.registryValue('showJoinParts', msg.args[0])):
self.doLog(irc, channel, if msg.nick in chan.users:
'*** %s <%s> has quit IRC%s\n', self.doLog(irc, channel,
msg.nick, msg.prefix, reason) '*** %s <%s> has quit IRC%s\n',
msg.nick, msg.prefix, reason)
def outFilter(self, irc, msg): def outFilter(self, irc, msg):
# Gotta catch my own messages *somehow* :) # Gotta catch my own messages *somehow* :)