[style]: update User display (#227)

This commit is contained in:
多吃点苹果 2023-02-03 17:57:58 +08:00 committed by GitHub
parent 5194ad4965
commit fbfd691cb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -10,7 +10,11 @@ type Friend struct{ *User }
// implement fmt.Stringer
func (f *Friend) String() string {
return fmt.Sprintf("<Friend:%s>", f.NickName)
display := f.NickName
if f.RemarkName != "" {
display = f.RemarkName
}
return fmt.Sprintf("<Friend:%s>", display)
}
// SetRemarkName 重命名当前好友
@ -156,7 +160,11 @@ type Group struct{ *User }
// implement fmt.Stringer
func (g *Group) String() string {
return fmt.Sprintf("<Group:%s>", g.NickName)
display := g.NickName
if g.RemarkName != "" {
display = g.RemarkName
}
return fmt.Sprintf("<Group:%s>", display)
}
// SendText 发行文本消息给当前的群组

View File

@ -58,14 +58,14 @@ type User struct {
// implement fmt.Stringer
func (u *User) String() string {
format := "User"
if u.IsFriend() {
if u.IsSelf() {
format = "Self"
} else if u.IsFriend() {
format = "Friend"
} else if u.IsGroup() {
format = "Group"
} else if u.IsMP() {
format = "MP"
} else if u.IsSelf() {
format = "Self"
}
return fmt.Sprintf("<%s:%s>", format, u.NickName)
}