1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 03:23:49 +08:00

get group info by search

This commit is contained in:
wdvxdr 2021-02-02 22:12:47 +08:00
parent 08567ec240
commit 5b57aeb1d1
No known key found for this signature in database
GPG Key ID: 55FF1414A69CEBA6
3 changed files with 19 additions and 2 deletions

View File

@ -62,7 +62,22 @@ func (bot *CQBot) CQGetGroupList(noCache bool) MSG {
func (bot *CQBot) CQGetGroupInfo(groupId int64, noCache bool) MSG {
group := bot.Client.FindGroup(groupId)
if group == nil {
return Failed(100, "GROUP_NOT_FOUND", "群聊不存在")
gid := strconv.FormatInt(groupId, 10)
info, err := bot.Client.SearchGroupByKeyword(gid)
if err != nil {
return Failed(100, "GROUP_SEARCH_ERROR", "群聊搜索失败")
}
for _, g := range info {
if g.Code == groupId {
return OK(MSG{
"group_id": g.Code,
"group_name": g.Name,
"max_member_count": 0,
"member_count": 0,
})
}
}
return Failed(100, "GROUP_NOT_FOUND", "群聊不存在失败")
}
if noCache {
var err error

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
go 1.15
require (
github.com/Mrs4s/MiraiGo v0.0.0-20210201234941-c69e578d0815
github.com/Mrs4s/MiraiGo v0.0.0-20210202135946-553229fea92e
github.com/dustin/go-humanize v1.0.0
github.com/gin-contrib/pprof v1.3.0
github.com/gin-gonic/gin v1.6.3

2
go.sum
View File

@ -2,6 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Mrs4s/MiraiGo v0.0.0-20210201234941-c69e578d0815 h1:WW2YfA+0+LSa/0VlWVhnfrXXatcE09paHgPgfPxlIMk=
github.com/Mrs4s/MiraiGo v0.0.0-20210201234941-c69e578d0815/go.mod h1:yhqA0NyKxUf7I/0HR/1OMchveFggX8wde04gqdGrNfU=
github.com/Mrs4s/MiraiGo v0.0.0-20210202135946-553229fea92e h1:5rZXeo+KW1vNq5fM7DowITQgm8r7HuH6w9tScWJ5GQQ=
github.com/Mrs4s/MiraiGo v0.0.0-20210202135946-553229fea92e/go.mod h1:yhqA0NyKxUf7I/0HR/1OMchveFggX8wde04gqdGrNfU=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=