FinallyEXCLAIM

This commit is contained in:
Jeremy Fincher 2004-04-18 00:35:54 +00:00
parent 2a62e3cd5b
commit e7f6aa884f

View File

@ -500,16 +500,18 @@ class Relay(callbacks.Privmsg):
s = '%s%s@%s%s %s' % (lt, nick, network, gt, msg.args[1]) s = '%s%s@%s%s %s' % (lt, nick, network, gt, msg.args[1])
return s return s
def _addRelayedMsg(self, msg):
try:
self.relayedMsgs[msg] += 1
except KeyError:
self.relayedMsgs[msg] = 1
def _sendToOthers(self, irc, msg): def _sendToOthers(self, irc, msg):
assert msg.command == 'PRIVMSG' or msg.command == 'TOPIC' assert msg.command == 'PRIVMSG' or msg.command == 'TOPIC'
for otherIrc in self.ircs.itervalues(): for otherIrc in self.ircs.itervalues():
if otherIrc != irc: if otherIrc != irc:
if msg.args[0] in otherIrc.state.channels: if msg.args[0] in otherIrc.state.channels:
if msg.command == 'PRIVMSG': self._addRelayedMsg(msg)
try:
self.relayedMsgs[msg].append(otherIrc)
except KeyError:
self.relayedMsgs[msg] = [otherIrc]
otherIrc.queueMsg(msg) otherIrc.queueMsg(msg)
def doPrivmsg(self, irc, msg): def doPrivmsg(self, irc, msg):
@ -615,24 +617,40 @@ class Relay(callbacks.Privmsg):
m = ircmsgs.privmsg(channel, s) m = ircmsgs.privmsg(channel, s)
self._sendToOthers(irc, m) self._sendToOthers(irc, m)
def _isRelayedPrivmsg(self, msg):
if msg in self.relayedMsgs:
self.relayedMsgs[msg] -= 1
if not self.relayedMsgs[msg]:
del self.relayedMsgs[msg]
return True
else:
return False
## abbreviations = self.abbreviations.values()
## rPrivmsg = re.compile(r'<[^@]+@(?:%s)>' % '|'.join(abbreviations))
## rAction = re.compile(r'\* [^/]+@(?:%s) ' % '|'.join(abbreviations))
## text = ircutils.stripColor(msg.args[1])
## return (rPrivmsg.match(text) or \
## rAction.match(text) or \
## 'has left on ' in text or \
## 'has joined on ' in text or \
## 'has quit ' in text or \
## 'was kicked by' in text or \
## text.startswith('mode change') or \
## text.startswith('nick change') or \
## text.startswith('topic change'))
def outFilter(self, irc, msg): def outFilter(self, irc, msg):
if not self.started: if not self.started:
return msg return msg
irc = self._getRealIrc(irc) irc = self._getRealIrc(irc)
if msg.command == 'PRIVMSG': if msg.command == 'PRIVMSG':
abbreviations = self.abbreviations.values() if not self._isRelayedPrivmsg(msg):
if msg in self.relayedMsgs and irc in self.relayedMsgs[msg]:
self.relayedMsgs[msg].remove(irc)
if not self.relayedMsgs[msg]:
del self.relayedMsgs[msg]
channel = msg.args[0] channel = msg.args[0]
if channel in self.registryValue('channels'): if channel in self.registryValue('channels'):
abbreviation = self.abbreviations[irc] abbreviation = self.abbreviations[irc]
s = self._formatPrivmsg(irc.nick, abbreviation, msg) s = self._formatPrivmsg(irc.nick, abbreviation, msg)
for otherIrc in self.ircs.itervalues(): relayMsg = ircmsgs.privmsg(channel, s)
if otherIrc != irc: self._sendToOthers(irc, relayMsg)
if channel in otherIrc.state.channels:
otherIrc.queueMsg(ircmsgs.privmsg(channel, s))
elif msg.command == 'TOPIC' and len(msg.args) > 1 and \ elif msg.command == 'TOPIC' and len(msg.args) > 1 and \
self.registryValue('topicSync', msg.args[0]): self.registryValue('topicSync', msg.args[0]):
(channel, topic) = msg.args (channel, topic) = msg.args