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

feat: get_unidirectional_friend_list api.

This commit is contained in:
Mrs4s 2021-09-16 17:33:38 +08:00
parent eadd688e5a
commit b8bf3f9711
No known key found for this signature in database
GPG Key ID: 3186E98FA19CE3A7
2 changed files with 87 additions and 62 deletions

View File

@ -72,6 +72,26 @@ func (bot *CQBot) CQGetFriendList() MSG {
return OK(fs)
}
// CQGetUnidirectionalFriendList 获取单向好友列表
//
//
func (bot *CQBot) CQGetUnidirectionalFriendList() MSG {
list, err := bot.Client.GetUnidirectionalFriendList()
if err != nil {
log.Errorf("获取单向好友列表时出现错误: %v", err)
return Failed(100, "API_ERROR", err.Error())
}
fs := make([]MSG, 0, len(list))
for _, f := range list {
fs = append(fs, MSG{
"nickname": f.Nickname,
"user_id": f.Uin,
"source": f.Source,
})
}
return OK(fs)
}
// CQDeleteFriend 删除好友
//
//

View File

@ -32,6 +32,10 @@ func getFriendList(bot *coolq.CQBot, _ resultGetter) coolq.MSG {
return bot.CQGetFriendList()
}
func getUnidirectionalFriendList(bot *coolq.CQBot, _ resultGetter) coolq.MSG {
return bot.CQGetUnidirectionalFriendList()
}
func deleteFriend(bot *coolq.CQBot, p resultGetter) coolq.MSG {
return bot.CQDeleteFriend(p.Get("id").Int())
}
@ -358,6 +362,7 @@ func markMSGAsRead(bot *coolq.CQBot, p resultGetter) coolq.MSG {
var API = map[string]func(*coolq.CQBot, resultGetter) coolq.MSG{
"get_login_info": getLoginInfo,
"get_friend_list": getFriendList,
"get_unidirectional_friend_list": getUnidirectionalFriendList,
"delete_friend": deleteFriend,
"get_group_list": getGroupList,
"get_group_info": getGroupInfo,