From 6b33e2855cdd6340788e97cb097b637471f7fc6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=87=E8=91=A9=E3=81=AE=E7=81=B5=E6=A2=A6?= Date: Sun, 25 Aug 2024 13:28:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E7=94=A8=E6=88=B7=E5=85=B3?= =?UTF-8?q?=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- user.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/user.go b/user.go index ddafd8e..a7c2308 100644 --- a/user.go +++ b/user.go @@ -631,3 +631,31 @@ func (c *Client) GetBlacks(param GetBlacksParam) (*GetBlacksResult, error) { ) return execute[*GetBlacksResult](c, method, url, param) } + +type ModifyRelationAct int + +const ( + ModifyRelationActFollow ModifyRelationAct = iota + 1 // 关注,无法对已注销或不存在的用户进行此操作 + ModifyRelationActUnfollow // 取关 + ModifyRelationActWhisper // 悄悄关注,现已下线,使用本操作代码请求接口会提示“请求错误” + ModifyRelationActUnwhisper // 取消悄悄关注 + ModifyRelationActBlack // 拉黑 + ModifyRelationActUnblack // 取消拉黑 + ModifyRelationActUnfollower // 踢出粉丝 +) + +type ModifyRelationParam struct { + Fid int `json:"fid"` // 目标用户mid + Act ModifyRelationAct `json:"act"` // 操作代码 + ReSrc int `json:"re_src"` // 关注来源代码。空间:11。视频:14。文章:115。活动页面:222 +} + +// ModifyRelation 操作用户关系 +func (c *Client) ModifyRelation(param ModifyRelationParam) error { + const ( + method = resty.MethodPost + url = "https://api.bilibili.com/x/relation/modify" + ) + _, err := execute[any](c, method, url, param, fillCsrf(c)) + return err +}