mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Seen: Add supybot.plugins.Seen.showLastMessage.
This commit is contained in:
parent
1bee83bc2e
commit
243cc0b998
@ -49,6 +49,10 @@ conf.registerChannelValue(Seen, 'minimumNonWildcard',
|
|||||||
registry.NonNegativeInteger(2, _("""The minimum non-wildcard characters
|
registry.NonNegativeInteger(2, _("""The minimum non-wildcard characters
|
||||||
required to perform a 'seen' request. Of course, it only applies if there
|
required to perform a 'seen' request. Of course, it only applies if there
|
||||||
is a wildcard in the request.""")))
|
is a wildcard in the request.""")))
|
||||||
|
conf.registerChannelValue(Seen, 'showLastMessage',
|
||||||
|
registry.Boolean(True, _("""Determines whether the last message will
|
||||||
|
be displayed with @seen. Useful for keeping messages from a channel
|
||||||
|
private.""")))
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
@ -202,9 +202,12 @@ class Seen(callbacks.Plugin):
|
|||||||
if len(results) == 1:
|
if len(results) == 1:
|
||||||
(nick, info) = results[0]
|
(nick, info) = results[0]
|
||||||
(when, said) = info
|
(when, said) = info
|
||||||
irc.reply(format(_('%s was last seen in %s %s ago: %s'),
|
reply = format(_('%s was last seen in %s %s ago'),
|
||||||
nick, channel,
|
nick, channel,
|
||||||
utils.timeElapsed(time.time()-when), said))
|
utils.timeElapsed(time.time()-when))
|
||||||
|
if self.registryValue('showLastMessage', channel):
|
||||||
|
reply = _('%s: %s') % (reply, said)
|
||||||
|
irc.reply(reply)
|
||||||
elif len(results) > 1:
|
elif len(results) > 1:
|
||||||
L = []
|
L = []
|
||||||
for (nick, info) in results:
|
for (nick, info) in results:
|
||||||
@ -266,9 +269,11 @@ class Seen(callbacks.Plugin):
|
|||||||
db = self.db
|
db = self.db
|
||||||
try:
|
try:
|
||||||
(when, said) = db.seen(channel, '<last>')
|
(when, said) = db.seen(channel, '<last>')
|
||||||
irc.reply(format(_('Someone was last seen in %s %s ago: %s'),
|
reply = format(_('Someone was last seen in %s %s ago'),
|
||||||
channel, utils.timeElapsed(time.time()-when),
|
channel, utils.timeElapsed(time.time()-when))
|
||||||
said))
|
if self.registryValue('showLastMessage', channel):
|
||||||
|
reply = _('%s: %s') % (reply, said)
|
||||||
|
irc.reply(reply)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.reply(_('I have never seen anyone.'))
|
irc.reply(_('I have never seen anyone.'))
|
||||||
|
|
||||||
@ -292,9 +297,12 @@ class Seen(callbacks.Plugin):
|
|||||||
db = self.db
|
db = self.db
|
||||||
try:
|
try:
|
||||||
(when, said) = db.seen(channel, user.id)
|
(when, said) = db.seen(channel, user.id)
|
||||||
irc.reply(format(_('%s was last seen in %s %s ago: %s'),
|
reply = format(_('%s was last seen in %s %s ago'),
|
||||||
user.name, channel,
|
user.name, channel,
|
||||||
utils.timeElapsed(time.time()-when), said))
|
utils.timeElapsed(time.time()-when))
|
||||||
|
if self.registryValue('showLastMessage', channel):
|
||||||
|
reply = _('%s: %s') % (reply, said)
|
||||||
|
irc.reply(reply)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
irc.reply(format(_('I have not seen %s.'), user.name))
|
irc.reply(format(_('I have not seen %s.'), user.name))
|
||||||
|
|
||||||
|
@ -59,7 +59,10 @@ class ChannelDBTestCase(ChannelPluginTestCase):
|
|||||||
self.irc.feedMsg(ircmsgs.mode(self.channel, args=('+o', self.nick),
|
self.irc.feedMsg(ircmsgs.mode(self.channel, args=('+o', self.nick),
|
||||||
prefix=self.prefix))
|
prefix=self.prefix))
|
||||||
self.assertRegexp('seen any %s' % self.nick,
|
self.assertRegexp('seen any %s' % self.nick,
|
||||||
'^%s was last seen' % self.nick)
|
'^%s was last seen.*:' % self.nick)
|
||||||
|
with conf.supybot.plugins.seen.showLastMessage.context(False):
|
||||||
|
self.assertRegexp('seen any %s' % self.nick,
|
||||||
|
'^%s was last seen[^:]*' % self.nick)
|
||||||
|
|
||||||
def testSeen(self):
|
def testSeen(self):
|
||||||
self.irc.feedMsg(ircmsgs.join(self.channel, self.irc.nick,
|
self.irc.feedMsg(ircmsgs.join(self.channel, self.irc.nick,
|
||||||
|
Loading…
Reference in New Issue
Block a user