Пример #1
0
def format_event(event):
    """
    Format an event
    :type event: ralybot.event.Event
    :rtype: str
    """

    # Setup arguments

    args = {
        "server": event.conn.name,
        "target": event.target,
        "channel": event.chan,
        "nick": event.nick,
        "user": event.user,
        "host": event.host,
    }

    if event.content is not None:
        # We can't strip colors from None
        args["content"] = strip_colors(event.content)
    else:
        args["content"] = None

    # Try formatting with non-connection-specific formats

    if event.type in base_formats:
        return base_formats[event.type].format(**args)

    # Try formatting with IRC-formats, if this is an IRC event
    if event.irc_command is not None:
        return format_irc_event(event, args)
Пример #2
0
def test_strip_colors():
    # compatibility
    assert strip_colors(test_strip_colors_input) == test_strip_colors_result