1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00

coolq: use generic sync.Map

This commit is contained in:
wdvxdr 2022-03-20 15:19:47 +08:00
parent 5b148d6c5e
commit 062eea62ab
No known key found for this signature in database
GPG Key ID: 703F8C071DE7A1B6
4 changed files with 12 additions and 8 deletions

View File

@ -1126,9 +1126,9 @@ func (bot *CQBot) CQProcessFriendRequest(flag string, approve bool) global.MSG {
return Failed(100, "FLAG_NOT_FOUND", "FLAG不存在")
}
if approve {
req.(*client.NewFriendRequest).Accept()
req.Accept()
} else {
req.(*client.NewFriendRequest).Reject()
req.Reject()
}
return OK(nil)
}

View File

@ -14,6 +14,7 @@ import (
"github.com/Mrs4s/MiraiGo/client"
"github.com/Mrs4s/MiraiGo/message"
"github.com/Mrs4s/MiraiGo/utils"
"github.com/RomiChan/syncx"
"github.com/pkg/errors"
"github.com/segmentio/asm/base64"
log "github.com/sirupsen/logrus"
@ -30,8 +31,8 @@ type CQBot struct {
lock sync.RWMutex
events []func(*Event)
friendReqCache sync.Map
tempSessionCache sync.Map
friendReqCache syncx.Map[string, *client.NewFriendRequest]
tempSessionCache syncx.Map[int64, *client.TempSessionInfo]
nextTokenCache *utils.Cache[*guildMemberPageToken]
}
@ -366,7 +367,7 @@ func (bot *CQBot) SendPrivateMessage(target int64, groupID int64, m *message.Sen
}
break
}
msg, err := session.(*client.TempSessionInfo).SendMessage(m)
msg, err := session.SendMessage(m)
if err != nil {
log.Errorf("发送临时会话消息失败: %v", err)
break

3
go.mod
View File

@ -4,7 +4,8 @@ go 1.18
require (
github.com/Microsoft/go-winio v0.5.1
github.com/Mrs4s/MiraiGo v0.0.0-20220319020337-5903226f2534
github.com/Mrs4s/MiraiGo v0.0.0-20220320070754-38990f6e1cf9
github.com/RomiChan/syncx v0.0.0-20220320065321-8d448f958257
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc
github.com/fumiama/go-hide-param v0.1.4
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible

6
go.sum
View File

@ -1,9 +1,11 @@
github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY=
github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Mrs4s/MiraiGo v0.0.0-20220319020337-5903226f2534 h1:Ah5fmskBIYruUGBIH1mLoeXmmGDO92N8JPDPW0Fd7f4=
github.com/Mrs4s/MiraiGo v0.0.0-20220319020337-5903226f2534/go.mod h1:kkUjOuOj2FMfqEEtnan/mxxKBZopYRBVIR4gSAdt7Hs=
github.com/Mrs4s/MiraiGo v0.0.0-20220320070754-38990f6e1cf9 h1:YJeHJRNVfpbuC7wSQD3WOcysC7AcILgQf5d8kFPL12Y=
github.com/Mrs4s/MiraiGo v0.0.0-20220320070754-38990f6e1cf9/go.mod h1:qseuVVwl5wxdhphaS29F6CN0gV2J0ojT880Ql5g2MBo=
github.com/RomiChan/protobuf v0.0.0-20220318113238-d8a99598f896 h1:UFAqSbH6VqW5mEzQV2HVB7+p3k9JfTbidWJ/9F15yz0=
github.com/RomiChan/protobuf v0.0.0-20220318113238-d8a99598f896/go.mod h1:CKKOWC7mBxd36zxsCB1V8DTrwlTNRQvkSVbYqyUiGEE=
github.com/RomiChan/syncx v0.0.0-20220320065321-8d448f958257 h1:fdMod+DEoiICoTtS1Wij/wl1d57FPvKVmretLi2sGD8=
github.com/RomiChan/syncx v0.0.0-20220320065321-8d448f958257/go.mod h1:KqZzu7slNKROh3TSYEH/IUMG6f4M+1qubZ5e52QypsE=
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc h1:AAx50/fb/xS4lvsdQg+bFbGvqSDhyV1MF+p2PLCamZ0=
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc/go.mod h1:OMmITAib6POA37xCichWM0aRnoVpSMZO1rB/G01wrr0=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=