feat(onebot): backfill semantic roles across action params

Phase 1 of the debug-console expansion. Sweeps the 8 action files,
swapping bare coercion primitives for the role-stamped equivalents from
Phase 0 (or appending `.role()` where a `.default()`/`.optional()` field
must keep its exact coercion). Coercion is byte-for-byte unchanged; the
only intentional bound change is face_id min 1→0 (QQ face 0 is valid).

Classification (verified against each run()):
- group_id → f.groupId() everywhere.
- user_id → f.userId() for any-user / friend / stranger / private-route
  targets (send_private, friend poke, friend add/remove, stranger info,
  private file transfer, forward-to-friend, share-contact).
- user_id → f.memberId() only when it's a member of a sibling group_id
  (batch kick elements; the groupUserAction preset already injects it).
- media file/image/record + file_id → f.file()/image()/record()/fileId()
  (or .role() when defaulted/optional); message_id/timestamp/duration via
  the constructor or .role() hatch as coercion requires.

Polymorphic ids left as bare uint on purpose (no single role can honestly
describe them): mark_msg_as_read.target_id (group# or uin), bot_appid,
msg_seq, fileset_id, folder_id, chunk indices, stream_id.

Catalog regenerated: 71 group_id / 25 user_id / 9 member_id / 19
message_id / 11 file_id / 7 image / 6 file roles surfaced. Done by 4
parallel agents; adversarially reviewed — zero coercion regressions,
zero member/user misclassifications.
This commit is contained in:
DrSmoothl committed 2026-06-30 16:00:21 +08:00
1 parent 14a61f4ce8
commit f9900053b0
10 files changed
+551 -259

No files matched your search

File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+43 -43
View File
@@ -141,7 +141,7 @@ export const actions = [
name: 'send_like', name: 'send_like',
summary: '点赞', summary: '点赞',
params: { params: {
user_id: f.uint(), user_id: f.userId(),
// 原实现用 `asNumber(times) || 1`,present 0 会被当作缺省 1。 // 原实现用 `asNumber(times) || 1`,present 0 会被当作缺省 1。
times: f.int({ min: 0 }).default(1), times: f.int({ min: 0 }).default(1),
}, },
@@ -155,8 +155,8 @@ export const actions = [
name: 'friend_poke', name: 'friend_poke',
summary: '好友拍一拍', summary: '好友拍一拍',
params: { params: {
user_id: f.uint(), user_id: f.userId(),
target_id: f.uint().optional(), target_id: f.userId().optional(),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
await ctx.bridge.apis.interaction.sendPoke(false, p.user_id, p.target_id); await ctx.bridge.apis.interaction.sendPoke(false, p.user_id, p.target_id);
@@ -177,8 +177,8 @@ export const actions = [
name: 'send_poke', name: 'send_poke',
summary: '拍一拍(群聊/私聊自动路由)', summary: '拍一拍(群聊/私聊自动路由)',
params: { params: {
user_id: f.uint(), user_id: f.userId(),
group_id: f.uint().optional(), group_id: f.groupId().optional(),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
if (p.group_id) { if (p.group_id) {
@@ -233,7 +233,7 @@ export const actions = [
name: 'set_group_reaction', name: 'set_group_reaction',
summary: '群聊表情回应', summary: '群聊表情回应',
params: { params: {
group_id: f.uint().optional(), group_id: f.groupId().optional(),
message_id: f.messageId(), message_id: f.messageId(),
code: f.string({ allowEmpty: false }), code: f.string({ allowEmpty: false }),
is_set: f.bool().default(true), is_set: f.bool().default(true),
@@ -272,7 +272,7 @@ export const actions = [
defineAction({ defineAction({
name: 'add_custom_face', name: 'add_custom_face',
summary: '添加收藏表情', summary: '添加收藏表情',
params: { file: f.string({ allowEmpty: false }) }, params: { file: f.image() },
run: async (p, ctx) => { run: async (p, ctx) => {
try { try {
const emojiId = await ctx.bridge.apis.profile.addCustomFace(p.file); const emojiId = await ctx.bridge.apis.profile.addCustomFace(p.file);
@@ -339,7 +339,7 @@ export const actions = [
// param-validation time (retcode 1400) before run() ever fires. Use a // param-validation time (retcode 1400) before run() ever fires. Use a
// plain signed int; `.default(0)` keeps absent/present-0 → "fetch latest" // plain signed int; `.default(0)` keeps absent/present-0 → "fetch latest"
// (matches the original `asNumber(message_id) || 0`). `count` stays ≥0. // (matches the original `asNumber(message_id) || 0`). `count` stays ≥0.
message_id: f.int().default(0), message_id: f.int().default(0).role('message_id'),
count: f.int({ min: 0 }).default(20), count: f.int({ min: 0 }).default(20),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
@@ -361,9 +361,9 @@ export const actions = [
required: ['messages'], required: ['messages'],
}, },
params: { params: {
user_id: f.uint(), user_id: f.userId(),
// Signed int32 hash, frequently negative — see get_group_msg_history. // Signed int32 hash, frequently negative — see get_group_msg_history.
message_id: f.int().default(0), message_id: f.int().default(0).role('message_id'),
count: f.int({ min: 0 }).default(20), count: f.int({ min: 0 }).default(20),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
@@ -378,7 +378,7 @@ export const actions = [
summary: '标记群消息已读', summary: '标记群消息已读',
params: { params: {
message_id: f.messageId(), message_id: f.messageId(),
group_id: f.uint().optional(), group_id: f.groupId().optional(),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
const meta = ctx.getMessageMeta(p.message_id); const meta = ctx.getMessageMeta(p.message_id);
@@ -400,7 +400,7 @@ export const actions = [
summary: '标记私聊消息已读', summary: '标记私聊消息已读',
params: { params: {
message_id: f.messageId(), message_id: f.messageId(),
user_id: f.uint().optional(), user_id: f.userId().optional(),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
const meta = ctx.getMessageMeta(p.message_id); const meta = ctx.getMessageMeta(p.message_id);
@@ -447,7 +447,7 @@ export const actions = [
summary: '发送群公告', summary: '发送群公告',
params: { params: {
content: f.string({ allowEmpty: false }), content: f.string({ allowEmpty: false }),
image: f.string().default(''), image: f.string().default('').role('image'),
pinned: f.raw(), pinned: f.raw(),
type: f.raw(), type: f.raw(),
confirm_required: f.raw(), confirm_required: f.raw(),
@@ -490,7 +490,7 @@ export const actions = [
params: { params: {
messages: f.message().optional(), messages: f.message().optional(),
message: f.message().optional(), message: f.message().optional(),
group_id: f.uint().optional(), group_id: f.groupId().optional(),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
const messages = p.messages ?? p.message; const messages = p.messages ?? p.message;
@@ -514,7 +514,7 @@ export const actions = [
params: { params: {
messages: f.message().optional(), messages: f.message().optional(),
message: f.message().optional(), message: f.message().optional(),
group_id: f.uint().optional(), group_id: f.groupId().optional(),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
const messages = p.messages ?? p.message; const messages = p.messages ?? p.message;
@@ -531,8 +531,8 @@ export const actions = [
summary: '获取图片信息', summary: '获取图片信息',
readOnly: true, readOnly: true,
params: { params: {
file: f.string().default(''), file: f.string().default('').role('image'),
file_id: f.string().default(''), file_id: f.string().default('').role('file_id'),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
const file = p.file || p.file_id; const file = p.file || p.file_id;
@@ -548,8 +548,8 @@ export const actions = [
summary: '获取语音信息', summary: '获取语音信息',
readOnly: true, readOnly: true,
params: { params: {
file: f.string().default(''), file: f.string().default('').role('record'),
file_id: f.string().default(''), file_id: f.string().default('').role('file_id'),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
const file = p.file || p.file_id; const file = p.file || p.file_id;
@@ -574,7 +574,7 @@ export const actions = [
required: ['text'], required: ['text'],
}, },
params: { params: {
message_id: f.string().default(''), message_id: f.string().default('').role('message_id'),
}, },
// `raw` so message_id works whether the client sends a number or a string. // `raw` so message_id works whether the client sends a number or a string.
run: async (_p, ctx, raw) => { run: async (_p, ctx, raw) => {
@@ -684,7 +684,7 @@ export const actions = [
name: 'set_friend_remark', name: 'set_friend_remark',
summary: '设置好友备注', summary: '设置好友备注',
params: { params: {
user_id: f.uint(), user_id: f.userId(),
remark: f.string(), remark: f.string(),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
@@ -697,7 +697,7 @@ export const actions = [
name: 'set_group_remark', name: 'set_group_remark',
summary: '设置群备注', summary: '设置群备注',
params: { params: {
group_id: f.uint(), group_id: f.groupId(),
remark: f.string(), remark: f.string(),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
@@ -822,7 +822,7 @@ export const actions = [
name: 'set_diy_online_status', name: 'set_diy_online_status',
summary: '设置自定义在线状态', summary: '设置自定义在线状态',
params: { params: {
face_id: f.uint(), face_id: f.faceId(),
// 原实现用 `asNumber(face_type) || 1`,present 0 会被当作缺省 1。 // 原实现用 `asNumber(face_type) || 1`,present 0 会被当作缺省 1。
face_type: f.int({ min: 0 }).default(1), face_type: f.int({ min: 0 }).default(1),
wording: f.string().default(''), wording: f.string().default(''),
@@ -979,7 +979,7 @@ export const actions = [
summary: '转发单条消息给好友', summary: '转发单条消息给好友',
params: { params: {
message_id: f.messageId(), message_id: f.messageId(),
user_id: f.uint(), user_id: f.userId(),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
try { try {
@@ -996,7 +996,7 @@ export const actions = [
summary: '转发单条消息到群', summary: '转发单条消息到群',
params: { params: {
message_id: f.messageId(), message_id: f.messageId(),
group_id: f.uint(), group_id: f.groupId(),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
try { try {
@@ -1044,7 +1044,7 @@ export const actions = [
}, },
params: { params: {
// 原实现 user_id 经 asNumber,无校验(0 也透传)。 // 原实现 user_id 经 asNumber,无校验(0 也透传)。
user_id: f.int({ min: 0 }).default(0), user_id: f.int({ min: 0 }).default(0).role('user_id'),
start: f.int({ min: 0 }).default(0), start: f.int({ min: 0 }).default(0),
count: f.int({ min: 0 }).default(10), count: f.int({ min: 0 }).default(10),
}, },
@@ -1367,8 +1367,8 @@ export const actions = [
required: ['arkMsg'], required: ['arkMsg'],
}, },
params: { params: {
user_id: f.uint().optional(), user_id: f.userId().optional(),
group_id: f.uint().optional(), group_id: f.groupId().optional(),
phone_number: f.string().default(''), phone_number: f.string().default(''),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
@@ -1398,8 +1398,8 @@ export const actions = [
required: ['arkMsg'], required: ['arkMsg'],
}, },
params: { params: {
user_id: f.uint().optional(), user_id: f.userId().optional(),
group_id: f.uint().optional(), group_id: f.groupId().optional(),
phone_number: f.string().default(''), phone_number: f.string().default(''),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
@@ -1427,7 +1427,7 @@ export const actions = [
readOnly: true, readOnly: true,
returns: '服务端生成的群推荐 Ark 卡片 JSON 字符串。', returns: '服务端生成的群推荐 Ark 卡片 JSON 字符串。',
returnsSchema: { type: 'string', description: '群 Ark 卡片 JSON 字符串' }, returnsSchema: { type: 'string', description: '群 Ark 卡片 JSON 字符串' },
params: { group_id: f.uint() }, params: { group_id: f.groupId() },
run: async (p, ctx) => { run: async (p, ctx) => {
try { try {
return okResponse(await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id)); return okResponse(await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id));
@@ -1442,7 +1442,7 @@ export const actions = [
readOnly: true, readOnly: true,
returns: '服务端生成的群推荐 Ark 卡片 JSON 字符串。', returns: '服务端生成的群推荐 Ark 卡片 JSON 字符串。',
returnsSchema: { type: 'string', description: '群 Ark 卡片 JSON 字符串' }, returnsSchema: { type: 'string', description: '群 Ark 卡片 JSON 字符串' },
params: { group_id: f.uint() }, params: { group_id: f.groupId() },
run: async (p, ctx) => { run: async (p, ctx) => {
try { try {
return okResponse(await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id)); return okResponse(await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id));
@@ -1565,7 +1565,7 @@ export const actions = [
defineAction({ defineAction({
name: 'set_qq_avatar', name: 'set_qq_avatar',
summary: '设置 QQ 头像', summary: '设置 QQ 头像',
params: { file: f.string({ allowEmpty: false }) }, params: { file: f.image() },
run: async (p, ctx) => { run: async (p, ctx) => {
try { try {
await ctx.bridge.apis.profile.setAvatar(p.file); await ctx.bridge.apis.profile.setAvatar(p.file);
@@ -1580,7 +1580,7 @@ export const actions = [
name: 'set_input_status', name: 'set_input_status',
summary: '设置输入状态', summary: '设置输入状态',
params: { params: {
user_id: f.uint(), user_id: f.userId(),
// event_type 可能为 0(取消输入状态);缺省也按 0 处理(与旧 asNumber 行为一致)。 // event_type 可能为 0(取消输入状态);缺省也按 0 处理(与旧 asNumber 行为一致)。
event_type: f.int().default(0), event_type: f.int().default(0),
}, },
@@ -1598,7 +1598,7 @@ export const actions = [
name: 'get_group_info_ex', name: 'get_group_info_ex',
summary: '获取群信息(扩展)', summary: '获取群信息(扩展)',
readOnly: true, readOnly: true,
params: { group_id: f.uint() }, params: { group_id: f.groupId() },
run: async (p, ctx) => { run: async (p, ctx) => {
if (ctx.getGroupInfo) { if (ctx.getGroupInfo) {
return okResponse(await ctx.getGroupInfo(p.group_id)); return okResponse(await ctx.getGroupInfo(p.group_id));
@@ -1611,7 +1611,7 @@ export const actions = [
name: 'get_group_detail_info', name: 'get_group_detail_info',
summary: '获取群详细信息', summary: '获取群详细信息',
readOnly: true, readOnly: true,
params: { group_id: f.uint() }, params: { group_id: f.groupId() },
run: async (p, ctx) => { run: async (p, ctx) => {
if (ctx.getGroupInfo) { if (ctx.getGroupInfo) {
return okResponse(await ctx.getGroupInfo(p.group_id)); return okResponse(await ctx.getGroupInfo(p.group_id));
@@ -1644,8 +1644,8 @@ export const actions = [
summary: '获取文件信息(仅图片/语音缓存;群文件请用 get_group_file_url)', summary: '获取文件信息(仅图片/语音缓存;群文件请用 get_group_file_url)',
readOnly: true, readOnly: true,
params: { params: {
file_id: f.string().default(''), file_id: f.string().default('').role('file_id'),
file: f.string().default(''), file: f.string().default('').role('file'),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
const fileId = p.file || p.file_id; const fileId = p.file || p.file_id;
@@ -1712,7 +1712,7 @@ export const actions = [
}, },
required: ['status', 'ext_status'], required: ['status', 'ext_status'],
}, },
params: { user_id: f.uint() }, params: { user_id: f.userId() },
run: async (p, ctx) => { run: async (p, ctx) => {
const status = await ctx.bridge.apis.extras.getStrangerStatus(p.user_id); const status = await ctx.bridge.apis.extras.getStrangerStatus(p.user_id);
if (!status) return failedResponse(RETCODE.ACTION_FAILED, 'failed to fetch user status'); if (!status) return failedResponse(RETCODE.ACTION_FAILED, 'failed to fetch user status');
@@ -1934,7 +1934,7 @@ export const actions = [
}, },
required: ['texts', 'language'], required: ['texts', 'language'],
}, },
params: { image: f.string({ allowEmpty: false }) }, params: { image: f.image() },
run: async (p, ctx) => { run: async (p, ctx) => {
// A passed-in http(s) URL is used verbatim (NOT re-signed) — if it is a // A passed-in http(s) URL is used verbatim (NOT re-signed) — if it is a
// stale CDN URL with an expired rkey the server fetch fails and surfaces // stale CDN URL with an expired rkey the server fetch fails and surfaces
@@ -2022,7 +2022,7 @@ export const actions = [
name: 'send_private_forward_msg', name: 'send_private_forward_msg',
summary: '发送私聊合并转发', summary: '发送私聊合并转发',
returns: '{ message_id, res_id, forward_id }', returns: '{ message_id, res_id, forward_id }',
params: { user_id: f.uint(), messages: f.message().optional(), message: f.message().optional() }, params: { user_id: f.userId(), messages: f.message().optional(), message: f.message().optional() },
run: async (p, ctx, raw) => { run: async (p, ctx, raw) => {
const messages = p.messages ?? p.message; const messages = p.messages ?? p.message;
if (messages === undefined) return failedResponse(RETCODE.BAD_REQUEST, 'message/messages is required'); if (messages === undefined) return failedResponse(RETCODE.BAD_REQUEST, 'message/messages is required');
@@ -2407,8 +2407,8 @@ export const actions = [
returns: '{ message_id }', returns: '{ message_id }',
params: { params: {
fileset_id: f.string({ allowEmpty: false }), fileset_id: f.string({ allowEmpty: false }),
user_id: f.uint().optional(), user_id: f.userId().optional(),
group_id: f.uint().optional(), group_id: f.groupId().optional(),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
if (!p.user_id && !p.group_id) { if (!p.user_id && !p.group_id) {
+2 -2
View File
@@ -46,7 +46,7 @@ export const actions = [
}, },
required: ['user_id', 'nickname', 'sex', 'age'], required: ['user_id', 'nickname', 'sex', 'age'],
}, },
params: { user_id: f.uint().describe('QQ 号') }, params: { user_id: f.userId().describe('QQ 号') },
run: async (p, ctx) => { run: async (p, ctx) => {
const userId = p.user_id; const userId = p.user_id;
if (ctx.getStrangerInfo) { if (ctx.getStrangerInfo) {
@@ -60,7 +60,7 @@ export const actions = [
defineAction({ defineAction({
name: 'delete_friend', name: 'delete_friend',
summary: '删除好友', summary: '删除好友',
params: { user_id: f.uint().describe('QQ 号'), block: f.bool().default(false) }, params: { user_id: f.userId().describe('QQ 号'), block: f.bool().default(false) },
run: async (p, ctx) => { run: async (p, ctx) => {
await ctx.bridge.apis.friend.delete(p.user_id, p.block); await ctx.bridge.apis.friend.delete(p.user_id, p.block);
return okResponse(); return okResponse();
+3 -3
View File
@@ -16,7 +16,7 @@ export const actions = [
groupAction({ groupAction({
name: 'set_group_kick_members', name: 'set_group_kick_members',
summary: '批量踢出群成员', summary: '批量踢出群成员',
params: { user_id: f.array(f.uint()).nonEmpty(), reject_add_request: f.bool().default(false) }, params: { user_id: f.array(f.memberId()).nonEmpty(), reject_add_request: f.bool().default(false) },
run: async (p, ctx) => { run: async (p, ctx) => {
await ctx.bridge.apis.groupAdmin.kickMembers(p.group_id, p.user_id, p.reject_add_request); await ctx.bridge.apis.groupAdmin.kickMembers(p.group_id, p.user_id, p.reject_add_request);
return okResponse(); return okResponse();
@@ -26,7 +26,7 @@ export const actions = [
groupUserAction({ groupUserAction({
name: 'set_group_ban', name: 'set_group_ban',
summary: '禁言群成员(duration=0 解除)', summary: '禁言群成员(duration=0 解除)',
params: { duration: f.int({ min: 0 }).default(1800) }, params: { duration: f.duration().default(1800) },
run: async (p, ctx) => { run: async (p, ctx) => {
await ctx.bridge.apis.groupAdmin.muteMember(p.group_id, p.user_id, p.duration); await ctx.bridge.apis.groupAdmin.muteMember(p.group_id, p.user_id, p.duration);
return okResponse(); return okResponse();
@@ -118,7 +118,7 @@ export const actions = [
groupAction({ groupAction({
name: 'set_group_portrait', name: 'set_group_portrait',
summary: '设置群头像', summary: '设置群头像',
params: { file: f.string({ allowEmpty: false }) }, params: { file: f.image() },
run: async (p, ctx) => { run: async (p, ctx) => {
try { try {
await ctx.bridge.apis.profile.setGroupAvatar(p.group_id, p.file); await ctx.bridge.apis.profile.setGroupAvatar(p.group_id, p.file);
+1 -1
View File
@@ -91,7 +91,7 @@ export const actions = [
params: { params: {
album_id: f.string({ allowEmpty: false }), album_id: f.string({ allowEmpty: false }),
album_name: f.string({ allowEmpty: false }), album_name: f.string({ allowEmpty: false }),
file: f.string({ allowEmpty: false }), file: f.image(),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
try { try {
+9 -9
View File
@@ -26,7 +26,7 @@ export const actions = [
// non-empty wins, else '/'. Both default '' so the `||` chain matches the // non-empty wins, else '/'. Both default '' so the `||` chain matches the
// legacy `asString(folder) || asString(folder_id) || '/'`. // legacy `asString(folder) || asString(folder_id) || '/'`.
params: { params: {
file: f.string({ allowEmpty: false }), file: f.file(),
name: f.string().default(''), name: f.string().default(''),
folder: f.string().default(''), folder: f.string().default(''),
folder_id: f.string().default(''), folder_id: f.string().default(''),
@@ -44,8 +44,8 @@ export const actions = [
summary: '上传私聊文件', summary: '上传私聊文件',
returns: '{ file_id: string }', returns: '{ file_id: string }',
params: { params: {
user_id: f.uint(), user_id: f.userId(),
file: f.string({ allowEmpty: false }), file: f.file(),
name: f.string().default(''), name: f.string().default(''),
upload_file: f.bool().default(true), upload_file: f.bool().default(true),
}, },
@@ -67,7 +67,7 @@ export const actions = [
}, },
// busid is accepted but tolerant (see busidOr102): NapCat/LLBot ignore it, // busid is accepted but tolerant (see busidOr102): NapCat/LLBot ignore it,
// so a present null/empty/non-numeric value must not 400 the request (#147). // so a present null/empty/non-numeric value must not 400 the request (#147).
params: { file_id: f.string({ allowEmpty: false }), busid: f.raw() }, params: { file_id: f.fileId(), busid: f.raw() },
run: async (p, ctx) => { run: async (p, ctx) => {
return okResponse({ url: await ctx.bridge.apis.groupFile.getUrl(p.group_id, p.file_id, busidOr102(p.busid)) }); return okResponse({ url: await ctx.bridge.apis.groupFile.getUrl(p.group_id, p.file_id, busidOr102(p.busid)) });
}, },
@@ -183,7 +183,7 @@ export const actions = [
groupAction({ groupAction({
name: 'delete_group_file', name: 'delete_group_file',
summary: '删除群文件', summary: '删除群文件',
params: { file_id: f.string({ allowEmpty: false }) }, params: { file_id: f.fileId() },
run: async (p, ctx) => { run: async (p, ctx) => {
await ctx.bridge.apis.groupFile.delete(p.group_id, p.file_id); await ctx.bridge.apis.groupFile.delete(p.group_id, p.file_id);
return okResponse(); return okResponse();
@@ -194,7 +194,7 @@ export const actions = [
name: 'move_group_file', name: 'move_group_file',
summary: '移动群文件', summary: '移动群文件',
params: { params: {
file_id: f.string({ allowEmpty: false }), file_id: f.fileId(),
parent_directory: f.string({ allowEmpty: false }), parent_directory: f.string({ allowEmpty: false }),
target_directory: f.string({ allowEmpty: false }), target_directory: f.string({ allowEmpty: false }),
}, },
@@ -210,7 +210,7 @@ export const actions = [
name: 'rename_group_file', name: 'rename_group_file',
summary: '重命名群文件', summary: '重命名群文件',
params: { params: {
file_id: f.string({ allowEmpty: false }), file_id: f.fileId(),
current_parent_directory: f.string().default('/'), current_parent_directory: f.string().default('/'),
new_name: f.string({ allowEmpty: false }), new_name: f.string({ allowEmpty: false }),
}, },
@@ -276,8 +276,8 @@ export const actions = [
// clients that only persist file_id, both user_id and file_hash are now // clients that only persist file_id, both user_id and file_hash are now
// optional; file_hash falls through empty when absent. See issue #147. // optional; file_hash falls through empty when absent. See issue #147.
params: { params: {
user_id: f.uint().optional(), user_id: f.userId().optional(),
file_id: f.string({ allowEmpty: false }), file_id: f.fileId(),
file_hash: f.string().default(''), file_hash: f.string().default(''),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
+3 -3
View File
@@ -47,8 +47,8 @@ export const actions = [
params: { params: {
message: f.message(), message: f.message(),
message_type: f.string().optional(), message_type: f.string().optional(),
group_id: f.uint().optional(), group_id: f.groupId().optional(),
user_id: f.uint().optional(), user_id: f.userId().optional(),
auto_escape: f.bool().default(false), auto_escape: f.bool().default(false),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
@@ -67,7 +67,7 @@ export const actions = [
name: 'send_private_msg', name: 'send_private_msg',
summary: '发送私聊消息', summary: '发送私聊消息',
returns: '{ message_id: number }', returns: '{ message_id: number }',
params: { user_id: f.uint(), message: f.message(), auto_escape: f.bool().default(false) }, params: { user_id: f.userId(), message: f.message(), auto_escape: f.bool().default(false) },
run: async (p, ctx) => { run: async (p, ctx) => {
const result = await ctx.sendPrivateMessage(p.user_id, p.message, p.auto_escape); const result = await ctx.sendPrivateMessage(p.user_id, p.message, p.auto_escape);
return okResponse({ message_id: result.messageId }); return okResponse({ message_id: result.messageId });
+6 -6
View File
@@ -54,7 +54,7 @@ export const actions = [
}, },
summary: '获取 QQ 空间说说列表(默认机器人自己的空间)', summary: '获取 QQ 空间说说列表(默认机器人自己的空间)',
params: { params: {
target_uin: f.uint().describe('目标 QQ 号,省略则取机器人自己').optional(), target_uin: f.userId().describe('目标 QQ 号,省略则取机器人自己').optional(),
pos: f.int({ min: 0 }).describe('起始偏移').default(0), pos: f.int({ min: 0 }).describe('起始偏移').default(0),
num: f.int({ min: 1, max: 100 }).describe('本页数量').default(20), num: f.int({ min: 1, max: 100 }).describe('本页数量').default(20),
}, },
@@ -167,8 +167,8 @@ export const actions = [
summary: '给一条说说点赞(QQ 空间)', summary: '给一条说说点赞(QQ 空间)',
params: { params: {
tid: f.string({ allowEmpty: false }).describe('说说 tid'), tid: f.string({ allowEmpty: false }).describe('说说 tid'),
target_uin: f.uint().describe('说说所属 QQ 号,省略则为机器人自己').optional(), target_uin: f.userId().describe('说说所属 QQ 号,省略则为机器人自己').optional(),
abstime: f.int({ min: 0 }).describe('说说发表时间(unix 秒),传真实值更可靠').default(0), abstime: f.int({ min: 0 }).describe('说说发表时间(unix 秒),传真实值更可靠').default(0).role('timestamp'),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
try { try {
@@ -188,8 +188,8 @@ export const actions = [
summary: '取消对一条说说的点赞(QQ 空间;取消赞端点待真机核实)', summary: '取消对一条说说的点赞(QQ 空间;取消赞端点待真机核实)',
params: { params: {
tid: f.string({ allowEmpty: false }).describe('说说 tid'), tid: f.string({ allowEmpty: false }).describe('说说 tid'),
target_uin: f.uint().describe('说说所属 QQ 号,省略则为机器人自己').optional(), target_uin: f.userId().describe('说说所属 QQ 号,省略则为机器人自己').optional(),
abstime: f.int({ min: 0 }).describe('说说发表时间(unix 秒),传真实值更可靠').default(0), abstime: f.int({ min: 0 }).describe('说说发表时间(unix 秒),传真实值更可靠').default(0).role('timestamp'),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
try { try {
@@ -211,7 +211,7 @@ export const actions = [
params: { params: {
tid: f.string({ allowEmpty: false }).describe('说说 tid'), tid: f.string({ allowEmpty: false }).describe('说说 tid'),
content: f.string({ allowEmpty: false }).describe('评论内容'), content: f.string({ allowEmpty: false }).describe('评论内容'),
target_uin: f.uint().describe('说说所属 QQ 号,省略则为机器人自己').optional(), target_uin: f.userId().describe('说说所属 QQ 号,省略则为机器人自己').optional(),
images: f.array(f.string({ allowEmpty: false })).describe('图片数组(可选),支持 file:// http:// base64://;自动上传').optional(), images: f.array(f.string({ allowEmpty: false })).describe('图片数组(可选),支持 file:// http:// base64://;自动上传').optional(),
}, },
run: async (p, ctx) => { run: async (p, ctx) => {
@@ -325,8 +325,8 @@ async function runDownload(
// ─────────────────────────── action definitions ─────────────────────────── // ─────────────────────────── action definitions ───────────────────────────
const downloadParams = { const downloadParams = {
file: f.string().optional().describe('文件路径(限 stream 临时目录)/ http(s) URL'), file: f.string().optional().describe('文件路径(限 stream 临时目录)/ http(s) URL').role('file'),
file_id: f.string().optional().describe('文件 ID(缓存的图片/语音 id)'), file_id: f.string().optional().describe('文件 ID(缓存的图片/语音 id)').role('file_id'),
chunk_size: f.int({ min: 1 }).optional().describe('分块大小(字节,默认 64KB)'), chunk_size: f.int({ min: 1 }).optional().describe('分块大小(字节,默认 64KB)'),
}; };