From e89a631aee16261273fab3ab56985eb359fc89d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=81=E8=B6=85=E9=A3=9E?= Date: Thu, 15 Dec 2022 11:13:28 +0800 Subject: [PATCH] add comment (#144) --- wechaty-puppet/schemas/contact.go | 15 ++++++++++----- wechaty-puppet/schemas/room.go | 7 +++++-- wechaty/interface/contact.go | 2 ++ wechaty/interface/room.go | 7 ++++--- wechaty/user/room.go | 4 ++-- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/wechaty-puppet/schemas/contact.go b/wechaty-puppet/schemas/contact.go index 0a66a25..886a4ec 100644 --- a/wechaty-puppet/schemas/contact.go +++ b/wechaty-puppet/schemas/contact.go @@ -22,12 +22,17 @@ const ( // ContactQueryFilter use the first non-empty parameter of all parameters to search type ContactQueryFilter struct { - Alias string + // 别名过滤 + Alias string + // 别名正则表达式过滤 AliasRegexp *regexp.Regexp - Id string - Name string - NameRegexp *regexp.Regexp - WeiXin string + // id 过滤 + Id string + // 昵称过滤 + Name string + // 昵称正则表达式过滤 + NameRegexp *regexp.Regexp + WeiXin string } type ContactPayload struct { diff --git a/wechaty-puppet/schemas/room.go b/wechaty-puppet/schemas/room.go index 11bb5cb..68a94a3 100644 --- a/wechaty-puppet/schemas/room.go +++ b/wechaty-puppet/schemas/room.go @@ -9,8 +9,11 @@ type RoomMemberQueryFilter struct { } type RoomQueryFilter struct { - Id string - Topic string + // 使用 room id 过滤 + Id string + // 使用群名称过滤 + Topic string + // 群名称正则过滤 TopicRegexp *regexp.Regexp } diff --git a/wechaty/interface/contact.go b/wechaty/interface/contact.go index 710585d..09640ed 100644 --- a/wechaty/interface/contact.go +++ b/wechaty/interface/contact.go @@ -9,8 +9,10 @@ type IContactFactory interface { Load(id string) IContact LoadSelf(id string) IContactSelf // Find query params is string or *schemas.ContactQueryFilter + // when the parameter is a string type, the name search is used by default Find(query interface{}) IContact // FindAll query params is string or *schemas.ContactQueryFilter + // when the parameter is a string type, the name search is used by default FindAll(query interface{}) []IContact // Tags get tags for all contact Tags() []ITag diff --git a/wechaty/interface/room.go b/wechaty/interface/room.go index bdd163c..68e085f 100644 --- a/wechaty/interface/room.go +++ b/wechaty/interface/room.go @@ -10,6 +10,7 @@ type IRoomFactory interface { Create(contactList []IContact, topic string) (IRoom, error) FindAll(query *schemas.RoomQueryFilter) []IRoom // Find query params is string or *schemas.RoomQueryFilter + // when the parameter is a string type, the room name search is used by default Find(query interface{}) IRoom Load(id string) IRoom } @@ -20,11 +21,11 @@ type IRoom interface { IsReady() bool String() string ID() string - // Find all contacts in a room - // params nil or string or RoomMemberQueryFilter + // MemberAll all contacts in a room + // params nil or string or *schemas.RoomMemberQueryFilter MemberAll(query interface{}) ([]IContact, error) // Member Find all contacts in a room, if get many, return the first one. - // query params string or RoomMemberQueryFilter + // query params string or *schemas.RoomMemberQueryFilter Member(query interface{}) (IContact, error) // Alias return contact's roomAlias in the room Alias(contact IContact) (string, error) diff --git a/wechaty/user/room.go b/wechaty/user/room.go index fd309e1..42644e6 100644 --- a/wechaty/user/room.go +++ b/wechaty/user/room.go @@ -69,8 +69,8 @@ func (r *Room) ID() string { return r.id } -// Find all contacts in a room -// params nil or string or RoomMemberQueryFilter +// MemberAll all contacts in a room +// params nil or string or *schemas.RoomMemberQueryFilter func (r *Room) MemberAll(query interface{}) ([]_interface.IContact, error) { if query == nil { return r.memberList()