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

feat: delete_friend api.

This commit is contained in:
Mrs4s 2021-05-24 20:03:01 +08:00
parent f6f31a87f9
commit e4e17fb8c4
No known key found for this signature in database
GPG Key ID: 3186E98FA19CE3A7
3 changed files with 19 additions and 1 deletions

View File

@ -73,6 +73,20 @@ func (bot *CQBot) CQGetFriendList() MSG {
return OK(fs)
}
// CQDeleteFriend 删除好友
//
//
func (bot *CQBot) CQDeleteFriend(uin int64) MSG {
if bot.Client.FindFriend(uin) == nil {
return Failed(100, "FRIEND_NOT_FOUND", "好友不存在")
}
if err := bot.Client.DeleteFriend(uin); err != nil {
log.Errorf("删除好友时出现错误: %v", err)
return Failed(100, "DELETE_API_ERROR", err.Error())
}
return OK(nil)
}
// CQGetGroupList 获取群列表
//
// https://git.io/Jtz1t

1
go.sum
View File

@ -13,7 +13,6 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gin-contrib/pprof v1.3.0 h1:G9eK6HnbkSqDZBYbzG4wrjCsA4e+cvYAHUZw6W+W9K0=
github.com/gin-contrib/pprof v1.3.0/go.mod h1:waMjT1H9b179t3CxuG1cV3DHpga6ybizwfBaM5OXaB0=

View File

@ -32,6 +32,10 @@ func getFriendList(bot *coolq.CQBot, _ resultGetter) coolq.MSG {
return bot.CQGetFriendList()
}
func deleteFriend(bot *coolq.CQBot, p resultGetter) coolq.MSG {
return bot.CQDeleteFriend(p.Get("id").Int())
}
func getGroupList(bot *coolq.CQBot, p resultGetter) coolq.MSG {
return bot.CQGetGroupList(p.Get("no_cache").Bool())
}
@ -350,6 +354,7 @@ func setModelShow(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,
"delete_friend": deleteFriend,
"get_group_list": getGroupList,
"get_group_info": getGroupInfo,
"get_group_member_list": getGroupMemberList,