Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
给一些结构体实现Stringer接口
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteReimu committed May 10, 2024
1 parent a9a81ac commit 2348d62
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions type.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package miraihttp

import "fmt"

type Perm string

const (
Expand Down Expand Up @@ -30,13 +32,21 @@ type Friend struct {
Remark string `json:"remark"` // 备注
}

func (f *Friend) String() string {
return fmt.Sprintf("%s(%d)", f.Nickname, f.Id)
}

// Group 群
type Group struct {
Id int64 `json:"id"` // 群号
Name string `json:"name"` // 群名称
Permission Perm `json:"permission"` // Bot在群中的权限
}

func (g *Group) String() string {
return fmt.Sprintf("%s(%d)", g.Name, g.Id)
}

// Member 群成员
type Member struct {
Id int64 `json:"id"` // QQ号
Expand All @@ -49,6 +59,10 @@ type Member struct {
Group Group `json:"group"` // 群信息
}

func (m *Member) String() string {
return fmt.Sprintf("%s(%d)", m.MemberName, m.Id)
}

type Sex string

const (
Expand Down

0 comments on commit 2348d62

Please sign in to comment.