mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-17 14:10:41 +01:00
Added more color to reduce collisions; robustified relaywhois.
This commit is contained in:
parent
d81c1be4f2
commit
ad432a640a
@ -243,7 +243,10 @@ class Relay(callbacks.Privmsg):
|
|||||||
Returns the WHOIS response <network> gives for <nick>.
|
Returns the WHOIS response <network> gives for <nick>.
|
||||||
"""
|
"""
|
||||||
nickAtNetwork = privmsgs.getArgs(args)
|
nickAtNetwork = privmsgs.getArgs(args)
|
||||||
(nick, network) = nickAtNetwork.split('@', 1)
|
try:
|
||||||
|
(nick, network) = nickAtNetwork.split('@', 1)
|
||||||
|
except ValueError:
|
||||||
|
raise callbacks.ArgumentError
|
||||||
if network not in self.ircs:
|
if network not in self.ircs:
|
||||||
irc.error(msg, 'I\'m not on that network.')
|
irc.error(msg, 'I\'m not on that network.')
|
||||||
return
|
return
|
||||||
@ -253,12 +256,12 @@ class Relay(callbacks.Privmsg):
|
|||||||
|
|
||||||
def do311(self, irc, msg):
|
def do311(self, irc, msg):
|
||||||
if not isinstance(irc, irclib.Irc):
|
if not isinstance(irc, irclib.Irc):
|
||||||
realIrc = irc.getRealIrc()
|
irc = irc.getRealIrc()
|
||||||
nick = msg.args[1]
|
nick = msg.args[1]
|
||||||
if (realIrc, nick) not in self.whois:
|
if (irc, nick) not in self.whois:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.whois[(realIrc, nick)][-1][msg.command] = msg
|
self.whois[(irc, nick)][-1][msg.command] = msg
|
||||||
|
|
||||||
do312 = do311
|
do312 = do311
|
||||||
do317 = do311
|
do317 = do311
|
||||||
@ -271,22 +274,33 @@ class Relay(callbacks.Privmsg):
|
|||||||
if (irc, nick) not in self.whois:
|
if (irc, nick) not in self.whois:
|
||||||
return
|
return
|
||||||
(replyIrc, replyMsg, d) = self.whois[(irc, nick)]
|
(replyIrc, replyMsg, d) = self.whois[(irc, nick)]
|
||||||
hostmask = '@'.join(d['311'].args[2:])
|
hostmask = '@'.join(d['311'].args[2:4])
|
||||||
channels = d['319'].args[-1].split()
|
channels = d['319'].args[-1].split()
|
||||||
channels = ', and '.join([', '.join(channels[:-1]), channels[-1]])
|
if len(channels) == 1:
|
||||||
idle = utils.timeElapsed(d['317'].args[2])
|
channels = channels[0]
|
||||||
signon = time.ctime(d['317'][3])
|
else:
|
||||||
|
channels = ', and '.join([', '.join(channels[:-1]), channels[-1]])
|
||||||
|
if '317' in d:
|
||||||
|
idle = utils.timeElapsed(d['317'].args[2])
|
||||||
|
signon = time.ctime(float(d['317'].args[3]))
|
||||||
|
else:
|
||||||
|
idle = signon = '<unknown>'
|
||||||
s = '%s (%s) has been online since %s (idle for %s) and is on %s' % \
|
s = '%s (%s) has been online since %s (idle for %s) and is on %s' % \
|
||||||
(nick, hostmask, signon, idle, channels)
|
(nick, hostmask, signon, idle, channels)
|
||||||
replyIrc.reply(replyMsg, s)
|
replyIrc.reply(replyMsg, s)
|
||||||
|
|
||||||
def _formatPrivmsg(self, nick, abbreviation, msg):
|
def _formatPrivmsg(self, nick, abbreviation, msg):
|
||||||
# colorize nicks
|
# colorize nicks
|
||||||
nick = ircutils.canonicalColor(nick)
|
nick = ircutils.mircColor(nick, *ircutils.canonicalColor(nick))
|
||||||
|
colors = ircutils.canonicalColor(nick, shift=4)
|
||||||
if ircmsgs.isAction(msg):
|
if ircmsgs.isAction(msg):
|
||||||
return '* %s@%s %s' % (nick, abbreviation, ircmsgs.unAction(msg))
|
t = ircutils.mircColor('*', *colors)
|
||||||
|
s = '%s %s@%s %s' % (t, nick, abbreviation, ircmsgs.unAction(msg))
|
||||||
else:
|
else:
|
||||||
return '<%s@%s> %s' % (nick, abbreviation, msg.args[1])
|
lt = ircutils.mircColor('<', *colors)
|
||||||
|
gt = ircutils.mircColor('>', *colors)
|
||||||
|
s = '%s%s@%s%s %s' % (lt, nick, abbreviation, gt, msg.args[1])
|
||||||
|
return s
|
||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
callbacks.Privmsg.doPrivmsg(self, irc, msg)
|
callbacks.Privmsg.doPrivmsg(self, irc, msg)
|
||||||
@ -349,7 +363,8 @@ class Relay(callbacks.Privmsg):
|
|||||||
if not isinstance(irc, irclib.Irc):
|
if not isinstance(irc, irclib.Irc):
|
||||||
irc = irc.getRealIrc()
|
irc = irc.getRealIrc()
|
||||||
newNick = msg.args[0]
|
newNick = msg.args[0]
|
||||||
s = 'nick change by %s to %s' % (msg.nick, newNick)
|
network = self.abbreviations[irc]
|
||||||
|
s = 'nick change by %s to %s on %s' % (msg.nick, newNick, network)
|
||||||
for channel in self.channels:
|
for channel in self.channels:
|
||||||
if newNick in irc.state.channels[channel].users:
|
if newNick in irc.state.channels[channel].users:
|
||||||
for otherIrc in self.ircs.itervalues():
|
for otherIrc in self.ircs.itervalues():
|
||||||
@ -380,13 +395,14 @@ class Relay(callbacks.Privmsg):
|
|||||||
abbreviations = self.abbreviations.values()
|
abbreviations = self.abbreviations.values()
|
||||||
rPrivmsg = re.compile(r'<[^@]+@(?:%s)>' % '|'.join(abbreviations))
|
rPrivmsg = re.compile(r'<[^@]+@(?:%s)>' % '|'.join(abbreviations))
|
||||||
rAction = re.compile(r'\* [^/]+@(?:%s) ' % '|'.join(abbreviations))
|
rAction = re.compile(r'\* [^/]+@(?:%s) ' % '|'.join(abbreviations))
|
||||||
if not (rPrivmsg.match(msg.args[1]) or \
|
text = ircutils.unColor(msg.args[1])
|
||||||
rAction.match(msg.args[1]) or \
|
if not (rPrivmsg.match(text) or \
|
||||||
'has left on ' in msg.args[1] or \
|
rAction.match(text) or \
|
||||||
'has joined on ' in msg.args[1] or \
|
'has left on ' in text or \
|
||||||
'has quit' in msg.args[1] or \
|
'has joined on ' in text or \
|
||||||
msg.args[1].startswith('mode change') or \
|
'has quit' in text or \
|
||||||
msg.args[1].startswith('nick change')):
|
text.startswith('mode change') or \
|
||||||
|
text.startswith('nick change')):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
if channel in self.channels:
|
if channel in self.channels:
|
||||||
abbreviation = self.abbreviations[irc]
|
abbreviation = self.abbreviations[irc]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user