Variable name change, humanTimestampFormat => reply.format.time

This commit is contained in:
Jeremy Fincher 2004-12-10 06:21:53 +00:00
parent 595a787f8a
commit 0efb17dd81
13 changed files with 21 additions and 22 deletions

View File

@ -348,7 +348,7 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
counter = 0 counter = 0
for (added_by, added_at) in factoids: for (added_by, added_at) in factoids:
counter += 1 counter += 1
added_at = time.strftime(conf.supybot.humanTimestampFormat(), added_at = time.strftime(conf.supybot.reply.format.time(),
time.localtime(int(added_at))) time.localtime(int(added_at)))
L.append('#%s was added by %s at %s' % (counter,added_by,added_at)) L.append('#%s was added by %s at %s' % (counter,added_by,added_at))
factoids = '; '.join(L) factoids = '; '.join(L)

View File

@ -103,7 +103,7 @@ class Later(callbacks.Privmsg):
fd.close() fd.close()
def _timestamp(self, when): def _timestamp(self, when):
#format = conf.supybot.humanTimestampFormat() #format = conf.supybot.reply.format.time()
diff = time.time() - when diff = time.time() - when
try: try:
return utils.timeElapsed(diff, seconds=False) + ' ago' return utils.timeElapsed(diff, seconds=False) + ' ago'

View File

@ -496,19 +496,19 @@ class MoobotFactoids(callbacks.Privmsg):
# First, creation info. # First, creation info.
# Map the integer created_by to the username # Map the integer created_by to the username
creat_by = ircdb.users.getUser(created_by).name creat_by = ircdb.users.getUser(created_by).name
creat_at = time.strftime(conf.supybot.humanTimestampFormat(), creat_at = time.strftime(conf.supybot.reply.format.time(),
time.localtime(int(created_at))) time.localtime(int(created_at)))
s += "Created by %s on %s." % (creat_by, creat_at) s += "Created by %s on %s." % (creat_by, creat_at)
# Next, modification info, if any. # Next, modification info, if any.
if modified_by is not None: if modified_by is not None:
mod_by = ircdb.users.getUser(modified_by).name mod_by = ircdb.users.getUser(modified_by).name
mod_at = time.strftime(conf.supybot.humanTimestampFormat(), mod_at = time.strftime(conf.supybot.reply.format.time(),
time.localtime(int(modified_at))) time.localtime(int(modified_at)))
s += " Last modified by %s on %s." % (mod_by, mod_at) s += " Last modified by %s on %s." % (mod_by, mod_at)
# Next, last requested info, if any # Next, last requested info, if any
if last_requested_by is not None: if last_requested_by is not None:
last_by = last_requested_by # not an int user id last_by = last_requested_by # not an int user id
last_at = time.strftime(conf.supybot.humanTimestampFormat(), last_at = time.strftime(conf.supybot.reply.format.time(),
time.localtime(int(last_requested_at))) time.localtime(int(last_requested_at)))
req_count = requested_count req_count = requested_count
times_str = utils.nItems('time', requested_count) times_str = utils.nItems('time', requested_count)
@ -516,7 +516,7 @@ class MoobotFactoids(callbacks.Privmsg):
(last_by, last_at, times_str) (last_by, last_at, times_str)
# Last, locked info # Last, locked info
if locked_at is not None: if locked_at is not None:
lock_at = time.strftime(conf.supybot.humanTimestampFormat(), lock_at = time.strftime(conf.supybot.reply.format.time(),
time.localtime(int(locked_at))) time.localtime(int(locked_at)))
lock_by = ircdb.users.getUser(locked_by).name lock_by = ircdb.users.getUser(locked_by).name
s += " Locked by %s on %s." % (lock_by, lock_at) s += " Locked by %s on %s." % (lock_by, lock_at)

View File

@ -189,7 +189,7 @@ class Network(callbacks.Privmsg):
channels = utils.commaAndify(L) channels = utils.commaAndify(L)
if '317' in d: if '317' in d:
idle = utils.timeElapsed(d['317'].args[2]) idle = utils.timeElapsed(d['317'].args[2])
signon = time.strftime(conf.supybot.humanTimestampFormat(), signon = time.strftime(conf.supybot.reply.format.time(),
time.localtime(float(d['317'].args[3]))) time.localtime(float(d['317'].args[3])))
else: else:
idle = '<unknown>' idle = '<unknown>'

View File

@ -60,7 +60,7 @@ class DbiNewsDB(plugins.DbiChannelDB):
] ]
def __str__(self): def __str__(self):
format = conf.supybot.humanTimestampFormat() format = conf.supybot.reply.format.time()
user = plugins.getUserName(self.by) user = plugins.getUserName(self.by)
if self.expires == 0: if self.expires == 0:
s = '%s (Subject: "%s", added by %s on %s)' % \ s = '%s (Subject: "%s", added by %s on %s)' % \

View File

@ -70,7 +70,7 @@ class PollRecord(dbi.Record):
'status' 'status'
] ]
def __str__(self): def __str__(self):
format = conf.supybot.humanTimestampFormat() format = conf.supybot.reply.format.time()
user = plugins.getUserName(self.by) user = plugins.getUserName(self.by)
if self.options: if self.options:
options = 'Options: %s' % '; '.join(map(str, self.options)) options = 'Options: %s' % '; '.join(map(str, self.options))

