-
Notifications
You must be signed in to change notification settings - Fork 1
/
getinfo.go
75 lines (67 loc) · 1.72 KB
/
getinfo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package wwdk
import (
"github.com/ikuiki/wwdk/datastruct"
"github.com/pkg/errors"
)
// 此文件内的方法主要为WechatWeb暴露给外部调用获取信息的方法
// GetContact 根据username获取联系人
func (wxwb *WechatWeb) GetContact(username string) (contact datastruct.Contact, err error) {
contact, ok := wxwb.contactList[username]
if !ok {
err = errors.New("User not found")
}
return
}
// GetContactByAlias 根据Alias获取联系人
func (wxwb *WechatWeb) GetContactByAlias(alias string) (contact datastruct.Contact, err error) {
found := false
for _, v := range wxwb.contactList {
if v.Alias == alias {
contact = v
found = true
}
}
if !found {
err = errors.New("User not found")
}
return
}
// GetContactByNickname 根据昵称获取用户名
func (wxwb *WechatWeb) GetContactByNickname(nickname string) (contact datastruct.Contact, err error) {
found := false
for _, v := range wxwb.contactList {
if v.NickName == nickname {
contact = v
found = true
}
}
if !found {
err = errors.New("User not found")
}
return
}
// GetContactByRemarkName 根据备注获取用户名
func (wxwb *WechatWeb) GetContactByRemarkName(remarkName string) (contact datastruct.Contact, err error) {
found := false
for _, v := range wxwb.contactList {
if v.RemarkName == remarkName {
contact = v
found = true
}
}
if !found {
err = errors.New("User not found")
}
return
}
// GetContactList 获取联系人列表
func (wxwb *WechatWeb) GetContactList() (contacts []datastruct.Contact) {
for _, v := range wxwb.contactList {
contacts = append(contacts, v)
}
return
}
// GetRunInfo 获取运行计数器信息
func (wxwb *WechatWeb) GetRunInfo() (runinfo WechatRunInfo) {
return wxwb.runInfo
}