支持访客实时输入草稿展示与联系方式自动识别

坐席输入框上方显示「对方正在输入」草稿;从草稿/消息提取手机微信邮箱QQ并追加入库,不覆盖已有联系方式。
This commit is contained in:
yml2213
2026-07-19 00:19:24 +08:00
parent fea5f4acf5
commit 6070cf47dc
11 changed files with 465 additions and 17 deletions
@@ -0,0 +1,28 @@
package handler
import "testing"
func TestExtractContactsFromText(t *testing.T) {
text := "你好,我微信是 abc_wx_01,手机 13800138000,邮箱 test@example.com QQ123456"
got := extractContactsFromText(text)
kinds := map[string]string{}
for _, c := range got {
kinds[c.Kind] = c.Value
}
if kinds["phone"] != "13800138000" {
t.Fatalf("phone: %+v", got)
}
if kinds["wechat"] != "abc_wx_01" {
t.Fatalf("wechat: %+v", got)
}
if kinds["email"] != "test@example.com" {
t.Fatalf("email: %+v", got)
}
if kinds["qq"] != "123456" {
t.Fatalf("qq: %+v", got)
}
// 不完整不应误提
if len(extractContactsFromText("微信 ab")) != 0 {
t.Fatal("partial wechat should not extract")
}
}