View File

@ -83,7 +83,7 @@ class QuoteGrabsRecord(dbi.Record):
] ]
def __str__(self): def __str__(self):
at = time.strftime(conf.supybot.humanTimestampFormat(), at = time.strftime(conf.supybot.reply.format.time(),
time.localtime(float(self.at))) time.localtime(float(self.at)))
grabber = plugins.getUserName(self.grabber) grabber = plugins.getUserName(self.grabber)
return '%s (Said by: %s; grabbed by %s at %s)' % \ return '%s (Said by: %s; grabbed by %s at %s)' % \

View File

@ -62,7 +62,7 @@ class QuoteRecord(dbi.Record):
'text' 'text'
] ]
def __str__(self): def __str__(self):
format = conf.supybot.humanTimestampFormat() format = conf.supybot.reply.format.time()
user = plugins.getUserName(self.by) user = plugins.getUserName(self.by)
return 'Quote %s added by %s at %s.' % \ return 'Quote %s added by %s at %s.' % \
(utils.quoted(self.text), user, (utils.quoted(self.text), user,

View File

@ -288,7 +288,7 @@ class Relay(callbacks.Privmsg):
channels = utils.commaAndify(L) channels = utils.commaAndify(L)
if '317' in d: if '317' in d:
idle = utils.timeElapsed(d['317'].args[2]) idle = utils.timeElapsed(d['317'].args[2])
signon = time.strftime(conf.supybot.humanTimestampFormat(), signon = time.strftime(conf.supybot.reply.format.time(),
time.localtime(float(d['317'].args[3]))) time.localtime(float(d['317'].args[3])))
else: else:
idle = '<unknown>' idle = '<unknown>'

View File

@ -62,7 +62,7 @@ def configure(advanced):
conf.registerPlugin('Time') conf.registerPlugin('Time')
conf.registerChannelValue(conf.supybot.plugins.Time, 'format', conf.registerChannelValue(conf.supybot.plugins.Time, 'format',
registry.String(str(conf.supybot.humanTimestampFormat()), """Determines the registry.String(str(conf.supybot.reply.format.time()), """Determines the
format string for timestamps. Refer to the Python documentation for the format string for timestamps. Refer to the Python documentation for the
time module to see what formats are accepted. If you set this variable to time module to see what formats are accepted. If you set this variable to
the empty string, the timestamp will not be shown.""")) the empty string, the timestamp will not be shown."""))

View File

@ -163,7 +163,7 @@ class Todo(callbacks.Privmsg):
active = 'Inactive' active = 'Inactive'
if pri: if pri:
task += ', priority: %s' % pri task += ', priority: %s' % pri
added_at = time.strftime(conf.supybot.humanTimestampFormat(), added_at = time.strftime(conf.supybot.reply.format.time(),
time.localtime(int(added_at))) time.localtime(int(added_at)))
s = "%s todo for %s: %s (Added at %s)" % \ s = "%s todo for %s: %s (Added at %s)" % \
(active, name, task, added_at) (active, name, task, added_at)

View File

@ -480,7 +480,7 @@ class ChannelIdDatabasePlugin(callbacks.Privmsg):
def showRecord(self, record): def showRecord(self, record):
name = getUserName(record.by) name = getUserName(record.by)
at = time.localtime(record.at) at = time.localtime(record.at)
timeS = time.strftime(conf.supybot.humanTimestampFormat(), at) timeS = time.strftime(conf.supybot.reply.format.time(), at)
return '%s #%s: %s (added by %s at %s)' % \ return '%s #%s: %s (added by %s at %s)' % \
(self.name(), record.id, utils.quoted(record.text), name, timeS) (self.name(), record.id, utils.quoted(record.text), name, timeS)

View File

@ -274,7 +274,12 @@ for (name, s) in registry._cache.iteritems():
registerGroup(supybot, 'reply') registerGroup(supybot, 'reply')
registerGroup(supybot.reply, 'format') registerGroup(supybot.reply, 'format')
registerGroup(supybot.reply.format, 'time') registerChannelValue(supybot.reply.format, 'time',
registry.String('%I:%M %p, %B %d, %Y', """Determines how timestamps printed
for human reading should be formatted. Refer to the Python documentation
for the time module to see valid formatting characters for time
formats."""))
registerGroup(supybot.reply.format.time, 'elapsed') registerGroup(supybot.reply.format.time, 'elapsed')
registerChannelValue(supybot.reply.format.time.elapsed, 'short', registerChannelValue(supybot.reply.format.time.elapsed, 'short',
registry.Boolean(False, """Determines whether elapsed times will be given registry.Boolean(False, """Determines whether elapsed times will be given
@ -910,12 +915,6 @@ registerGlobalValue(supybot, 'defaultIgnore',
hard for those users to register or identify with the bot, but that's your hard for those users to register or identify with the bot, but that's your
problem to solve.""")) problem to solve."""))
registerChannelValue(supybot, 'humanTimestampFormat',
registry.String('%I:%M %p, %B %d, %Y', """Determines how timestamps printed
for human reading should be formatted. Refer to the Python documentation
for the time module to see valid formatting characters for time
formats."""))
class IP(registry.String): class IP(registry.String):
"""Value must be a valid IP.""" """Value must be a valid IP."""
def setValue(self, v): def setValue(self, v):