harmony/pkg/web/user.go

22 lines
327 B
Go

package web
import "regexp"
type User struct {
N string
V bool
}
var nickRegexp = regexp.MustCompile(`[^a-zA-Z0-9_\-!@#$%^&*+=,./?]+`)
func Nickname(nick string) string {
nick = nickRegexp.ReplaceAllString(nick, "")
if len(nick) > 10 {
nick = nick[:10]
} else if nick == "" {
nick = "Anonymous"
}
return nick
}