Later: Add option senderHostname.

This commit is contained in:
Valentin Lorentz 2019-03-06 15:29:09 +01:00
parent 71dbd39dd7
commit 6b213f0686
3 changed files with 21 additions and 3 deletions

View File

@ -56,4 +56,9 @@ conf.registerGlobalValue(Later, 'messageExpiry',
days that a message will remain queued for a user. After this time elapses,
the message will be deleted. If this value is 0, there is no maximum.""")))
conf.registerGroup(Later, 'format')
conf.registerGlobalValue(Later.format, 'senderHostname',
registry.Boolean(False, _("""Determines whether senders' hostname will be
shown in messages (instead of just the nick).""")))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -150,7 +150,7 @@ class Later(callbacks.Plugin):
full_queues = []
for validnick in validnicks:
try:
self._addNote(validnick, msg.nick, text)
self._addNote(validnick, msg.prefix, text)
except QueueIsFull:
full_queues.append(validnick)
if full_queues:
@ -210,7 +210,7 @@ class Later(callbacks.Plugin):
return
self._notes[nick].reverse()
for note in self._notes[nick]:
if note[1] == msg.nick:
if ircutils.nickFromHostmask(note[1]) == msg.nick:
self._notes[nick].remove(note)
if len(self._notes[nick]) == 0:
del self._notes[nick]
@ -243,6 +243,8 @@ class Later(callbacks.Plugin):
msg.tag('repliedTo', old_repliedto)
def _formatNote(self, when, whence, note):
if not self.registryValue('format.senderHostname'):
whence = ircutils.nickFromHostmask(whence)
return _('Sent %s: <%s> %s') % (self._timestamp(when), whence, note)
def doJoin(self, irc, msg):

View File

@ -28,6 +28,7 @@
###
from supybot.test import *
import supybot.conf as conf
import time
class LaterTestCase(ChannelPluginTestCase):
@ -126,6 +127,16 @@ class LaterTestCase(ChannelPluginTestCase):
self.assertEqual(str(m).strip(),
'PRIVMSG #test :bar: Sent 1 minute ago: <test> more stuff')
time.time = real_time
def testSenderHostname(self):
self.assertNotError('later tell foo stuff')
testPrefix = 'foo!bar@baz'
with conf.supybot.plugins.Later.format.senderHostname.context(True):
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'something',
prefix=testPrefix))
m = self.getMsg(' ')
self.assertEqual(str(m).strip(),
'PRIVMSG #test :foo: Sent just now: <%s> stuff' % self.prefix)
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: