Misc refactoring

This commit is contained in:
Daniel Oaks
2018-02-03 21:15:07 +10:00
parent d854bac78e
commit 2ecec25d28
9 changed files with 55 additions and 59 deletions
+27
View File
@@ -0,0 +1,27 @@
// Copyright (c) 2016-2017 Daniel Oaks <daniel@danieloaks.net>
// released under the MIT license
package utils
import "github.com/goshuirc/irc-go/ircmsg"
// GetClientOnlyTags takes a tag map and returns a map containing just the client-only tags from it.
func GetClientOnlyTags(tags map[string]ircmsg.TagValue) *map[string]ircmsg.TagValue {
if len(tags) < 1 {
return nil
}
clientOnlyTags := make(map[string]ircmsg.TagValue)
for name, value := range tags {
if len(name) > 1 && name[0] == '+' {
clientOnlyTags[name] = value
}
}
if len(clientOnlyTags) < 1 {
return nil
}
return &clientOnlyTags
}