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

Merge pull request #223 from F0ur/master

feat(api): make json response [] instead of null(empty list)
This commit is contained in:
Mrs4s 2020-08-31 23:46:27 +08:00 committed by GitHub
commit 7d62db2ec0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,7 +25,7 @@ func (bot *CQBot) CQGetLoginInfo() MSG {
// https://cqhttp.cc/docs/4.15/#/API?id=get_friend_list-%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8 // https://cqhttp.cc/docs/4.15/#/API?id=get_friend_list-%E8%8E%B7%E5%8F%96%E5%A5%BD%E5%8F%8B%E5%88%97%E8%A1%A8
func (bot *CQBot) CQGetFriendList() MSG { func (bot *CQBot) CQGetFriendList() MSG {
var fs []MSG fs := make([]MSG, 0)
for _, f := range bot.Client.FriendList { for _, f := range bot.Client.FriendList {
fs = append(fs, MSG{ fs = append(fs, MSG{
"nickname": f.Nickname, "nickname": f.Nickname,
@ -38,7 +38,7 @@ func (bot *CQBot) CQGetFriendList() MSG {
// https://cqhttp.cc/docs/4.15/#/API?id=get_group_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%88%97%E8%A1%A8 // https://cqhttp.cc/docs/4.15/#/API?id=get_group_list-%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%88%97%E8%A1%A8
func (bot *CQBot) CQGetGroupList(noCache bool) MSG { func (bot *CQBot) CQGetGroupList(noCache bool) MSG {
var gs []MSG gs := make([]MSG, 0)
if noCache { if noCache {
_ = bot.Client.ReloadGroupList() _ = bot.Client.ReloadGroupList()
} }
@ -73,7 +73,7 @@ func (bot *CQBot) CQGetGroupMemberList(groupId int64) MSG {
if group == nil { if group == nil {
return Failed(100) return Failed(100)
} }
var members []MSG members := make([]MSG, 0)
for _, m := range group.Members { for _, m := range group.Members {
members = append(members, convertGroupMemberInfo(groupId, m)) members = append(members, convertGroupMemberInfo(groupId, m))
} }
@ -525,7 +525,7 @@ func (bot *CQBot) CQGetForwardMessage(resId string) MSG {
if m == nil { if m == nil {
return Failed(100) return Failed(100)
} }
var r []MSG r := make([]MSG, 0)
for _, n := range m.Nodes { for _, n := range m.Nodes {
bot.checkMedia(n.Message) bot.checkMedia(n.Message)
r = append(r, MSG{ r = append(r, MSG{