Example #1
0
File: beta.py Project: driax/bravo
    def chat(self, message):
        """
        Relay chat messages.

        Chat messages are sent to all connected clients, as well as to anybody
        consuming this factory.
        """

        for consumer in self.chat_consumers:
            consumer.write((self, message))

        # Prepare the message for chat packeting.
        for user in self.protocols:
            message = message.replace(user, chat_name(user))
        message = sanitize_chat(message)

        packet = make_packet("chat", message=message)
        self.broadcast(packet)
Example #2
0
    def chat(self, message):
        """
        Relay chat messages.

        Chat messages are sent to all connected clients, as well as to anybody
        consuming this factory.
        """

        for consumer in self.chat_consumers:
            consumer.write((self, message))

        # Prepare the message for chat packeting.
        for user in self.protocols:
            message = message.replace(user, chat_name(user))
        message = sanitize_chat(message)

        log.msg("Chat: %s" % message.encode("utf8"))

        packet = make_packet("chat", message=message)
        self.broadcast(packet)
Example #3
0
    def chat(self, message):
        """
        Relay chat messages.

        Chat messages are sent to all connected clients, as well as to anybody
        consuming this factory.
        """

        for consumer in self.chat_consumers:
            consumer.write((self, message))

        # Prepare the message for chat packeting.
        for user in self.protocols:
            message = message.replace(user, chat_name(user))
        message = sanitize_chat(message)

        log.msg("Chat: %s" % message.encode("utf8"))

        data = json.dumps({"text": message})

        packet = make_packet("chat", data=data)
        self.broadcast(packet)
Example #4
0
 def test_sanitize_chat_color_control_at_end(self):
     message = u"§0Test§f"
     sanitized = u"§0Test"
     self.assertEqual(sanitize_chat(message), sanitized)
Example #5
0
 def test_sanitize_chat_color_control_at_end(self):
     message = u"§0Test§f"
     sanitized = u"§0Test"
     self.assertEqual(sanitize_chat(message), sanitized)