From fbfd691cb49ec75c369f89bced4607e95f4c37a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E5=90=83=E7=82=B9=E8=8B=B9=E6=9E=9C?= <73388495+eatmoreapple@users.noreply.github.com> Date: Fri, 3 Feb 2023 17:57:58 +0800 Subject: [PATCH] [style]: update User display (#227) --- relations.go | 12 ++++++++++-- user.go | 6 +++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/relations.go b/relations.go index 19762e0..635610e 100644 --- a/relations.go +++ b/relations.go @@ -10,7 +10,11 @@ type Friend struct{ *User } // implement fmt.Stringer func (f *Friend) String() string { - return fmt.Sprintf("", f.NickName) + display := f.NickName + if f.RemarkName != "" { + display = f.RemarkName + } + return fmt.Sprintf("", display) } // SetRemarkName 重命名当前好友 @@ -156,7 +160,11 @@ type Group struct{ *User } // implement fmt.Stringer func (g *Group) String() string { - return fmt.Sprintf("", g.NickName) + display := g.NickName + if g.RemarkName != "" { + display = g.RemarkName + } + return fmt.Sprintf("", display) } // SendText 发行文本消息给当前的群组 diff --git a/user.go b/user.go index 45f233e..05fbf42 100644 --- a/user.go +++ b/user.go @@ -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) }