mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Renamed conf.timestampFormat to conf.logTimestampFormat and added conf.humanTimestampFormat.
This commit is contained in:
parent
23321ca960
commit
5289f6bc75
@ -81,7 +81,7 @@ class ChannelLogger(irclib.IrcCallback):
|
||||
return StringIO()
|
||||
|
||||
def timestamp(self, log):
|
||||
log.write(time.strftime(conf.timestampFormat))
|
||||
log.write(time.strftime(conf.logTimestampFormat))
|
||||
log.write(' ')
|
||||
|
||||
def doPrivmsg(self, irc, msg):
|
||||
|
@ -218,7 +218,7 @@ class Factoids(ChannelDBHandler, callbacks.Privmsg):
|
||||
L = []
|
||||
counter = 0
|
||||
for (added_by, added_at) in factoids:
|
||||
added_at = time.strftime(conf.timestampFormat,
|
||||
added_at = time.strftime(conf.humanTimestampFormat,
|
||||
time.localtime(int(added_at)))
|
||||
L.append('#%s was added by %s at %s' % (counter,added_by,added_at))
|
||||
counter += 1
|
||||
|
@ -158,10 +158,12 @@ class Quotes(ChannelDBHandler, callbacks.Privmsg):
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("""SELECT * FROM quotes WHERE id=%s""", id)
|
||||
row = cursor.fetchone()
|
||||
(id, added_by, added_at, quote) = cursor.fetchone()
|
||||
if row:
|
||||
timestamp = time.strftime(conf.humanTimestampFormat,
|
||||
time.localtime(int(added_at)))
|
||||
irc.reply(msg, 'Quote %r added by %s at %s.' % \
|
||||
(row.quote, row.added_by, time.strftime(conf.timestampFormat)))
|
||||
(quote, added_by, timestamp)
|
||||
return
|
||||
else:
|
||||
irc.reply(msg, 'There isn\'t a quote with that id.')
|
||||
|
@ -337,7 +337,8 @@ class Relay(callbacks.Privmsg):
|
||||
channels = utils.commaAndify(channels)
|
||||
if '317' in d:
|
||||
idle = utils.timeElapsed(d['317'].args[2])
|
||||
signon = time.ctime(float(d['317'].args[3]))
|
||||
signon = time.strftime(conf.humanTimestampFormat,
|
||||
time.localtime(float(d['317'].args[3])))
|
||||
else:
|
||||
idle = '<unknown>'
|
||||
signon = '<unknown>'
|
||||
|
@ -122,7 +122,8 @@ class URLSnarfer(callbacks.Privmsg, ChannelDBHandler):
|
||||
cursor = db.cursor()
|
||||
cursor.execute("""SELECT * FROM urls ORDER BY random() LIMIT 1""")
|
||||
(id, url, added, addedBy, _, _, _, _, _, _) = cursor.fetchone()
|
||||
when = time.ctime(int(added))
|
||||
when = time.strftime(conf.humanTimestampFormat,
|
||||
time.localtime(int(added)))
|
||||
s = '%s: <%s> (added by %s on %s)' % (id, url, addedBy, when)
|
||||
irc.reply(msg, s)
|
||||
|
||||
@ -180,13 +181,18 @@ class URLSnarfer(callbacks.Privmsg, ChannelDBHandler):
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
criterion = ' AND '.join(criteria)
|
||||
sql = 'SELECT url FROM urls WHERE %s ORDER BY id DESC' % criterion
|
||||
sql = """SELECT url, added, added_by
|
||||
FROM urls
|
||||
WHERE %s ORDER BY id DESC""" % criterion
|
||||
cursor.execute(sql, *formats)
|
||||
if cursor.rowcount == 0:
|
||||
irc.reply(msg, 'No URLs matched that criteria.')
|
||||
else:
|
||||
(url,) = cursor.fetchone()
|
||||
irc.reply(msg, url)
|
||||
(url, added, added_by) = cursor.fetchone()
|
||||
timestamp = time.strftime('%I:%M %p, %B %d, %Y',
|
||||
time.localtime(int(added)))
|
||||
s = '<%s>, added by %s at %s.' % (url, added_by, timestamp)
|
||||
irc.reply(msg, s)
|
||||
|
||||
|
||||
Class = URLSnarfer
|
||||
|
@ -75,7 +75,7 @@ class AsyncoreDriver(asynchat.async_chat, object):
|
||||
|
||||
def scheduleReconnect(self):
|
||||
when = time.time() + 60
|
||||
whenS = time.strftime(conf.timestampFormat, time.localtime(when))
|
||||
whenS = time.strftime(conf.logTimestampFormat, time.localtime(when))
|
||||
debug.msg('Scheduling reconnect at %s' % whenS, 'normal')
|
||||
def makeNewDriver():
|
||||
self.irc.reset()
|
||||
|
16
src/conf.py
16
src/conf.py
@ -57,11 +57,19 @@ ignoresfile = os.path.join(confDir, 'ignores.conf')
|
||||
rawlogfile = os.path.join(logDir, 'raw.log')
|
||||
|
||||
###
|
||||
# timestampFormat: A format string defining how timestamps should be. Check
|
||||
# the Python library reference for the "time" module to see
|
||||
# what the various format specifiers mean.
|
||||
# logTimestampFormat: A format string defining how timestamps should be. Check
|
||||
# the Python library reference for the "time" module to see
|
||||
# what the various format specifiers mean.
|
||||
###
|
||||
timestampFormat = '[%d-%b-%Y %H:%M:%S]'
|
||||
logTimestampFormat = '[%d-%b-%Y %H:%M:%S]'
|
||||
|
||||
###
|
||||
# humanTimestampFormat: A format string defining how timestamps should be
|
||||
# formatted for human consumption. Check the Python
|
||||
# library reference for the "time" module to see what the
|
||||
# various format specifiers mean.
|
||||
###
|
||||
humanTimestampFormat = '%I:%M %p, %B %d, %Y'
|
||||
|
||||
###
|
||||
# throttleTime: A floating point number of seconds to throttle queued messages.
|
||||
|
@ -423,7 +423,7 @@ class Irc(object):
|
||||
debug.msg(s)
|
||||
return None
|
||||
self.state.addMsg(self,ircmsgs.IrcMsg(msg=msg, prefix=self.prefix))
|
||||
s = '%s %s' % (time.strftime(conf.timestampFormat), msg)
|
||||
s = '%s %s' % (time.strftime(conf.logTimestampFormat), msg)
|
||||
debug.msg(s, 'low')
|
||||
if msg.command == 'NICK':
|
||||
# We don't want a race condition where the server's NICK
|
||||
@ -438,7 +438,7 @@ class Irc(object):
|
||||
return None
|
||||
|
||||
def feedMsg(self, msg):
|
||||
debug.msg('%s %s' % (time.strftime(conf.timestampFormat), msg), 'low')
|
||||
debug.msg('%s %s'%(time.strftime(conf.logTimestampFormat), msg),'low')
|
||||
# Yeah, so this is odd. Some networks (oftc) seem to give us certain
|
||||
# messages with our nick instead of our prefix. We'll fix that here.
|
||||
if msg.prefix == self.nick:
|
||||
|
@ -88,7 +88,7 @@ def upkeep(): # Function to be run on occasion to do upkeep stuff.
|
||||
debug.msg('Uncollectable garbage: %s' % gc.garbage, 'normal')
|
||||
if 'noflush' not in tempvars:
|
||||
flush()
|
||||
msg = '%s upkeep ran.' % time.strftime(conf.timestampFormat)
|
||||
msg = '%s upkeep ran.' % time.strftime(conf.logTimestampFormat)
|
||||
debug.msg(msg, 'verbose')
|
||||
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user