refactor(onebot): drop 55 redundant ACTION_FAILED try/catch in extended actions
阶段 2b:从 extended.ts 删除 55 个「纯兜底」try/catch(catch 体恰为单条
return failedResponse(ACTION_FAILED, String(e)/e.message)),让抛错落到唯一 seam
runAction(已统一 100 + error.message)。retcode 不变(这些本就是 100),去的是
冗余包装。
- 保留:try/finally、带前缀的 catch(获取精华消息失败 / 语音转码失败)、
download_file 保存失败的 BAD_REQUEST catch、fetchFilteredGroupRequests 的
catch{return []} 吞值——均原样未动。
- 唯一文案变化:约 30 个原用 String(e) 的 catch,其 wording 由 "Error: X" 变为
seam 的裸 "X"(丢类名前缀,retcode 不变;OidbError 的服务器码仍在 message 内)
——一致化改善,无测试/契约依赖该前缀。
- onebot 全量 516 全绿、typecheck 干净;对抗性 Agent 逐块比对 HEAD 确认等价、
结构正确、无误删漏改。
This commit is contained in:
1 file changed
+179
-399
@@ -110,12 +110,8 @@ async function groupTodoRun(
|
|||||||
if (!meta.isGroup || meta.targetId !== p.group_id) {
|
if (!meta.isGroup || meta.targetId !== p.group_id) {
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, 'message does not belong to this group');
|
return failedResponse(RETCODE.ACTION_FAILED, 'message does not belong to this group');
|
||||||
}
|
}
|
||||||
try {
|
await op(p.group_id, BigInt(meta.sequence));
|
||||||
await op(p.group_id, BigInt(meta.sequence));
|
return okResponse();
|
||||||
return okResponse();
|
|
||||||
} catch (err) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, err instanceof Error ? err.message : String(err));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** FlashTransferApi 返回的 FlashFileInfo → OneBot JSON 响应(plain object,JsonObject 兼容)。
|
/** FlashTransferApi 返回的 FlashFileInfo → OneBot JSON 响应(plain object,JsonObject 兼容)。
|
||||||
@@ -259,12 +255,8 @@ export const actions = [
|
|||||||
summary: '删除收藏表情',
|
summary: '删除收藏表情',
|
||||||
params: { emoji_id: f.string({ allowEmpty: false }) },
|
params: { emoji_id: f.string({ allowEmpty: false }) },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
await ctx.bridge.apis.profile.deleteCustomFace(p.emoji_id);
|
||||||
await ctx.bridge.apis.profile.deleteCustomFace(p.emoji_id);
|
return okResponse();
|
||||||
return okResponse();
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -274,12 +266,8 @@ export const actions = [
|
|||||||
summary: '添加收藏表情',
|
summary: '添加收藏表情',
|
||||||
params: { file: f.image() },
|
params: { file: f.image() },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const emojiId = await ctx.bridge.apis.profile.addCustomFace(p.file);
|
||||||
const emojiId = await ctx.bridge.apis.profile.addCustomFace(p.file);
|
return okResponse({ emoji_id: emojiId });
|
||||||
return okResponse({ emoji_id: emojiId });
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -292,12 +280,8 @@ export const actions = [
|
|||||||
desc: f.string().default(''),
|
desc: f.string().default(''),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
await ctx.bridge.apis.profile.modifyCustomFace(p.emoji_id, p.desc);
|
||||||
await ctx.bridge.apis.profile.modifyCustomFace(p.emoji_id, p.desc);
|
return okResponse();
|
||||||
return okResponse();
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -311,12 +295,8 @@ export const actions = [
|
|||||||
summary: '收藏表情移到最前',
|
summary: '收藏表情移到最前',
|
||||||
params: { emoji_id: f.string({ allowEmpty: false }) },
|
params: { emoji_id: f.string({ allowEmpty: false }) },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
await ctx.bridge.apis.profile.moveCustomFaceToFront(p.emoji_id);
|
||||||
await ctx.bridge.apis.profile.moveCustomFaceToFront(p.emoji_id);
|
return okResponse();
|
||||||
return okResponse();
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -453,19 +433,15 @@ export const actions = [
|
|||||||
confirm_required: f.raw(),
|
confirm_required: f.raw(),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const options = {
|
||||||
const options = {
|
image: p.image || undefined,
|
||||||
image: p.image || undefined,
|
pinned: p.pinned !== undefined ? Number(p.pinned) : 0,
|
||||||
pinned: p.pinned !== undefined ? Number(p.pinned) : 0,
|
type: p.type !== undefined ? Number(p.type) : 1,
|
||||||
type: p.type !== undefined ? Number(p.type) : 1,
|
confirm_required: p.confirm_required !== undefined ? Number(p.confirm_required) : 1,
|
||||||
confirm_required: p.confirm_required !== undefined ? Number(p.confirm_required) : 1,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
await ctx.bridge.apis.web.sendNotice(p.group_id, p.content, options);
|
await ctx.bridge.apis.web.sendNotice(p.group_id, p.content, options);
|
||||||
return okResponse();
|
return okResponse();
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -474,12 +450,8 @@ export const actions = [
|
|||||||
summary: '获取群公告',
|
summary: '获取群公告',
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const notices = await ctx.bridge.apis.web.getNotice(p.group_id);
|
||||||
const notices = await ctx.bridge.apis.web.getNotice(p.group_id);
|
return okResponse(notices);
|
||||||
return okResponse(notices);
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -594,11 +566,7 @@ export const actions = [
|
|||||||
run: async (_p, ctx, raw) => {
|
run: async (_p, ctx, raw) => {
|
||||||
const messageId = asNumber(raw.message_id);
|
const messageId = asNumber(raw.message_id);
|
||||||
if (!messageId) return failedResponse(RETCODE.BAD_REQUEST, 'message_id is required');
|
if (!messageId) return failedResponse(RETCODE.BAD_REQUEST, 'message_id is required');
|
||||||
try {
|
return okResponse(await ctx.fetchPttText(messageId));
|
||||||
return okResponse(await ctx.fetchPttText(messageId));
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : '获取语音转文字结果失败');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -617,12 +585,8 @@ export const actions = [
|
|||||||
},
|
},
|
||||||
params: { domain: f.string().default('qun.qq.com') },
|
params: { domain: f.string().default('qun.qq.com') },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const cookies = await ctx.bridge.apis.web.getCookiesStr(p.domain || 'qun.qq.com');
|
||||||
const cookies = await ctx.bridge.apis.web.getCookiesStr(p.domain || 'qun.qq.com');
|
return okResponse({ cookies });
|
||||||
return okResponse({ cookies });
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -640,12 +604,8 @@ export const actions = [
|
|||||||
},
|
},
|
||||||
params: {},
|
params: {},
|
||||||
run: async (_p, ctx) => {
|
run: async (_p, ctx) => {
|
||||||
try {
|
const token = await ctx.bridge.apis.web.getCsrfToken();
|
||||||
const token = await ctx.bridge.apis.web.getCsrfToken();
|
return okResponse({ token });
|
||||||
return okResponse({ token });
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -665,12 +625,8 @@ export const actions = [
|
|||||||
},
|
},
|
||||||
params: { domain: f.string().default('qun.qq.com') },
|
params: { domain: f.string().default('qun.qq.com') },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const creds = await ctx.bridge.apis.web.getCredentials(p.domain || 'qun.qq.com');
|
||||||
const creds = await ctx.bridge.apis.web.getCredentials(p.domain || 'qun.qq.com');
|
return okResponse(creds);
|
||||||
return okResponse(creds);
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -801,12 +757,8 @@ export const actions = [
|
|||||||
const nickname = p.nickname;
|
const nickname = p.nickname;
|
||||||
const personalNote = p.personal_note;
|
const personalNote = p.personal_note;
|
||||||
|
|
||||||
try {
|
await ctx.bridge.apis.profile.setProfile(nickname, personalNote);
|
||||||
await ctx.bridge.apis.profile.setProfile(nickname, personalNote);
|
return okResponse();
|
||||||
return okResponse();
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -820,12 +772,8 @@ export const actions = [
|
|||||||
battery_status: f.int({ min: 0 }).default(100),
|
battery_status: f.int({ min: 0 }).default(100),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
await ctx.bridge.apis.profile.setOnlineStatus(p.status, p.ext_status, p.battery_status);
|
||||||
await ctx.bridge.apis.profile.setOnlineStatus(p.status, p.ext_status, p.battery_status);
|
return okResponse();
|
||||||
return okResponse();
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -842,12 +790,8 @@ export const actions = [
|
|||||||
wording: f.string().default(''),
|
wording: f.string().default(''),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
await ctx.bridge.apis.profile.setDiyOnlineStatus(p.face_id, p.wording, p.face_type);
|
||||||
await ctx.bridge.apis.profile.setDiyOnlineStatus(p.face_id, p.wording, p.face_type);
|
return okResponse();
|
||||||
return okResponse();
|
|
||||||
} catch (err) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, err instanceof Error ? err.message : String(err));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -979,12 +923,8 @@ export const actions = [
|
|||||||
summary: '获取群今日打卡列表',
|
summary: '获取群今日打卡列表',
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const list = await ctx.bridge.apis.web.getSignedList(p.group_id);
|
||||||
const list = await ctx.bridge.apis.web.getSignedList(p.group_id);
|
return okResponse(list);
|
||||||
return okResponse(list);
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -996,12 +936,8 @@ export const actions = [
|
|||||||
user_id: f.userId(),
|
user_id: f.userId(),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const result = await ctx.forwardSingleMsg(p.message_id, { userId: p.user_id });
|
||||||
const result = await ctx.forwardSingleMsg(p.message_id, { userId: p.user_id });
|
return okResponse({ message_id: result.messageId });
|
||||||
return okResponse({ message_id: result.messageId });
|
|
||||||
} catch (err) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, err instanceof Error ? err.message : String(err));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1013,12 +949,8 @@ export const actions = [
|
|||||||
group_id: f.groupId(),
|
group_id: f.groupId(),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const result = await ctx.forwardSingleMsg(p.message_id, { groupId: p.group_id });
|
||||||
const result = await ctx.forwardSingleMsg(p.message_id, { groupId: p.group_id });
|
return okResponse({ message_id: result.messageId });
|
||||||
return okResponse({ message_id: result.messageId });
|
|
||||||
} catch (err) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, err instanceof Error ? err.message : String(err));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1063,12 +995,8 @@ export const actions = [
|
|||||||
count: f.int({ min: 0 }).default(10),
|
count: f.int({ min: 0 }).default(10),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const data = await ctx.bridge.apis.profile.getLike(p.user_id, p.start, p.count);
|
||||||
const data = await ctx.bridge.apis.profile.getLike(p.user_id, p.start, p.count);
|
return okResponse(data);
|
||||||
return okResponse(data);
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1088,19 +1016,15 @@ export const actions = [
|
|||||||
return_type: f.string().default('url'),
|
return_type: f.string().default('url'),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const urls = await ctx.bridge.apis.profile.fetchCustomFace(p.count);
|
||||||
const urls = await ctx.bridge.apis.profile.fetchCustomFace(p.count);
|
if (p.return_type === 'id') {
|
||||||
if (p.return_type === 'id') {
|
const emojiIds = urls.map((url) => {
|
||||||
const emojiIds = urls.map((url) => {
|
const m = /\/qq_expression\/[^/]+\/([^/]+)\//.exec(url);
|
||||||
const m = /\/qq_expression\/[^/]+\/([^/]+)\//.exec(url);
|
return m ? m[1] : '';
|
||||||
return m ? m[1] : '';
|
}).filter(Boolean);
|
||||||
}).filter(Boolean);
|
return okResponse(emojiIds);
|
||||||
return okResponse(emojiIds);
|
|
||||||
}
|
|
||||||
return okResponse(urls);
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
}
|
||||||
|
return okResponse(urls);
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1132,14 +1056,10 @@ export const actions = [
|
|||||||
emoji_id: f.string({ allowEmpty: false }),
|
emoji_id: f.string({ allowEmpty: false }),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const result = await ctx.fetchEmojiLikeUsers(p.message_id, p.emoji_id, 1000);
|
||||||
const result = await ctx.fetchEmojiLikeUsers(p.message_id, p.emoji_id, 1000);
|
return okResponse({
|
||||||
return okResponse({
|
emoji_like_list: result.users.map(u => ({ user_id: String(u.uin), nick_name: '' })),
|
||||||
emoji_like_list: result.users.map(u => ({ user_id: String(u.uin), nick_name: '' })),
|
});
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1179,22 +1099,18 @@ export const actions = [
|
|||||||
cookie: f.string().default(''),
|
cookie: f.string().default(''),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const offset = p.cookie ? Number.parseInt(p.cookie, 10) || 0 : 0;
|
||||||
const offset = p.cookie ? Number.parseInt(p.cookie, 10) || 0 : 0;
|
const result = await ctx.fetchEmojiLikeUsers(p.message_id, p.emojiId, p.count, offset);
|
||||||
const result = await ctx.fetchEmojiLikeUsers(p.message_id, p.emojiId, p.count, offset);
|
const nextOffset = offset + result.users.length;
|
||||||
const nextOffset = offset + result.users.length;
|
const isLastPage = nextOffset >= result.cachedCount;
|
||||||
const isLastPage = nextOffset >= result.cachedCount;
|
return okResponse({
|
||||||
return okResponse({
|
result: 0,
|
||||||
result: 0,
|
errMsg: '',
|
||||||
errMsg: '',
|
emojiLikesList: result.users.map(u => ({ tinyId: String(u.uin), nickName: '', headUrl: '' })),
|
||||||
emojiLikesList: result.users.map(u => ({ tinyId: String(u.uin), nickName: '', headUrl: '' })),
|
cookie: isLastPage ? '' : String(nextOffset),
|
||||||
cookie: isLastPage ? '' : String(nextOffset),
|
isLastPage,
|
||||||
isLastPage,
|
isFirstPage: offset === 0,
|
||||||
isFirstPage: offset === 0,
|
});
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1312,12 +1228,8 @@ export const actions = [
|
|||||||
required: ['can_at_all', 'remain_at_all_count_for_group', 'remain_at_all_count_for_uin'],
|
required: ['can_at_all', 'remain_at_all_count_for_group', 'remain_at_all_count_for_uin'],
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const data = await ctx.bridge.apis.groupAdmin.getAtAllRemain(p.group_id);
|
||||||
const data = await ctx.bridge.apis.groupAdmin.getAtAllRemain(p.group_id);
|
return okResponse(data);
|
||||||
return okResponse(data);
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1327,12 +1239,8 @@ export const actions = [
|
|||||||
readOnly: true,
|
readOnly: true,
|
||||||
params: {},
|
params: {},
|
||||||
run: async (_p, ctx) => {
|
run: async (_p, ctx) => {
|
||||||
try {
|
const data = await ctx.bridge.apis.profile.getUnidirectionalFriendList();
|
||||||
const data = await ctx.bridge.apis.profile.getUnidirectionalFriendList();
|
return okResponse(data);
|
||||||
return okResponse(data);
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1386,17 +1294,13 @@ export const actions = [
|
|||||||
phone_number: f.string().default(''),
|
phone_number: f.string().default(''),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
if (p.group_id) {
|
||||||
if (p.group_id) {
|
return okResponse({ arkMsg: await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id) });
|
||||||
return okResponse({ arkMsg: await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id) });
|
|
||||||
}
|
|
||||||
if (p.user_id) {
|
|
||||||
return okResponse({ arkMsg: await ctx.bridge.apis.contacts.getBuddyRecommendArk(p.user_id, p.phone_number) });
|
|
||||||
}
|
|
||||||
return failedResponse(RETCODE.BAD_REQUEST, 'user_id or group_id is required');
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
|
||||||
}
|
}
|
||||||
|
if (p.user_id) {
|
||||||
|
return okResponse({ arkMsg: await ctx.bridge.apis.contacts.getBuddyRecommendArk(p.user_id, p.phone_number) });
|
||||||
|
}
|
||||||
|
return failedResponse(RETCODE.BAD_REQUEST, 'user_id or group_id is required');
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
defineAction({
|
defineAction({
|
||||||
@@ -1417,17 +1321,13 @@ export const actions = [
|
|||||||
phone_number: f.string().default(''),
|
phone_number: f.string().default(''),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
if (p.group_id) {
|
||||||
if (p.group_id) {
|
return okResponse({ arkMsg: await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id) });
|
||||||
return okResponse({ arkMsg: await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id) });
|
|
||||||
}
|
|
||||||
if (p.user_id) {
|
|
||||||
return okResponse({ arkMsg: await ctx.bridge.apis.contacts.getBuddyRecommendArk(p.user_id, p.phone_number) });
|
|
||||||
}
|
|
||||||
return failedResponse(RETCODE.BAD_REQUEST, 'user_id or group_id is required');
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
|
||||||
}
|
}
|
||||||
|
if (p.user_id) {
|
||||||
|
return okResponse({ arkMsg: await ctx.bridge.apis.contacts.getBuddyRecommendArk(p.user_id, p.phone_number) });
|
||||||
|
}
|
||||||
|
return failedResponse(RETCODE.BAD_REQUEST, 'user_id or group_id is required');
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1443,11 +1343,7 @@ export const actions = [
|
|||||||
returnsSchema: { type: 'string', description: '群 Ark 卡片 JSON 字符串' },
|
returnsSchema: { type: 'string', description: '群 Ark 卡片 JSON 字符串' },
|
||||||
params: { group_id: f.groupId() },
|
params: { group_id: f.groupId() },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
return okResponse(await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id));
|
||||||
return okResponse(await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id));
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
defineAction({
|
defineAction({
|
||||||
@@ -1458,11 +1354,7 @@ export const actions = [
|
|||||||
returnsSchema: { type: 'string', description: '群 Ark 卡片 JSON 字符串' },
|
returnsSchema: { type: 'string', description: '群 Ark 卡片 JSON 字符串' },
|
||||||
params: { group_id: f.groupId() },
|
params: { group_id: f.groupId() },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
return okResponse(await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id));
|
||||||
return okResponse(await ctx.bridge.apis.contacts.getGroupRecommendArk(p.group_id));
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1489,12 +1381,8 @@ export const actions = [
|
|||||||
},
|
},
|
||||||
params: { count: f.int({ min: 0 }).default(50) },
|
params: { count: f.int({ min: 0 }).default(50) },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const list = await ctx.bridge.apis.friend.getDoubtRequests(p.count);
|
||||||
const list = await ctx.bridge.apis.friend.getDoubtRequests(p.count);
|
return okResponse(list);
|
||||||
return okResponse(list);
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
// set_doubt_friends_add_request — handle a 可疑好友申请 (0xd69_0). `flag` is
|
// set_doubt_friends_add_request — handle a 可疑好友申请 (0xd69_0). `flag` is
|
||||||
@@ -1511,16 +1399,12 @@ export const actions = [
|
|||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
// approve → approvalDoubtBuddyReq (0xd69_0); reject → delDoubtBuddyReq
|
// approve → approvalDoubtBuddyReq (0xd69_0); reject → delDoubtBuddyReq
|
||||||
// (also 0xd69_0, distinct body) — both RE'd from the binary.
|
// (also 0xd69_0, distinct body) — both RE'd from the binary.
|
||||||
try {
|
if (p.approve) {
|
||||||
if (p.approve) {
|
await ctx.bridge.apis.friend.approveDoubtRequest(p.flag);
|
||||||
await ctx.bridge.apis.friend.approveDoubtRequest(p.flag);
|
} else {
|
||||||
} else {
|
await ctx.bridge.apis.friend.rejectDoubtRequest(p.flag);
|
||||||
await ctx.bridge.apis.friend.rejectDoubtRequest(p.flag);
|
|
||||||
}
|
|
||||||
return okResponse();
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
|
||||||
}
|
}
|
||||||
|
return okResponse();
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1530,14 +1414,10 @@ export const actions = [
|
|||||||
name: 'set_group_robot_add_option',
|
name: 'set_group_robot_add_option',
|
||||||
summary: '设置群机器人加群选项',
|
summary: '设置群机器人加群选项',
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
await ctx.bridge.apis.groupAdmin.setRobotAddOption(
|
||||||
await ctx.bridge.apis.groupAdmin.setRobotAddOption(
|
p.group_id, p.robot_member_switch, p.robot_member_examine,
|
||||||
p.group_id, p.robot_member_switch, p.robot_member_examine,
|
);
|
||||||
);
|
return okResponse();
|
||||||
return okResponse();
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
robot_member_switch: f.int({ min: 0 }).optional(),
|
robot_member_switch: f.int({ min: 0 }).optional(),
|
||||||
@@ -1581,12 +1461,8 @@ export const actions = [
|
|||||||
summary: '设置 QQ 头像',
|
summary: '设置 QQ 头像',
|
||||||
params: { file: f.image() },
|
params: { file: f.image() },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
await ctx.bridge.apis.profile.setAvatar(p.file);
|
||||||
await ctx.bridge.apis.profile.setAvatar(p.file);
|
return okResponse();
|
||||||
return okResponse();
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1599,12 +1475,8 @@ export const actions = [
|
|||||||
event_type: f.int().default(0),
|
event_type: f.int().default(0),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
await ctx.bridge.apis.profile.setInputStatus(p.user_id, p.event_type);
|
||||||
await ctx.bridge.apis.profile.setInputStatus(p.user_id, p.event_type);
|
return okResponse({});
|
||||||
return okResponse({});
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1770,19 +1642,15 @@ export const actions = [
|
|||||||
},
|
},
|
||||||
params: { chat_type: f.int({ min: 0 }).default(1) },
|
params: { chat_type: f.int({ min: 0 }).default(1) },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const list = await ctx.bridge.apis.extras.fetchAiVoiceList(p.group_id, p.chat_type);
|
||||||
const list = await ctx.bridge.apis.extras.fetchAiVoiceList(p.group_id, p.chat_type);
|
return okResponse(list.map((cat) => ({
|
||||||
return okResponse(list.map((cat) => ({
|
type: cat.category,
|
||||||
type: cat.category,
|
characters: cat.voices.map((v) => ({
|
||||||
characters: cat.voices.map((v) => ({
|
character_id: v.voiceId,
|
||||||
character_id: v.voiceId,
|
character_name: v.voiceDisplayName,
|
||||||
character_name: v.voiceDisplayName,
|
preview_url: v.voiceExampleUrl,
|
||||||
preview_url: v.voiceExampleUrl,
|
})),
|
||||||
})),
|
})));
|
||||||
})));
|
|
||||||
} catch (err) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, err instanceof Error ? err.message : String(err));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1795,13 +1663,9 @@ export const actions = [
|
|||||||
chat_type: f.int({ min: 0 }).default(1),
|
chat_type: f.int({ min: 0 }).default(1),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const node = await ctx.bridge.apis.extras.fetchAiVoice(p.group_id, p.character, p.text, p.chat_type);
|
||||||
const node = await ctx.bridge.apis.extras.fetchAiVoice(p.group_id, p.character, p.text, p.chat_type);
|
const url = await ctx.bridge.apis.groupFile.getPttUrl(p.group_id, node);
|
||||||
const url = await ctx.bridge.apis.groupFile.getPttUrl(p.group_id, node);
|
return okResponse(url);
|
||||||
return okResponse(url);
|
|
||||||
} catch (err) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, err instanceof Error ? err.message : String(err));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1817,12 +1681,8 @@ export const actions = [
|
|||||||
chat_type: f.int({ min: 0 }).default(1),
|
chat_type: f.int({ min: 0 }).default(1),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
await ctx.bridge.apis.extras.fetchAiVoice(p.group_id, p.character, p.text, p.chat_type);
|
||||||
await ctx.bridge.apis.extras.fetchAiVoice(p.group_id, p.character, p.text, p.chat_type);
|
return okResponse({ message_id: 0 });
|
||||||
return okResponse({ message_id: 0 });
|
|
||||||
} catch (err) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, err instanceof Error ? err.message : String(err));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1831,27 +1691,23 @@ export const actions = [
|
|||||||
summary: '请求数据库解密密钥',
|
summary: '请求数据库解密密钥',
|
||||||
params: { db_path: f.string({ allowEmpty: false }) },
|
params: { db_path: f.string({ allowEmpty: false }) },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const buffer = Buffer.alloc(128);
|
||||||
const buffer = Buffer.alloc(128);
|
const fileHandle = await readFile(p.db_path);
|
||||||
const fileHandle = await readFile(p.db_path);
|
|
||||||
|
|
||||||
if (fileHandle.length < 0xaf) {
|
if (fileHandle.length < 0xaf) {
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, 'Database file too short');
|
return failedResponse(RETCODE.ACTION_FAILED, 'Database file too short');
|
||||||
}
|
|
||||||
|
|
||||||
fileHandle.copy(buffer, 0, 0x2f, 0xaf);
|
|
||||||
const dbSalt = buffer.toString('utf8');
|
|
||||||
|
|
||||||
if (!/^[0-9a-fA-F]{128}$/.test(dbSalt)) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, 'Invalid db_salt: not a valid 128-character hex string');
|
|
||||||
}
|
|
||||||
|
|
||||||
const dbKey = await ctx.bridge.apis.misc.getDecryptKey(dbSalt.toLowerCase());
|
|
||||||
|
|
||||||
return okResponse({ db_key: dbKey });
|
|
||||||
} catch (err) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, err instanceof Error ? err.message : String(err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileHandle.copy(buffer, 0, 0x2f, 0xaf);
|
||||||
|
const dbSalt = buffer.toString('utf8');
|
||||||
|
|
||||||
|
if (!/^[0-9a-fA-F]{128}$/.test(dbSalt)) {
|
||||||
|
return failedResponse(RETCODE.ACTION_FAILED, 'Invalid db_salt: not a valid 128-character hex string');
|
||||||
|
}
|
||||||
|
|
||||||
|
const dbKey = await ctx.bridge.apis.misc.getDecryptKey(dbSalt.toLowerCase());
|
||||||
|
|
||||||
|
return okResponse({ db_key: dbKey });
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -1985,12 +1841,8 @@ export const actions = [
|
|||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
const fid = p.fid || p.notice_id;
|
const fid = p.fid || p.notice_id;
|
||||||
if (!fid) return failedResponse(RETCODE.BAD_REQUEST, 'group_id and fid/notice_id are required');
|
if (!fid) return failedResponse(RETCODE.BAD_REQUEST, 'group_id and fid/notice_id are required');
|
||||||
try {
|
const success = await ctx.bridge.apis.web.deleteNotice(p.group_id, fid);
|
||||||
const success = await ctx.bridge.apis.web.deleteNotice(p.group_id, fid);
|
return success ? okResponse() : failedResponse(RETCODE.ACTION_FAILED, 'delete failed');
|
||||||
return success ? okResponse() : failedResponse(RETCODE.ACTION_FAILED, 'delete failed');
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2107,11 +1959,7 @@ export const actions = [
|
|||||||
buf = Buffer.from(base64, 'base64');
|
buf = Buffer.from(base64, 'base64');
|
||||||
if (buf.length > DOWNLOAD_FILE_MAX_BYTES) return failedResponse(RETCODE.BAD_REQUEST, `base64 payload too large: ${buf.length} > ${DOWNLOAD_FILE_MAX_BYTES} bytes`);
|
if (buf.length > DOWNLOAD_FILE_MAX_BYTES) return failedResponse(RETCODE.BAD_REQUEST, `base64 payload too large: ${buf.length} > ${DOWNLOAD_FILE_MAX_BYTES} bytes`);
|
||||||
} else {
|
} else {
|
||||||
try {
|
buf = await fetchDownloadFile(url, parseDownloadHeaders(raw.headers), DOWNLOAD_FILE_MAX_BYTES, DOWNLOAD_FILE_TIMEOUT_MS);
|
||||||
buf = await fetchDownloadFile(url, parseDownloadHeaders(raw.headers), DOWNLOAD_FILE_MAX_BYTES, DOWNLOAD_FILE_TIMEOUT_MS);
|
|
||||||
} catch (err) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, err instanceof Error ? err.message : String(err));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const safe = await saveDownloadBuffer(buf, name);
|
const safe = await saveDownloadBuffer(buf, name);
|
||||||
@@ -2139,12 +1987,8 @@ export const actions = [
|
|||||||
const rawWords = p.words;
|
const rawWords = p.words;
|
||||||
if (!Array.isArray(rawWords)) return failedResponse(RETCODE.BAD_REQUEST, 'invalid words array');
|
if (!Array.isArray(rawWords)) return failedResponse(RETCODE.BAD_REQUEST, 'invalid words array');
|
||||||
const words = rawWords.map((w) => String(w));
|
const words = rawWords.map((w) => String(w));
|
||||||
try {
|
const translated = await ctx.bridge.apis.misc.translateEn2Zh(words);
|
||||||
const translated = await ctx.bridge.apis.misc.translateEn2Zh(words);
|
return okResponse({ words: translated });
|
||||||
return okResponse({ words: translated });
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2155,12 +1999,8 @@ export const actions = [
|
|||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
const longNick = p.longNick || p.long_nick;
|
const longNick = p.longNick || p.long_nick;
|
||||||
if (typeof longNick !== 'string') return failedResponse(RETCODE.BAD_REQUEST, 'invalid longNick');
|
if (typeof longNick !== 'string') return failedResponse(RETCODE.BAD_REQUEST, 'invalid longNick');
|
||||||
try {
|
await ctx.bridge.apis.profile.setSelfLongNick(longNick);
|
||||||
await ctx.bridge.apis.profile.setSelfLongNick(longNick);
|
return okResponse({});
|
||||||
return okResponse({});
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2175,12 +2015,8 @@ export const actions = [
|
|||||||
const desc = raw.desc || '';
|
const desc = raw.desc || '';
|
||||||
const picUrl = raw.picUrl || raw.pic_url || '';
|
const picUrl = raw.picUrl || raw.pic_url || '';
|
||||||
const jumpUrl = raw.jumpUrl || raw.jump_url || '';
|
const jumpUrl = raw.jumpUrl || raw.jump_url || '';
|
||||||
try {
|
const data = await ctx.bridge.apis.misc.getMiniAppArk(String(type), String(title), String(desc), String(picUrl), String(jumpUrl));
|
||||||
const data = await ctx.bridge.apis.misc.getMiniAppArk(String(type), String(title), String(desc), String(picUrl), String(jumpUrl));
|
return okResponse(data);
|
||||||
return okResponse(data);
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2192,12 +2028,8 @@ export const actions = [
|
|||||||
const buttonId = raw.button_id;
|
const buttonId = raw.button_id;
|
||||||
const callbackData = raw.callback_data || '';
|
const callbackData = raw.callback_data || '';
|
||||||
if (!buttonId) return failedResponse(RETCODE.BAD_REQUEST, 'missing required parameters');
|
if (!buttonId) return failedResponse(RETCODE.BAD_REQUEST, 'missing required parameters');
|
||||||
try {
|
const data = await ctx.bridge.apis.misc.clickInlineKeyboardButton(p.group_id, p.bot_appid, String(buttonId), String(callbackData), p.msg_seq);
|
||||||
const data = await ctx.bridge.apis.misc.clickInlineKeyboardButton(p.group_id, p.bot_appid, String(buttonId), String(callbackData), p.msg_seq);
|
return okResponse(data);
|
||||||
return okResponse(data);
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2205,12 +2037,8 @@ export const actions = [
|
|||||||
name: ['set_group_sign', 'send_group_sign'],
|
name: ['set_group_sign', 'send_group_sign'],
|
||||||
summary: '群签到',
|
summary: '群签到',
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
await ctx.bridge.apis.misc.sendGroupSign(p.group_id);
|
||||||
await ctx.bridge.apis.misc.sendGroupSign(p.group_id);
|
return okResponse({});
|
||||||
return okResponse({});
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2222,16 +2050,12 @@ export const actions = [
|
|||||||
if (!/^[0-9a-fA-F]*$/.test(p.data) || p.data.length % 2 !== 0) {
|
if (!/^[0-9a-fA-F]*$/.test(p.data) || p.data.length % 2 !== 0) {
|
||||||
return failedResponse(RETCODE.BAD_REQUEST, 'data must be a hex string of even length');
|
return failedResponse(RETCODE.BAD_REQUEST, 'data must be a hex string of even length');
|
||||||
}
|
}
|
||||||
try {
|
const body = hexToBytes(p.data);
|
||||||
const body = hexToBytes(p.data);
|
const result = await ctx.bridge.sendRawPacket(p.cmd, body);
|
||||||
const result = await ctx.bridge.sendRawPacket(p.cmd, body);
|
if (!result.success) return failedResponse(RETCODE.ACTION_FAILED, result.errorMessage || 'send failed');
|
||||||
if (!result.success) return failedResponse(RETCODE.ACTION_FAILED, result.errorMessage || 'send failed');
|
if (!p.rsp) return okResponse(null);
|
||||||
if (!p.rsp) return okResponse(null);
|
const respHex = result.responseData ? bytesToHex(result.responseData) : '';
|
||||||
const respHex = result.responseData ? bytesToHex(result.responseData) : '';
|
return okResponse(respHex);
|
||||||
return okResponse(respHex);
|
|
||||||
} catch (err) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, err instanceof Error ? err.message : String(err));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2280,12 +2104,8 @@ export const actions = [
|
|||||||
} else {
|
} else {
|
||||||
return failedResponse(RETCODE.BAD_REQUEST, 'files must be a string or string array');
|
return failedResponse(RETCODE.BAD_REQUEST, 'files must be a string or string array');
|
||||||
}
|
}
|
||||||
try {
|
const result = await ctx.bridge.apis.flashTransfer.createFlashTask(fileList, p.name, p.thumb_path);
|
||||||
const result = await ctx.bridge.apis.flashTransfer.createFlashTask(fileList, p.name, p.thumb_path);
|
return okResponse({ fileset_id: result.filesetId, task_id: result.filesetId });
|
||||||
return okResponse({ fileset_id: result.filesetId, task_id: result.filesetId });
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2294,12 +2114,8 @@ export const actions = [
|
|||||||
summary: '获取文件集信息',
|
summary: '获取文件集信息',
|
||||||
params: { fileset_id: f.string({ allowEmpty: false }) },
|
params: { fileset_id: f.string({ allowEmpty: false }) },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const list = await ctx.bridge.apis.flashTransfer.getFilesetInfo(p.fileset_id);
|
||||||
const list = await ctx.bridge.apis.flashTransfer.getFilesetInfo(p.fileset_id);
|
return okResponse({ fileset_id: p.fileset_id, file_list: list.map(flashFileInfoToJson) });
|
||||||
return okResponse({ fileset_id: p.fileset_id, file_list: list.map(flashFileInfoToJson) });
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2308,12 +2124,8 @@ export const actions = [
|
|||||||
summary: '获取闪传文件列表',
|
summary: '获取闪传文件列表',
|
||||||
params: { fileset_id: f.string({ allowEmpty: false }) },
|
params: { fileset_id: f.string({ allowEmpty: false }) },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const list = await ctx.bridge.apis.flashTransfer.getFlashFileList(p.fileset_id);
|
||||||
const list = await ctx.bridge.apis.flashTransfer.getFlashFileList(p.fileset_id);
|
return okResponse(list.map(flashFileInfoToJson));
|
||||||
return okResponse(list.map(flashFileInfoToJson));
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2322,12 +2134,8 @@ export const actions = [
|
|||||||
summary: '列出当前账号的所有闪传文件集',
|
summary: '列出当前账号的所有闪传文件集',
|
||||||
params: {},
|
params: {},
|
||||||
run: async (_p, ctx) => {
|
run: async (_p, ctx) => {
|
||||||
try {
|
const list = await ctx.bridge.apis.flashTransfer.listFilesets();
|
||||||
const list = await ctx.bridge.apis.flashTransfer.listFilesets();
|
return okResponse(list.map(flashFileInfoToJson));
|
||||||
return okResponse(list.map(flashFileInfoToJson));
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2340,12 +2148,8 @@ export const actions = [
|
|||||||
file_index: f.number().optional(),
|
file_index: f.number().optional(),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const url = await ctx.bridge.apis.flashTransfer.getFlashFileUrl(p.fileset_id, p.file_index);
|
||||||
const url = await ctx.bridge.apis.flashTransfer.getFlashFileUrl(p.fileset_id, p.file_index);
|
return okResponse({ url });
|
||||||
return okResponse({ url });
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2354,12 +2158,8 @@ export const actions = [
|
|||||||
summary: '获取文件分享链接',
|
summary: '获取文件分享链接',
|
||||||
params: { fileset_id: f.string({ allowEmpty: false }) },
|
params: { fileset_id: f.string({ allowEmpty: false }) },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const url = await ctx.bridge.apis.flashTransfer.getShareLink(p.fileset_id);
|
||||||
const url = await ctx.bridge.apis.flashTransfer.getShareLink(p.fileset_id);
|
return okResponse(url);
|
||||||
return okResponse(url);
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2368,12 +2168,8 @@ export const actions = [
|
|||||||
summary: '删除闪传文件',
|
summary: '删除闪传文件',
|
||||||
params: { fileset_id: f.string({ allowEmpty: false }) },
|
params: { fileset_id: f.string({ allowEmpty: false }) },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
await ctx.bridge.apis.flashTransfer.deleteFlashFile(p.fileset_id);
|
||||||
await ctx.bridge.apis.flashTransfer.deleteFlashFile(p.fileset_id);
|
return okResponse();
|
||||||
return okResponse();
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2385,12 +2181,8 @@ export const actions = [
|
|||||||
new_name: f.string({ allowEmpty: false }),
|
new_name: f.string({ allowEmpty: false }),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
await ctx.bridge.apis.flashTransfer.renameFlashFile(p.fileset_id, p.new_name);
|
||||||
await ctx.bridge.apis.flashTransfer.renameFlashFile(p.fileset_id, p.new_name);
|
return okResponse();
|
||||||
return okResponse();
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2404,19 +2196,15 @@ export const actions = [
|
|||||||
file_index: f.number().optional(),
|
file_index: f.number().optional(),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const target = await ctx.bridge.apis.flashTransfer.downloadFileset(p.fileset_id, {
|
||||||
const target = await ctx.bridge.apis.flashTransfer.downloadFileset(p.fileset_id, {
|
fileName: p.file_name,
|
||||||
fileName: p.file_name,
|
fileIndex: p.file_index,
|
||||||
fileIndex: p.file_index,
|
});
|
||||||
});
|
return okResponse({
|
||||||
return okResponse({
|
url: target.url,
|
||||||
url: target.url,
|
file_name: target.fileName,
|
||||||
file_name: target.fileName,
|
file_size: target.fileSize,
|
||||||
file_size: target.fileSize,
|
});
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, err instanceof Error ? err.message : String(err));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2433,16 +2221,12 @@ export const actions = [
|
|||||||
if (!p.user_id && !p.group_id) {
|
if (!p.user_id && !p.group_id) {
|
||||||
return failedResponse(RETCODE.BAD_REQUEST, 'user_id or group_id is required');
|
return failedResponse(RETCODE.BAD_REQUEST, 'user_id or group_id is required');
|
||||||
}
|
}
|
||||||
try {
|
await ctx.bridge.apis.flashTransfer.sendFlashMsg(p.fileset_id, {
|
||||||
await ctx.bridge.apis.flashTransfer.sendFlashMsg(p.fileset_id, {
|
userId: p.user_id,
|
||||||
userId: p.user_id,
|
groupId: p.group_id,
|
||||||
groupId: p.group_id,
|
});
|
||||||
});
|
// 0x93d7 响应无 message_id(分享 fileset,非传统消息),返回 0 兼容 OneBot 形状。
|
||||||
// 0x93d7 响应无 message_id(分享 fileset,非传统消息),返回 0 兼容 OneBot 形状。
|
return okResponse({ message_id: 0 });
|
||||||
return okResponse({ message_id: 0 });
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -2460,12 +2244,8 @@ export const actions = [
|
|||||||
},
|
},
|
||||||
params: { share_code: f.string({ allowEmpty: false }) },
|
params: { share_code: f.string({ allowEmpty: false }) },
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
try {
|
const filesetId = await ctx.bridge.apis.flashTransfer.getFilesetIdByCode(p.share_code);
|
||||||
const filesetId = await ctx.bridge.apis.flashTransfer.getFilesetIdByCode(p.share_code);
|
return okResponse({ fileset_id: filesetId });
|
||||||
return okResponse({ fileset_id: filesetId });
|
|
||||||
} catch (e) {
|
|
||||||
return failedResponse(RETCODE.ACTION_FAILED, e instanceof Error ? e.message : String(e));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in new issue
Block a user