feat(onebot): backfill returnsSchema on representative read-only actions

This commit is contained in:
DrSmoothl committed 2026-06-26 22:03:42 +08:00
1 parent 355cce1e52
commit 18014fb3c5
2 files changed
+57

No files matched your search

+29
View File
@@ -23,6 +23,17 @@ export const actions = [
name: 'get_group_info',
summary: '获取群信息',
readOnly: true,
returns: '群信息对象。',
returnsSchema: {
type: 'object',
properties: {
group_id: { type: 'integer', description: '群号' },
group_name: { type: 'string', description: '群名' },
member_count: { type: 'integer', description: '当前成员数' },
max_member_count: { type: 'integer', description: '成员上限' },
},
required: ['group_id', 'group_name', 'member_count', 'max_member_count'],
},
params: { no_cache: f.bool().default(false) },
run: async (p, ctx) => {
const groupId = p.group_id;
@@ -54,6 +65,24 @@ export const actions = [
name: 'get_group_member_info',
summary: '获取群成员信息',
readOnly: true,
returns: '群成员信息对象。',
returnsSchema: {
type: 'object',
properties: {
group_id: { type: 'integer', description: '群号' },
user_id: { type: 'integer', description: 'QQ 号' },
nickname: { type: 'string', description: '昵称' },
card: { type: 'string', description: '群名片' },
sex: { type: 'string', enum: ['male', 'female', 'unknown'], description: '性别' },
age: { type: 'integer', description: '年龄' },
join_time: { type: 'integer', description: '入群时间戳(秒)' },
last_sent_time: { type: 'integer', description: '最后发言时间戳(秒)' },
level: { type: 'string', description: '群等级' },
role: { type: 'string', enum: ['owner', 'admin', 'member'], description: '角色' },
title: { type: 'string', description: '专属头衔' },
},
required: ['group_id', 'user_id', 'nickname', 'role'],
},
params: { no_cache: f.bool().default(false) },
run: async (p, ctx) => {
const groupId = p.group_id;
+28
View File
@@ -9,6 +9,15 @@ export const actions = [
defineAction({
name: 'get_login_info',
readOnly: true,
returns: '当前登录账号的 QQ 号与昵称。',
returnsSchema: {
type: 'object',
properties: {
user_id: { type: 'integer', description: '登录 QQ 号' },
nickname: { type: 'string', description: '登录昵称' },
},
required: ['user_id', 'nickname'],
},
params: {},
run: (_p, ctx) => {
const login = ctx.getLoginInfo();
@@ -19,6 +28,15 @@ export const actions = [
defineAction({
name: 'get_status',
readOnly: true,
returns: '运行状态。`online`/`good` 均表示账号是否在线。',
returnsSchema: {
type: 'object',
properties: {
online: { type: 'boolean', description: '是否在线' },
good: { type: 'boolean', description: '状态是否正常(与 online 一致)' },
},
required: ['online', 'good'],
},
params: {},
run: (_p, ctx) => {
const online = ctx.isOnline();
@@ -29,6 +47,16 @@ export const actions = [
defineAction({
name: 'get_version_info',
readOnly: true,
returns: '实现与协议版本信息。',
returnsSchema: {
type: 'object',
properties: {
app_name: { type: 'string', description: '实现名称(SnowLuma)' },
app_version: { type: 'string', description: '实现版本' },
protocol_version: { type: 'string', description: 'OneBot 协议版本' },
},
required: ['app_name', 'app_version', 'protocol_version'],
},
params: {},
run: () => {
return okResponse({