mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
314bc6f231
1. Remove root-level shim files (errors.ts, logger.ts, registry.ts, types.ts, utils.ts, launcher.ts) — update all ~840 adapter imports to reference src/ directly 2. Consolidate interceptor: reuse shared DISGUISE_FN in tap interceptor instead of reimplementing 3. Unify error classification: single ClassifiedError type with icon/exitCode/hint lookup table, eliminating duplicated pattern matching between resolveExitCode and renderError 4. Simplify cascade probe: replace repetitive switch cases with PROBE_OPTIONS lookup map 12. Clean up synthesize.ts: remove deprecated snake_case field aliases (recommended_args, recommended_columns, recommendedColumnsLegacy) and unnecessary constant aliases Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
47 lines
1.8 KiB
TypeScript
47 lines
1.8 KiB
TypeScript
import { cli, Strategy } from '../../src/registry.js';
|
|
import { requirePage, navigateToChat, bossFetch, findFriendByUid } from './utils.js';
|
|
|
|
cli({
|
|
site: 'boss',
|
|
name: 'chatmsg',
|
|
description: 'BOSS直聘查看与候选人的聊天消息',
|
|
domain: 'www.zhipin.com',
|
|
strategy: Strategy.COOKIE,
|
|
navigateBefore: false,
|
|
browser: true,
|
|
args: [
|
|
{ name: 'uid', required: true, positional: true, help: 'Encrypted UID (from chatlist)' },
|
|
{ name: 'page', type: 'int', default: 1, help: 'Page number' },
|
|
],
|
|
columns: ['from', 'type', 'text', 'time'],
|
|
func: async (page, kwargs) => {
|
|
requirePage(page);
|
|
await navigateToChat(page);
|
|
|
|
const friend = await findFriendByUid(page, kwargs.uid);
|
|
if (!friend) throw new Error('未找到该候选人');
|
|
|
|
const gid = friend.uid;
|
|
const securityId = encodeURIComponent(friend.securityId);
|
|
const msgUrl = `https://www.zhipin.com/wapi/zpchat/boss/historyMsg?gid=${gid}&securityId=${securityId}&page=${kwargs.page}&c=20&src=0`;
|
|
|
|
const msgData = await bossFetch(page, msgUrl);
|
|
|
|
const TYPE_MAP: Record<number, string> = {
|
|
1: '文本', 2: '图片', 3: '招呼', 4: '简历', 5: '系统',
|
|
6: '名片', 7: '语音', 8: '视频', 9: '表情',
|
|
};
|
|
const messages = msgData.zpData?.messages || msgData.zpData?.historyMsgList || [];
|
|
return messages.map((m: any) => {
|
|
const fromObj = m.from || {};
|
|
const isSelf = typeof fromObj === 'object' ? fromObj.uid !== friend.uid : false;
|
|
return {
|
|
from: isSelf ? '我' : (typeof fromObj === 'object' ? fromObj.name : friend.name),
|
|
type: TYPE_MAP[m.type] || '其他(' + m.type + ')',
|
|
text: m.text || m.body?.text || '',
|
|
time: m.time ? new Date(m.time).toLocaleString('zh-CN') : '',
|
|
};
|
|
});
|
|
},
|
|
});
|