def receiveGroupMessage(self, sender, group, message, metadata=None): """Pass a message from the Words group on to IRC. Or, if it's in our errorGroup, recognize some debugging commands. """ if not (group == self.errorGroup): channel = groupToChannelName(group) if not self.isThisMine(sender): # Test for Special case: # got CTCP, probably through words.ircservice # (you SUCK!) # ACTION is the only case we'll support here. if message[:8] == irc.X_DELIM + 'ACTION ': c = irc.ctcpExtract(message) for tag, data in c['extended']: if tag == 'ACTION': self.irc.say(channel, "* %s %s" % (sender, data)) else: # Not an action. Repackage the chunk, msg = "%(X)s%(tag)s %(data)s%(X)s" % { 'X': irc.X_DELIM, 'tag': tag, 'data': data } # ctcpQuote it to render it harmless, msg = irc.ctcpQuote(msg) # and let it continue on. c['normal'].append(msg) for msg in c['normal']: self.irc.say(channel, "<%s> %s" % (sender, msg)) return elif irc.X_DELIM in message: message = irc.ctcpQuote(message) if metadata and metadata.has_key('style'): if metadata['style'] == "emote": self.irc.say(channel, "* %s %s" % (sender, message)) return self.irc.say(channel, "<%s> %s" % (sender, message)) else: # A message in our errorGroup. if message == "participants": s = map(lambda i: str(i[0]), self.participants.values()) s = string.join(s, ", ") elif message == "groups": s = map(str, self.perspective.groups) s = string.join(s, ", ") elif message == "transport": s = "%s connected: %s" %\ (self.transport, getattr(self.transport, "connected")) else: s = None if s: self.groupMessage(group, s)
def receiveGroupMessage(self, sender, group, message): """Pass a message from the Words group on to IRC. Or, if it's in our errorGroup, recognize some debugging commands. """ if not (group == self.errorGroup): channel = groupToChannelName(group) if not self.isThisMine(sender): # Test for Special case: # got CTCP, probably through words.ircservice # (you SUCK!) # ACTION is the only case we'll support here. if message[:8] == irc.X_DELIM + 'ACTION ': c = irc.ctcpExtract(message) for tag, data in c['extended']: if tag == 'ACTION': self.say(channel, "* %s %s" % (sender, data)) else: # Not an action. Repackage the chunk, msg = "%(X)s%(tag)s %(data)s%(X)s" % { 'X': irc.X_DELIM, 'tag': tag, 'data': data } # ctcpQuote it to render it harmless, msg = irc.ctcpQuote(msg) # and let it continue on. c['normal'].append(msg) for msg in c['normal']: self.say(channel, "<%s> %s" % (sender, msg)) return elif irc.X_DELIM in message: message = irc.ctcpQuote(message) self.say(channel, "<%s> %s" % (sender, message)) else: # A message in our errorGroup. if message == "participants": s = map(lambda i: str(i[0]), self.participants.values()) s = string.join(s, ", ") elif message == "groups": s = map(str, self.perspective.groups) s = string.join(s, ", ") elif message == "transport": s = "%s connected: %s" %\ (self.transport, getattr(self.transport, "connected")) else: s = None if s: self.groupMessage(group, s)
def test_ctcpquoteSanity(self): """Testing CTCP message level quote/dequote""" for s in stringSubjects: self.failUnlessEqual(s, irc.ctcpDequote(irc.ctcpQuote(s)))