diff --git a/client.go b/client.go index fcf04f9..4576ab4 100644 --- a/client.go +++ b/client.go @@ -113,8 +113,8 @@ type Config struct { // messages. AllowFlood bool // GlobalFormat enables passing through all events which have trailing - // text through the color Format() function, so you don't have to wrap - // every response in the Format() method. + // text through the color Fmt() function, so you don't have to wrap + // every response in the Fmt() method. // // Note that this only actually applies to PRIVMSG, NOTICE and TOPIC // events, to ensure it doesn't clobber unwanted events. diff --git a/conn.go b/conn.go index 4b50e6e..a4a4e1e 100644 --- a/conn.go +++ b/conn.go @@ -395,7 +395,7 @@ func (c *Client) Send(event *Event) { if c.Config.GlobalFormat && event.Trailing != "" && (event.Command == PRIVMSG || event.Command == TOPIC || event.Command == NOTICE) { - event.Trailing = Format(event.Trailing) + event.Trailing = Fmt(event.Trailing) } c.write(event) diff --git a/format.go b/format.go index 955dc88..8cfce09 100644 --- a/format.go +++ b/format.go @@ -40,13 +40,13 @@ var codes = []*ircFmtCode{ {aliases: []string{"ctcp"}, val: "\x01"}, // CTCP/ACTION delimiter. } -// Format takes format strings like "{red}" and turns them into the resulting +// Fmt takes format strings like "{red}" and turns them into the resulting // ASCII format/color codes for IRC. // // For example: // -// client.Message("#channel", Format("{red}{bold}Hello World{c}")) -func Format(text string) string { +// client.Message("#channel", Fmt("{red}{bold}Hello World{c}")) +func Fmt(text string) string { for i := 0; i < len(codes); i++ { for a := 0; a < len(codes[i].aliases); a++ { text = strings.Replace(text, "{"+codes[i].aliases[a]+"}", codes[i].val, -1) @@ -69,9 +69,9 @@ func Format(text string) string { return text } -// StripFormat strips all "{fmt}" formatting strings from the input text. -// See Format() for more information. -func StripFormat(text string) string { +// TrimFmt strips all "{fmt}" formatting strings from the input text. +// See Fmt() for more information. +func TrimFmt(text string) string { for i := 0; i < len(codes); i++ { for a := 0; a < len(codes[i].aliases); a++ { text = strings.Replace(text, "{"+codes[i].aliases[a]+"}", "", -1) diff --git a/format_test.go b/format_test.go index fa5686d..d5d07cc 100644 --- a/format_test.go +++ b/format_test.go @@ -11,7 +11,7 @@ import ( func BenchmarkFormat(b *testing.B) { for i := 0; i < b.N; i++ { - Format("{red}test{c}") + Fmt("{red}test{c}") } return @@ -19,7 +19,7 @@ func BenchmarkFormat(b *testing.B) { func BenchmarkFormatLong(b *testing.B) { for i := 0; i < b.N; i++ { - Format("{red}test {blue}2 {red}3 {brown} {italic}test{c}") + Fmt("{red}test {blue}2 {red}3 {brown} {italic}test{c}") } return @@ -27,7 +27,7 @@ func BenchmarkFormatLong(b *testing.B) { func BenchmarkStripFormat(b *testing.B) { for i := 0; i < b.N; i++ { - StripFormat("{red}test{c}") + TrimFmt("{red}test{c}") } return @@ -35,14 +35,14 @@ func BenchmarkStripFormat(b *testing.B) { func BenchmarkStripFormatLong(b *testing.B) { for i := 0; i < b.N; i++ { - StripFormat("{red}test {blue}2 {red}3 {brown} {italic}test{c}") + TrimFmt("{red}test {blue}2 {red}3 {brown} {italic}test{c}") } return } func BenchmarkStripRaw(b *testing.B) { - text := Format("{red}test{c}") + text := Fmt("{red}test{c}") for i := 0; i < b.N; i++ { StripRaw(text) } @@ -51,7 +51,7 @@ func BenchmarkStripRaw(b *testing.B) { } func BenchmarkStripRawLong(b *testing.B) { - text := Format("{red}test {blue}2 {red}3 {brown} {italic}test{c}") + text := Fmt("{red}test {blue}2 {red}3 {brown} {italic}test{c}") for i := 0; i < b.N; i++ { StripRaw(text) } @@ -77,7 +77,7 @@ func TestFormat(t *testing.T) { } for _, tt := range tests { - if got := Format(tt.args.text); got != tt.want { + if got := Fmt(tt.args.text); got != tt.want { t.Errorf("%s: Format() = %v, want %v", tt.name, got, tt.want) } } @@ -101,7 +101,7 @@ func TestStripFormat(t *testing.T) { } for _, tt := range tests { - if got := StripFormat(tt.args.text); got != tt.want { + if got := TrimFmt(tt.args.text); got != tt.want { t.Errorf("%s: StripFormat() = %v, want %v", tt.name, got, tt.want) } } @@ -125,7 +125,7 @@ func TestStripRaw(t *testing.T) { } for _, tt := range tests { - if got := StripRaw(Format(tt.args.text)); got != tt.want { + if got := StripRaw(Fmt(tt.args.text)); got != tt.want { t.Errorf("%s: StripRaw() = %v, want %v", tt.name, got, tt.want) } }