feat(dingtalk): stabilize multimodal answer workflows
This commit is contained in:
@@ -85,7 +85,7 @@ func (c *Controller) Handle(ctx context.Context, in SettingInput) (string, error
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "身份已验证,请回到后台确认首位管理员。", nil
|
||||
return "身份已验证,请回到服务器命令行等待确认。", nil
|
||||
}
|
||||
if explicit && len(args) == 0 {
|
||||
admin, err := c.repo.IsAdministrator(ctx, in.TenantKey, in.StaffID)
|
||||
@@ -158,7 +158,7 @@ func (c *Controller) Handle(ctx context.Context, in SettingInput) (string, error
|
||||
return "", err
|
||||
}
|
||||
|
||||
func settingMenu(admin, direct bool) string {
|
||||
func settingMenu(admin, _ bool) string {
|
||||
menu := "⚙️ 个人设置\n入口:/setting 或 /设置\n" +
|
||||
"回答语言:/setting language <auto|zh-CN|en|ja|ko|es>\n" +
|
||||
"- auto:跟随当前提问语言(推荐)\n" +
|
||||
@@ -172,14 +172,7 @@ func settingMenu(admin, direct bool) string {
|
||||
"- support:在目标技术支持群@机器人发送 /setting support 保存;再发送 /setting support test,测试成功后激活。\n" +
|
||||
"- question:私聊发送 /setting question,再在10分钟内发送问题AI表链接;Schema验证通过后激活并短暂重启。\n" +
|
||||
"- faq:私聊发送 /setting faq,再在10分钟内发送FAQ表链接;Schema验证通过后激活并短暂重启。"
|
||||
if !direct {
|
||||
return menu + "\n\n🌐 管理后台与管理员更换:请私聊机器人发送 /setting 查看。"
|
||||
}
|
||||
return menu + "\n\n🌐 管理后台(仅PC)\n" +
|
||||
"1. 通过SSH隧道将本地8090转发到服务器127.0.0.1:8090。\n" +
|
||||
"2. 浏览器打开:http://127.0.0.1:8090/admin/settings\n" +
|
||||
"3. Basic Auth用户名任意;密码为服务器DOBOTAI_ADMIN_TOKEN(仅从服务器安全获取,禁止发送到钉钉)。\n" +
|
||||
"4. 更换管理员:后台生成6位码 → 新管理员私聊 /setting <6位码> → 回后台确认 → 新管理员生效后再停用旧管理员。"
|
||||
return menu
|
||||
}
|
||||
|
||||
func tableBindingFailureReply(action string, err error) string {
|
||||
|
||||
@@ -88,7 +88,7 @@ func TestControllerSettingMenuExplainsLanguageWithoutAdminActionsToOrdinaryUser(
|
||||
}
|
||||
}
|
||||
|
||||
func TestControllerSettingMenuExplainsAdminActionsAndBackendAccess(t *testing.T) {
|
||||
func TestControllerSettingMenuExplainsAdminActionsWithoutBackendAccess(t *testing.T) {
|
||||
r := newMemoryRepo()
|
||||
r.admins["t/a"] = true
|
||||
c := NewController(r)
|
||||
@@ -103,15 +103,21 @@ func TestControllerSettingMenuExplainsAdminActionsAndBackendAccess(t *testing.T)
|
||||
"/setting question",
|
||||
"/setting faq",
|
||||
"Schema验证通过后激活并短暂重启",
|
||||
} {
|
||||
if !strings.Contains(out, want) {
|
||||
t.Fatalf("reply=%q must contain %q", out, want)
|
||||
}
|
||||
}
|
||||
for _, forbidden := range []string{
|
||||
"管理后台",
|
||||
"SSH隧道",
|
||||
"127.0.0.1:8090/admin/settings",
|
||||
"Basic Auth",
|
||||
"DOBOTAI_ADMIN_TOKEN",
|
||||
"新管理员私聊 /setting <6位码>",
|
||||
"新管理员生效后再停用旧管理员",
|
||||
"回后台确认",
|
||||
} {
|
||||
if !strings.Contains(out, want) {
|
||||
t.Fatalf("reply=%q must contain %q", out, want)
|
||||
if strings.Contains(out, forbidden) {
|
||||
t.Fatalf("reply=%q must not contain %q", out, forbidden)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,11 +318,14 @@ func TestControllerDetectsBootstrapCandidate(t *testing.T) {
|
||||
r := newMemoryRepo()
|
||||
c := NewController(r)
|
||||
c.now = func() time.Time { return time.Unix(100, 0) }
|
||||
_, err := c.Handle(context.Background(), SettingInput{TenantKey: "t", StaffID: "a", UnionID: "union", DisplayName: "Alice", Text: "/setting 123456", ConversationType: "direct"})
|
||||
out, err := c.Handle(context.Background(), SettingInput{TenantKey: "t", StaffID: "a", UnionID: "union", DisplayName: "Alice", Text: "/setting 123456", ConversationType: "direct"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if r.candidate.Code != "123456" || r.candidate.StaffID != "a" {
|
||||
t.Fatalf("candidate=%+v", r.candidate)
|
||||
}
|
||||
if !strings.Contains(out, "服务器命令行") || strings.Contains(out, "后台") {
|
||||
t.Fatalf("reply=%q must direct confirmation back to the server CLI only", out)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user