Add smart ACK provider for WeChat MP replies
Replace fixed ackText with a rule-based AckProvider that picks response templates by message type and intent (translate, summary, rewrite, poster, ppt, mindmap, code, search, schedule). Pure sync, zero I/O, auto-falls back to config.ackText on any error. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import type { PortalUser } from '../types';
|
||||
|
||||
function isInternalWechatUsername(value?: string | null): boolean {
|
||||
return /^wx_[a-z0-9_]{4,64}$/i.test(String(value ?? '').trim());
|
||||
}
|
||||
|
||||
export function resolveUserAddressName(
|
||||
user?: Pick<PortalUser, 'displayName' | 'username'> | null,
|
||||
): string {
|
||||
const preferred = user?.displayName?.trim();
|
||||
if (preferred) return preferred;
|
||||
const username = user?.username?.trim();
|
||||
if (username) return username;
|
||||
if (username && !isInternalWechatUsername(username)) return username;
|
||||
return '用户';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user