diff --git a/coolq/api.go b/coolq/api.go index 5d7a4ac..e0f7922 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -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 diff --git a/go.sum b/go.sum index bc972bf..07e8950 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/server/api.go b/server/api.go index 9021f4c..206ff9e 100644 --- a/server/api.go +++ b/server/api.go @@ -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,