1
0
Fork 0
forked from External/ergo

add a type for CTCP-encoded strings, and NOTICEs for error cases

This commit is contained in:
Edmund Huber 2014-03-23 06:47:21 +01:00
parent 6267b6a40c
commit 34b01b115e
5 changed files with 38 additions and 14 deletions

View file

@ -64,3 +64,12 @@ func NewText(str string) Text {
func (text Text) String() string {
return string(text)
}
// CTCPText is text suitable escaped for CTCP.
type CTCPText string
var ctcpEscaper = strings.NewReplacer("\x00", "\x200", "\n", "\x20n", "\r", "\x20r")
func NewCTCPText(str string) CTCPText {
return CTCPText(ctcpEscaper.Replace(str))
}