From 3c7ac0cc75d7ccc38881bdca648d080b2c4373f9 Mon Sep 17 00:00:00 2001 From: ford <1334788676@qq.com> Date: Sun, 5 Feb 2023 11:20:40 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90opt=E3=80=91=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=A5=BD=E5=8F=8B=E5=85=AC=E4=BC=97=E5=8F=B7=E7=BE=A4=E7=BB=84?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3=E9=98=B2=E6=AD=A2=E9=A2=91?= =?UTF-8?q?=E7=B9=81=E5=8F=91=E9=80=81=E7=BD=91=E7=BB=9C=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=20(#234)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: wenyoufu --- user.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/user.go b/user.go index 4d50c3d..e69320f 100644 --- a/user.go +++ b/user.go @@ -288,13 +288,18 @@ func (s *Self) FileHelper() *Friend { } return s.fileHelper } +func (s *Self) ChkFrdGrpMpNil() bool { + return s.friends == nil && s.groups == nil && s.mps == nil +} // Friends 获取所有的好友 func (s *Self) Friends(update ...bool) (Friends, error) { - if s.friends == nil || (len(update) > 0 && update[0]) { + if (len(update) > 0 && update[0]) || s.ChkFrdGrpMpNil() { if _, err := s.Members(true); err != nil { return nil, err } + } + if s.friends == nil || (len(update) > 0 && update[0]) { s.friends = s.members.Friends() } return s.friends, nil @@ -302,10 +307,14 @@ func (s *Self) Friends(update ...bool) (Friends, error) { // Groups 获取所有的群组 func (s *Self) Groups(update ...bool) (Groups, error) { - if s.groups == nil || (len(update) > 0 && update[0]) { + + if (len(update) > 0 && update[0]) || s.ChkFrdGrpMpNil() { if _, err := s.Members(true); err != nil { return nil, err } + + } + if s.groups == nil || (len(update) > 0 && update[0]) { s.groups = s.members.Groups() } return s.groups, nil @@ -313,10 +322,12 @@ func (s *Self) Groups(update ...bool) (Groups, error) { // Mps 获取所有的公众号 func (s *Self) Mps(update ...bool) (Mps, error) { - if s.mps == nil || (len(update) > 0 && update[0]) { + if (len(update) > 0 && update[0]) || s.ChkFrdGrpMpNil() { if _, err := s.Members(true); err != nil { return nil, err } + } + if s.mps == nil || (len(update) > 0 && update[0]) { s.mps = s.members.MPs() } return s.mps, nil