Merge pull request #1107 from GLolol/format-whois

formatWhois: fix errors and restore formatting changes lost in supybot merge
This commit is contained in:
Valentin Lorentz 2015-05-16 12:44:49 +02:00
commit 7cc7ad886f

View File

@ -427,24 +427,24 @@ def formatWhois(irc, replies, caller='', channel='', command='whois'):
# The user is in a channel the bot is in, so the ircd may have # The user is in a channel the bot is in, so the ircd may have
# responded with otherwise private data. # responded with otherwise private data.
if chanState: if chanState:
# Skip channels the callee isn't in. This helps prevents # Skip channels the caller isn't in. This prevents
# us leaking information when the channel is +s or the # us from leaking information when the channel is +s or the
# target is +i # target is +i.
if caller not in chanState.users: if caller not in chanState.users:
continue continue
# Skip +s channels the target is in only if the reply isn't # Skip +s channels the target is in only if the reply isn't
# being sent to that channel # being sent to that channel.
if 's' in chanState.modes and \ if 's' in chanState.modes and \
not ircutils.strEqual(channel or '', chan): not strEqual(channel or '', chan):
continue continue
if not modes: if not modes:
normal.append(chan) normal.append(chan)
elif utils.iter.any(lambda c: c in modes,('@', '&', '~', '!')): elif utils.iter.any(lambda c: c in modes,('@', '&', '~', '!')):
ops.append(chan[1:]) ops.append(chan)
elif utils.iter.any(lambda c: c in modes, ('%',)): elif utils.iter.any(lambda c: c in modes, ('%',)):
halfops.append(chan[1:]) halfops.append(chan)
elif utils.iter.any(lambda c: c in modes, ('+',)): elif utils.iter.any(lambda c: c in modes, ('+',)):
voices.append(chan[1:]) voices.append(chan)
L = [] L = []
if ops: if ops:
L.append(format(_('is an op on %L'), ops)) L.append(format(_('is an op on %L'), ops))
@ -459,7 +459,7 @@ def formatWhois(irc, replies, caller='', channel='', command='whois'):
L.append(format(_('is on %L'), normal)) L.append(format(_('is on %L'), normal))
else: else:
if command == 'whois': if command == 'whois':
L = [_('isn\'t on any non-secret channels')] L = [_('isn\'t on any publicly visible channels')]
else: else:
L = [] L = []
channels = format('%L', L) channels = format('%L', L)
@ -476,7 +476,7 @@ def formatWhois(irc, replies, caller='', channel='', command='whois'):
else: else:
server = '<unknown>' server = '<unknown>'
if '301' in replies: if '301' in replies:
away = ' %s is away: %s.' % (nick, replies['301'].args[2]) away = ' %s is away: %s.' % (nick, replies['301'].args[2])
else: else:
away = '' away = ''
if '320' in replies: if '320' in replies:
@ -487,11 +487,11 @@ def formatWhois(irc, replies, caller='', channel='', command='whois'):
else: else:
identify = '' identify = ''
if command == 'whois': if command == 'whois':
s = _('%s (%s) has been%s on server %s since %s (idle for %s) and ' s = _('%s (%s) has been%s on server %s since %s (idle for %s). %s '
'%s.%s') % (user, hostmask, identify, server, '%s.%s') % (user, hostmask, identify, server,
signon, idle, channels, away) signon, idle, nick, channels, away)
else: else:
s = _('%s (%s) has been%s on server %s and disconnect on %s.') % \ s = _('%s (%s) has been%s on server %s and disconnected on %s.') % \
(user, hostmask, identify, server, signoff) (user, hostmask, identify, server, signoff)
return s return s