Skip to content

Commit

Permalink
feat: get_rkey
Browse files Browse the repository at this point in the history
  • Loading branch information
Fripine committed Oct 11, 2024
1 parent 39997d5 commit 2092df2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions coolq/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,22 @@ func (bot *CQBot) CQGetSupportedActions(spec *onebot.Spec) global.MSG {
return OK(spec.SupportedActions)
}

// CQGetRkey 获取Rkey
//
// @route(get_rkey)
func (bot *CQBot) CQGetRkey() global.MSG {
rkeys, err := bot.Client.FetchRkey()
if err != nil || len(rkeys) < 2 {
return Failed(100, "GET_RKEY_ERROR", err.Error())
}
return OK(global.MSG{
"private_rkey": rkeys[10].RKey,
"group_rkey": rkeys[20].RKey,
"create_time": rkeys[10].CreateTime,
"expire_time": rkeys[10].ExpireTime,
})
}

// OK 生成成功返回值
func OK(data any) global.MSG {
return global.MSG{"data": data, "retcode": 0, "status": "ok", "message": ""}
Expand Down
2 changes: 2 additions & 0 deletions modules/api/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/onebot/supported.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2092df2

Please sign in to comment.