MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / GetUin

Method GetUin

client/internal/cache/cache.go:24–46  ·  view source on GitHub ↗

GetUin 根据uid获取uin

(uid string, groupUin ...uint32)

Source from the content-addressed store, hash-verified

22
23// GetUin 根据uid获取uin
24func (c *Cache) GetUin(uid string, groupUin ...uint32) (uin uint32) {
25 if len(groupUin) == 0 {
26 rangeCacheOf[entity.User](c, func(k uint32, friend *entity.User) bool {
27 if friend.UID == uid {
28 uin = k
29 return false
30 }
31 return true
32 })
33 return uin
34 }
35 if group, ok := getCacheOf[Cache](c, groupUin[0]); ok {
36 rangeCacheOf[entity.GroupMember](group, func(k uint32, member *entity.GroupMember) bool {
37 if member.UID == uid {
38 uin = k
39 return false
40 }
41 return true
42 })
43 return uin
44 }
45 return 0
46}
47
48// GetFriend 获取好友信息
49func (c *Cache) GetFriend(uin uint32) *entity.User {

Callers

nothing calls this directly

Calls 1

rangeCacheOfFunction · 0.85

Tested by

no test coverage detected