mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-12 08:14:06 +00:00
- Fix image_generation nil-pointer crash on codex agents: the sentinel now carries a name-only Function so the many sites reading td.Function.Name never nil-deref; codex_build still branches on Type. - Agent-declared trigger words in IDENTITY.md wake the bot in groups without an @mention (whole-word, Cyrillic-aware; text + caption), cached per-agent 60s. - channel_post support with a synthetic sender + a recover() guard so a malformed update can't crash the gateway. - message tool action=edit (editMessageText + editMessageCaption fallback), targeting the replied-to message via reply_to_message_id. - message tool topic=<name> posts into a named forum topic; topics learned from forum_topic_created into channel_contacts and resolved by name. Co-authored-by: skensel <skensel@MacBook-Pro-skensel.local> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package bootstrap
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestParseTriggerWords(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
content string
|
|
want []string
|
|
}{
|
|
{
|
|
name: "plain key value",
|
|
content: "Name: Rex\nTrigger words: Alice, Boss, Chief\nEmoji: 🤖",
|
|
want: []string{"Alice", "Boss", "Chief"},
|
|
},
|
|
{
|
|
name: "markdown bullet form",
|
|
content: "- **Name:** Rex\n- **Trigger words:** Alice, Boss\n",
|
|
want: []string{"Alice", "Boss"},
|
|
},
|
|
{
|
|
name: "case-insensitive key and singular",
|
|
content: "trigger word: Alice",
|
|
want: []string{"Alice"},
|
|
},
|
|
{
|
|
name: "drops blanks and trims",
|
|
content: "Trigger words: Alice ,, Chief , ",
|
|
want: []string{"Alice", "Chief"},
|
|
},
|
|
{
|
|
name: "missing key",
|
|
content: "Name: Rex\nEmoji: 🤖",
|
|
want: nil,
|
|
},
|
|
{
|
|
name: "empty content",
|
|
content: "",
|
|
want: nil,
|
|
},
|
|
}
|
|
for _, tc := range cases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
got := ParseTriggerWords(tc.content)
|
|
if !reflect.DeepEqual(got, tc.want) {
|
|
t.Errorf("ParseTriggerWords() = %#v, want %#v", got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|