mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-06 12:03:50 +08:00
feat: delete_unidirectional_friend.
This commit is contained in:
parent
757661bcf7
commit
59209068bf
21
coolq/api.go
21
coolq/api.go
@ -92,6 +92,27 @@ func (bot *CQBot) CQGetUnidirectionalFriendList() MSG {
|
||||
return OK(fs)
|
||||
}
|
||||
|
||||
// CQDeleteUnidirectionalFriend 删除单向好友
|
||||
//
|
||||
//
|
||||
func (bot *CQBot) CQDeleteUnidirectionalFriend(uin int64) MSG {
|
||||
list, err := bot.Client.GetUnidirectionalFriendList()
|
||||
if err != nil {
|
||||
log.Errorf("获取单向好友列表时出现错误: %v", err)
|
||||
return Failed(100, "API_ERROR", err.Error())
|
||||
}
|
||||
for _, f := range list {
|
||||
if f.Uin == uin {
|
||||
if err = bot.Client.DeleteUnidirectionalFriend(uin); err != nil {
|
||||
log.Errorf("删除单向好友时出现错误: %v", err)
|
||||
return Failed(100, "API_ERROR", err.Error())
|
||||
}
|
||||
return OK(nil)
|
||||
}
|
||||
}
|
||||
return Failed(100, "FRIEND_NOT_FOUND", "好友不存在")
|
||||
}
|
||||
|
||||
// CQDeleteFriend 删除好友
|
||||
//
|
||||
//
|
||||
|
2
go.mod
2
go.mod
@ -7,7 +7,7 @@ replace github.com/willf/bitset v1.2.0 => github.com/bits-and-blooms/bitset v1.2
|
||||
require (
|
||||
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f
|
||||
github.com/Microsoft/go-winio v0.5.0
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20210916073323-f70f9df5e4f9
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20210916095246-e1502ecb48e1
|
||||
github.com/dustin/go-humanize v1.0.0
|
||||
github.com/gabriel-vasile/mimetype v1.3.1
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
|
4
go.sum
4
go.sum
@ -4,8 +4,8 @@ github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f/g
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXGjwU=
|
||||
github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20210916073323-f70f9df5e4f9 h1:QU5b//vKJeWmIWhdy09yjW8khUyyndop4NJgrk9Oo7c=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20210916073323-f70f9df5e4f9/go.mod h1:EpB6wQ+iaIqLRxVrs6si2J3XGv6wHXMrRXNUnJFaoww=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20210916095246-e1502ecb48e1 h1:E8iscz9XxN3DweLUVJQxgxmI1xXUUDBdmCmKoWUeA0w=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20210916095246-e1502ecb48e1/go.mod h1:EpB6wQ+iaIqLRxVrs6si2J3XGv6wHXMrRXNUnJFaoww=
|
||||
github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA=
|
||||
github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
|
@ -37,7 +37,11 @@ func getUnidirectionalFriendList(bot *coolq.CQBot, _ resultGetter) coolq.MSG {
|
||||
}
|
||||
|
||||
func deleteFriend(bot *coolq.CQBot, p resultGetter) coolq.MSG {
|
||||
return bot.CQDeleteFriend(p.Get("id").Int())
|
||||
return bot.CQDeleteFriend(p.Get("[user_id,id]").Int())
|
||||
}
|
||||
|
||||
func deleteUnidirectionalFriend(bot *coolq.CQBot, p resultGetter) coolq.MSG {
|
||||
return bot.CQDeleteUnidirectionalFriend(p.Get("user_id").Int())
|
||||
}
|
||||
|
||||
func getGroupList(bot *coolq.CQBot, p resultGetter) coolq.MSG {
|
||||
@ -364,6 +368,7 @@ var API = map[string]func(*coolq.CQBot, resultGetter) coolq.MSG{
|
||||
"get_friend_list": getFriendList,
|
||||
"get_unidirectional_friend_list": getUnidirectionalFriendList,
|
||||
"delete_friend": deleteFriend,
|
||||
"delete_unidirectional_friend": deleteUnidirectionalFriend,
|
||||
"get_group_list": getGroupList,
|
||||
"get_group_info": getGroupInfo,
|
||||
"get_group_member_list": getGroupMemberList,
|
||||
|
Loading…
x
Reference in New Issue
Block a user