mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-08 18:44:06 +01:00
Added flushImmediately and [nolog] prefix.
This commit is contained in:
parent
59e5a6bc9f
commit
adc046a6a0
@ -1,3 +1,11 @@
|
|||||||
|
* Updated ChannelLogger not to log messages starting with
|
||||||
|
[nolog], in order to allow private information to remain private.
|
||||||
|
|
||||||
|
* Added a configuration variable to ChannelLogger,
|
||||||
|
flushImmediately, to cause all channel logs to be flushed every
|
||||||
|
time they're modified, for those people who like to read the logs
|
||||||
|
through tail -f or something similar.
|
||||||
|
|
||||||
* Updated WordStats to allow removing of tracked words.
|
* Updated WordStats to allow removing of tracked words.
|
||||||
|
|
||||||
* Updated Seen.seen to accept no arguments and return the last
|
* Updated Seen.seen to accept no arguments and return the last
|
||||||
|
@ -46,15 +46,25 @@ import world
|
|||||||
import irclib
|
import irclib
|
||||||
import ircmsgs
|
import ircmsgs
|
||||||
import ircutils
|
import ircutils
|
||||||
|
import registry
|
||||||
|
import callbacks
|
||||||
|
|
||||||
###
|
conf.registerPlugin('ChannelLogger')
|
||||||
# Logger: Handles logging of IRC channels to files.
|
conf.registerGlobalValue(conf.supybot.plugins.ChannelLogger,
|
||||||
###
|
'flushImmediately', registry.Boolean(False, """Determines whether channel
|
||||||
class ChannelLogger(irclib.IrcCallback):
|
logfiles will be flushed anytime they're written to, rather than being
|
||||||
logs = ircutils.IrcDict()
|
buffered by the operating system."""))
|
||||||
|
conf.registerChannelValue(conf.supybot.plugins.ChannelLogger, 'noLogPrefix',
|
||||||
|
registry.String('[nolog]', """Determines what string a message should be
|
||||||
|
prefixed with in order not to be logged. If you don't want any such
|
||||||
|
prefix, just set it to the empty string."""))
|
||||||
|
|
||||||
|
class ChannelLogger(callbacks.Privmsg):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.laststate = None
|
callbacks.Privmsg.__init__(self)
|
||||||
self.lastMsg = None
|
self.lastMsg = None
|
||||||
|
self.laststate = None
|
||||||
|
self.logs = ircutils.IrcDict()
|
||||||
world.flushers.append(self.flush)
|
world.flushers.append(self.flush)
|
||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
@ -104,31 +114,37 @@ class ChannelLogger(irclib.IrcCallback):
|
|||||||
log.write(time.strftime(conf.supybot.log.timestampFormat()))
|
log.write(time.strftime(conf.supybot.log.timestampFormat()))
|
||||||
log.write(' ')
|
log.write(' ')
|
||||||
|
|
||||||
|
def doLog(self, channel, s):
|
||||||
|
log = self.getLog(channel)
|
||||||
|
self.timestamp(log)
|
||||||
|
log.write(s)
|
||||||
|
if self.registryValue('flushImmediately'):
|
||||||
|
log.flush()
|
||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
(recipients, text) = msg.args
|
(recipients, text) = msg.args
|
||||||
for channel in recipients.split(','):
|
for channel in recipients.split(','):
|
||||||
|
noLogPrefix = self.registryValue('noLogPrefix', channel)
|
||||||
|
if noLogPrefix and text.startswith(noLogPrefix):
|
||||||
|
text = '-= THIS MESSAGE NOT LOGGED =-'
|
||||||
if ircutils.isChannel(channel):
|
if ircutils.isChannel(channel):
|
||||||
log = self.getLog(channel)
|
|
||||||
self.timestamp(log)
|
|
||||||
nick = msg.nick or irc.nick
|
nick = msg.nick or irc.nick
|
||||||
if ircmsgs.isAction(msg):
|
if ircmsgs.isAction(msg):
|
||||||
log.write('* %s %s\n' % (nick, ircmsgs.unAction(msg)))
|
self.doLog(channel,
|
||||||
|
'* %s %s\n' % (nick, ircmsgs.unAction(msg)))
|
||||||
else:
|
else:
|
||||||
log.write('<%s> %s\n' % (nick, text))
|
self.doLog(channel, '<%s> %s\n' % (nick, text))
|
||||||
|
|
||||||
def doNotice(self, irc, msg):
|
def doNotice(self, irc, msg):
|
||||||
(recipients, text) = msg.args
|
(recipients, text) = msg.args
|
||||||
for channel in recipients.split(','):
|
for channel in recipients.split(','):
|
||||||
if ircutils.isChannel(channel):
|
if ircutils.isChannel(channel):
|
||||||
log = self.getLog(channel)
|
self.doLog(channel, '-%s- %s\n' % (msg.nick, text))
|
||||||
self.timestamp(log)
|
|
||||||
log.write('-%s- %s\n' % (msg.nick, text))
|
|
||||||
|
|
||||||
def doJoin(self, irc, msg):
|
def doJoin(self, irc, msg):
|
||||||
for channel in msg.args[0].split(','):
|
for channel in msg.args[0].split(','):
|
||||||
log = self.getLog(channel)
|
self.doLog(channel,
|
||||||
self.timestamp(log)
|
'*** %s has joined %s\n' %
|
||||||
log.write('*** %s has joined %s\n' %
|
|
||||||
(msg.nick or msg.prefix, channel))
|
(msg.nick or msg.prefix, channel))
|
||||||
|
|
||||||
def doKick(self, irc, msg):
|
def doKick(self, irc, msg):
|
||||||
@ -137,26 +153,23 @@ class ChannelLogger(irclib.IrcCallback):
|
|||||||
else:
|
else:
|
||||||
(channel, target) = msg.args
|
(channel, target) = msg.args
|
||||||
kickmsg = ''
|
kickmsg = ''
|
||||||
log = self.getLog(channel)
|
|
||||||
self.timestamp(log)
|
|
||||||
if kickmsg:
|
if kickmsg:
|
||||||
log.write('*** %s was kicked by %s (%s)\n' %
|
self.doLog(channel,
|
||||||
|
'*** %s was kicked by %s (%s)\n' %
|
||||||
(target, msg.nick, kickmsg))
|
(target, msg.nick, kickmsg))
|
||||||
else:
|
else:
|
||||||
log.write('*** %s was kicked by %s\n' % (target, msg.nick))
|
self.doLog(channel,
|
||||||
|
'*** %s was kicked by %s\n' % (target, msg.nick))
|
||||||
|
|
||||||
def doPart(self, irc, msg):
|
def doPart(self, irc, msg):
|
||||||
for channel in msg.args[0].split(','):
|
for channel in msg.args[0].split(','):
|
||||||
log = self.getLog(channel)
|
self.doLog(channel, '*** %s has left %s\n' % (msg.nick, channel))
|
||||||
self.timestamp(log)
|
|
||||||
log.write('*** %s has left %s\n' % (msg.nick, channel))
|
|
||||||
|
|
||||||
def doMode(self, irc, msg):
|
def doMode(self, irc, msg):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
if ircutils.isChannel(channel) and msg.args[1:]:
|
if ircutils.isChannel(channel) and msg.args[1:]:
|
||||||
log = self.getLog(channel)
|
self.doLog(channel,
|
||||||
self.timestamp(log)
|
'*** %s sets mode: %s %s\n' %
|
||||||
log.write('*** %s sets mode: %s %s\n' %
|
|
||||||
(msg.nick or msg.prefix, msg.args[1],
|
(msg.nick or msg.prefix, msg.args[1],
|
||||||
' '.join(msg.args[2:])))
|
' '.join(msg.args[2:])))
|
||||||
|
|
||||||
@ -164,15 +177,13 @@ class ChannelLogger(irclib.IrcCallback):
|
|||||||
if len(msg.args) == 1:
|
if len(msg.args) == 1:
|
||||||
return # It's an empty TOPIC just to get the current topic.
|
return # It's an empty TOPIC just to get the current topic.
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
log = self.getLog(channel)
|
self.doLog(channel,
|
||||||
self.timestamp(log)
|
'*** %s changes topic to "%s"\n' % (msg.nick, msg.args[1]))
|
||||||
log.write('*** %s changes topic to "%s"\n' % (msg.nick, msg.args[1]))
|
|
||||||
|
|
||||||
def doQuit(self, irc, msg):
|
def doQuit(self, irc, msg):
|
||||||
for (channel, chan) in self.laststate.channels.iteritems():
|
for (channel, chan) in self.laststate.channels.iteritems():
|
||||||
if msg.nick in chan.users:
|
if msg.nick in chan.users:
|
||||||
log = self.getLog(channel)
|
self.doLog(channel, '*** %s has quit IRC\n' % msg.nick)
|
||||||
log.write('*** %s has quit IRC\n' % msg.nick)
|
|
||||||
|
|
||||||
def outFilter(self, irc, msg):
|
def outFilter(self, irc, msg):
|
||||||
# Gotta catch my own messages *somehow* :)
|
# Gotta catch my own messages *somehow* :)
|
||||||
|
Loading…
Reference in New Issue
Block a user