Esempio n. 1
0
    def execute(self, server, room, buff, tags):
        topic = self.topic

        nick, color_name = sender_to_nick_and_color(room, self.sender)

        author = ("{nick_color}{user}{ncolor}").format(
            nick_color=W.color(color_name), user=nick, ncolor=W.color("reset"))

        # TODO print old topic if configured so
        if room.is_named():
            message = ("{prefix}{nick} has changed "
                       "the topic for {chan_color}{room}{ncolor} "
                       "to \"{topic}\"").format(
                           prefix=W.prefix("network"),
                           nick=author,
                           chan_color=W.color("chat_channel"),
                           ncolor=W.color("reset"),
                           room=room.named_room_name(),
                           topic=topic)
        else:
            message = ('{prefix}{nick} has changed the topic to '
                       '"{topic}"').format(prefix=W.prefix("network"),
                                           nick=author,
                                           topic=topic)

        tags = ["matrix_topic", "log3", "matrix_id_{}".format(self.event_id)]
        date = server_ts_to_weechat(self.timestamp)
        W.prnt_date_tags(buff, date, ",".join(tags), message)
Esempio n. 2
0
    def execute(self, server, room, buff, tags):
        nick, color_name = sender_to_nick_and_color(room, self.sender)
        event_tags = add_event_tags(self.event_id, nick, None, [])
        # TODO this should be configurable
        action_color = "red" if self.prefix == "quit" else "green"

        data = ("{prefix}{color}{author}{ncolor} "
                "{del_color}({host_color}{user_id}{del_color})"
                "{action_color} {message} "
                "{channel_color}{room}{ncolor}").format(
                    prefix=W.prefix(self.prefix),
                    color=W.color(color_name),
                    author=nick,
                    ncolor=W.color("reset"),
                    del_color=W.color("chat_delimiters"),
                    host_color=W.color("chat_host"),
                    user_id=self.sender,
                    action_color=W.color(action_color),
                    message=self.message,
                    channel_color=W.color("chat_channel"),
                    room="" if room.is_group() else room.named_room_name())
        date = server_ts_to_weechat(self.timestamp)
        tags_string = ",".join(event_tags)

        W.prnt_date_tags(buff, date, tags_string, data)
Esempio n. 3
0
    def execute(self, server, room, buff, tags):
        nick, color_name = sender_to_nick_and_color(room, self.sender)
        color = color_for_tags(color_name)
        date = server_ts_to_weechat(self.timestamp)

        event_tags = add_event_tags(self.event_id, nick, color, tags)

        reason = (", reason: \"{reason}\"".format(
            reason=self.reason) if self.reason else "")

        censor, _ = sender_to_nick_and_color(room, self.censor)

        msg = ("{del_color}<{log_color}Message redacted by: "
               "{censor}{log_color}{reason}{del_color}>{ncolor}").format(
                   del_color=W.color("chat_delimiters"),
                   ncolor=W.color("reset"),
                   log_color=W.color("logger.color.backlog_line"),
                   censor=censor,
                   reason=reason)

        event_tags.append("matrix_redacted")

        tags_string = ",".join(event_tags)

        data = "{author}\t{msg}".format(author=nick, msg=msg)

        W.prnt_date_tags(buff, date, tags_string, data)
Esempio n. 4
0
    def execute(self, server, room, buff, tags):
        topic = self.topic

        W.buffer_set(buff, "title", topic)

        room.topic = topic
        room.topic_author = self.sender
        room.topic_date = datetime.fromtimestamp(
            server_ts_to_weechat(self.timestamp))
Esempio n. 5
0
    def execute(self, server, room, buff, tags):
        nick, color_name = sender_to_nick_and_color(room, self.sender)
        color = color_for_tags(color_name)

        event_tags = add_event_tags(self.event_id, nick, color, tags)
        event_tags.append("matrix_action")

        tags_string = ",".join(event_tags)

        data = "{prefix}{nick_color}{author}{ncolor} {msg}".format(
            prefix=W.prefix("action"),
            nick_color=W.color(color_name),
            author=nick,
            ncolor=W.color("reset"),
            msg=self.message)

        date = server_ts_to_weechat(self.timestamp)
        W.prnt_date_tags(buff, date, tags_string, data)
Esempio n. 6
0
    def _print_message(self, message, room, buff, tags):
        nick, color_name = sender_to_nick_and_color(room, self.sender)
        color = color_for_tags(color_name)

        event_tags = add_event_tags(self.event_id, nick, color, tags)

        tags_string = ",".join(event_tags)

        prefix, prefix_color = sender_to_prefix_and_color(room, self.sender)

        prefix_string = ("" if not prefix else "{}{}{}".format(
            W.color(prefix_color), prefix, W.color("reset")))

        data = "{prefix}{color}{author}{ncolor}\t{msg}".format(
            prefix=prefix_string,
            color=W.color(color_name),
            author=nick,
            ncolor=W.color("reset"),
            msg=message)

        date = server_ts_to_weechat(self.timestamp)
        W.prnt_date_tags(buff, date, tags_string, data)