package ircclient import ( "fmt" "log" "regexp" ) // Stripper removes IRC color and formatting codes. func Stripper(input string) string { var rx *regexp.Regexp var err error rx, err = regexp.Compile("\x02|\x1d|\x16|\x1e|\x11|\x16|\x1f|\x0f|\x03[0-9]{2}") if err != nil { log.Panic("regexp:", err) } input = rx.ReplaceAllString(input, "") return input } // Set IRC bold func Bold(input string) string { return "\x02" + input + "\x02" } // Set IRC Italics func Italics(input string) string { return "\x1d" + input + "\x1d" } // Set IRC underline func Underline(input string) string { return "\x1f" + input + "\x1f" } // Set IRC strike through func Strike(input string) string { return "\x1e" + input + "\x1e" } // Set IRC monospace func Monospace(input string) string { return "\x11" + input + "\x11" } // Set IRC reverse func Reverse(input string) string { return "\x16" + input + "\x16" } // Reset IRC reset color and formatting func Reset() string { return "\x0f" } // Color set IRC color // // We always output the color code as 2 digits. func Color(color int) string { return fmt.Sprintf("\x03%02d", color) } // Format a string with the given color code, and reset. func ColorString(color int, input string) string { return fmt.Sprintf("\x03%02d%s\x0f", color, input) }