添加完整的微信插件测试框架,包含: - 微信插件源码(weixin-plugin/) - TypeScript 类型定义(types.ts) - 插件编译脚本(scripts/build-weixin-plugin.sh) - 简化测试脚本(scripts/test-weixin-simple.js) - 完整测试脚本(scripts/test-weixin-plugin.js) - 项目配置和依赖管理(package.json) - 使用说明文档(README.md) 主要功能: - 支持二维码登录认证 - HTTP 长轮询消息接收 - 文本、图片、视频、文件消息收发 - 自动回复测试 - 运行状态统计 Generated with [Claude Code](https://claude.com/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { logger } from "../util/logger.js";
|
|
import { sendMessageWeixin } from "./send.js";
|
|
|
|
/**
|
|
* Send a plain-text error notice back to the user.
|
|
* Fire-and-forget: errors are logged but never thrown, so callers stay unaffected.
|
|
* No-op when contextToken is absent (we have no conversation reference to reply into).
|
|
*/
|
|
export async function sendWeixinErrorNotice(params: {
|
|
to: string;
|
|
contextToken: string | undefined;
|
|
message: string;
|
|
baseUrl: string;
|
|
token?: string;
|
|
errLog: (m: string) => void;
|
|
}): Promise<void> {
|
|
if (!params.contextToken) {
|
|
logger.warn(`sendWeixinErrorNotice: no contextToken for to=${params.to}, sending without context`);
|
|
}
|
|
try {
|
|
await sendMessageWeixin({ to: params.to, text: params.message, opts: {
|
|
baseUrl: params.baseUrl,
|
|
token: params.token,
|
|
contextToken: params.contextToken,
|
|
}});
|
|
logger.debug(`sendWeixinErrorNotice: sent to=${params.to}`);
|
|
} catch (err) {
|
|
params.errLog(`[weixin] sendWeixinErrorNotice failed to=${params.to}: ${String(err)}`);
|
|
}
|
|
}
|