mirror of https://github.com/Mikaela/Limnoria.git
Added getUserName.
This commit is contained in:
parent
2a0b9e645d
commit
f7a3504a93
|
@ -61,21 +61,16 @@ class DbiNewsDB(plugins.DbiChannelDB):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
format = conf.supybot.humanTimestampFormat()
|
format = conf.supybot.humanTimestampFormat()
|
||||||
try:
|
user = plugins.getUserName(self.by)
|
||||||
user = ircdb.users.getUser(int(self.by)).name
|
if self.expires == 0:
|
||||||
except ValueError:
|
|
||||||
user = self.by
|
|
||||||
except KeyError:
|
|
||||||
user = 'a user that is no longer registered'
|
|
||||||
if int(self.expires) == 0:
|
|
||||||
s = '%s (Subject: "%s", added by %s on %s)' % \
|
s = '%s (Subject: "%s", added by %s on %s)' % \
|
||||||
(self.text, self.subject, self.by,
|
(self.text, self.subject, self.by,
|
||||||
time.strftime(format, time.localtime(int(self.at))))
|
time.strftime(format, time.localtime(self.at)))
|
||||||
else:
|
else:
|
||||||
s = '%s (Subject: "%s", added by %s on %s, expires at %s)'
|
s = '%s (Subject: "%s", added by %s on %s, expires at %s)'
|
||||||
s = s % (self.text, self.subject, user,
|
s = s % (self.text, self.subject, user,
|
||||||
time.strftime(format, time.localtime(int(self.at))),
|
time.strftime(format, time.localtime(self.at)),
|
||||||
time.strftime(format, time.localtime(int(self.expires))))
|
time.strftime(format, time.localtime(self.expires)))
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
|
|
|
@ -71,12 +71,9 @@ class PollRecord(dbi.Record):
|
||||||
]
|
]
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
format = conf.supybot.humanTimestampFormat()
|
format = conf.supybot.humanTimestampFormat()
|
||||||
try:
|
user = plugins.getUserName(self.by)
|
||||||
user = ircdb.users.getUser(int(self.by)).name
|
|
||||||
except KeyError:
|
|
||||||
user = 'a user that is no longer registered'
|
|
||||||
if self.options:
|
if self.options:
|
||||||
options = 'Options: %s' % '; '.join(map(str, self.options))
|
options = 'Options: %s' % '; '.join(self.options)
|
||||||
else:
|
else:
|
||||||
options = 'The poll has no options, yet'
|
options = 'The poll has no options, yet'
|
||||||
if self.status:
|
if self.status:
|
||||||
|
@ -84,8 +81,7 @@ class PollRecord(dbi.Record):
|
||||||
else:
|
else:
|
||||||
status = 'closed'
|
status = 'closed'
|
||||||
return 'Poll #%s: %s started by %s. %s. Poll is %s.' % \
|
return 'Poll #%s: %s started by %s. %s. Poll is %s.' % \
|
||||||
(self.id, utils.quoted(self.question), user,
|
(self.id, utils.quoted(self.question), user, options, status)
|
||||||
options, status)
|
|
||||||
|
|
||||||
class SqlitePollDB(object):
|
class SqlitePollDB(object):
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
|
|
|
@ -63,12 +63,7 @@ class QuoteRecord(dbi.Record):
|
||||||
]
|
]
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
format = conf.supybot.humanTimestampFormat()
|
format = conf.supybot.humanTimestampFormat()
|
||||||
try:
|
user = plugins.getUserName(self.by)
|
||||||
user = ircdb.users.getUser(int(self.by)).name
|
|
||||||
except ValueError:
|
|
||||||
user = self.by
|
|
||||||
except KeyError:
|
|
||||||
user = 'a user that is no longer registered'
|
|
||||||
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,
|
||||||
time.strftime(format, time.localtime(float(self.at))))
|
time.strftime(format, time.localtime(float(self.at))))
|
||||||
|
|
|
@ -355,6 +355,15 @@ class ChannelUserDB(ChannelUserDictionary):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
|
def getUserName(id):
|
||||||
|
if isinstance(id, int):
|
||||||
|
try:
|
||||||
|
return ircdb.users.getUser(id).name
|
||||||
|
except KeyError:
|
||||||
|
return 'a user that is no longer registered'
|
||||||
|
else:
|
||||||
|
return id
|
||||||
|
|
||||||
class ChannelIdDatabasePlugin(callbacks.Privmsg):
|
class ChannelIdDatabasePlugin(callbacks.Privmsg):
|
||||||
class DB(DbiChannelDB):
|
class DB(DbiChannelDB):
|
||||||
class DB(dbi.DB):
|
class DB(dbi.DB):
|
||||||
|
@ -470,10 +479,7 @@ class ChannelIdDatabasePlugin(callbacks.Privmsg):
|
||||||
additional(rest('glob'))])
|
additional(rest('glob'))])
|
||||||
|
|
||||||
def showRecord(self, record):
|
def showRecord(self, record):
|
||||||
try:
|
name = getUserName(record.by)
|
||||||
name = ircdb.users.getUser(record.by).name
|
|
||||||
except KeyError:
|
|
||||||
name = 'a user that is no longer registered'
|
|
||||||
at = time.localtime(record.at)
|
at = time.localtime(record.at)
|
||||||
timeS = time.strftime(conf.supybot.humanTimestampFormat(), at)
|
timeS = time.strftime(conf.supybot.humanTimestampFormat(), at)
|
||||||
return '%s #%s: %s (added by %s at %s)' % \
|
return '%s #%s: %s (added by %s at %s)' % \
|
||||||
|
|
Loading…
Reference in New Issue