mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-17 13:13:35 +08:00
WeChat needs a QR-paired path instead of bot-token setup, so the adapter layer now includes the iLink protocol calls, desktop pairing UI, server-side bind/unbind APIs, and shared IM command behavior. Empty project history falls back to the user's default work directory so mobile /new works without pre-opening a desktop project. Constraint: Tencent iLink login returns a URL that the desktop UI must render as a QR image locally Constraint: IM adapters should keep /new, /projects, status, permission, and default workdir behavior consistent across WeChat, Feishu, and Telegram Rejected: Require users to paste absolute project paths for first WeChat sessions | mobile onboarding should work from the default user working directory Confidence: high Scope-risk: moderate Directive: Do not change WeChat polling back to overlapping intervals; getupdates is a long-poll endpoint and must remain serialized Tested: Real WeChat QR scan, inbound /status, outbound reply, and unbind E2E Tested: bun run check:adapters Tested: bun run quality:pr Not-tested: Re-scan live WeChat after the default-workdir fallback tweak; covered by adapter config tests and PR gate
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'bun:test'
|
|
import { buildClientVersion, extractWechatText } from '../protocol.js'
|
|
|
|
describe('WeChat protocol helpers', () => {
|
|
it('encodes iLink client versions like the OpenClaw Weixin plugin', () => {
|
|
expect(buildClientVersion('2.1.7')).toBe((2 << 16) | (1 << 8) | 7)
|
|
expect(buildClientVersion('1.0.11')).toBe(65547)
|
|
})
|
|
|
|
it('extracts plain text from WeChat message items', () => {
|
|
expect(extractWechatText([
|
|
{ type: 1, text_item: { text: 'hello' } },
|
|
])).toBe('hello')
|
|
})
|
|
|
|
it('extracts voice transcription when text items are absent', () => {
|
|
expect(extractWechatText([
|
|
{ type: 3, voice_item: { text: 'voice text' } },
|
|
])).toBe('voice text')
|
|
})
|
|
|
|
it('preserves quoted text context', () => {
|
|
expect(extractWechatText([
|
|
{
|
|
type: 1,
|
|
text_item: { text: 'reply' },
|
|
ref_msg: {
|
|
title: 'quote title',
|
|
message_item: { type: 1, text_item: { text: 'quoted body' } },
|
|
},
|
|
},
|
|
])).toBe('[引用: quote title | quoted body]\nreply')
|
|
})
|
|
})
|