making the bot listen with mentions in DMs

This commit is contained in:
ari committed 2026-11-01 14:24:32 -05:00
1 parent 650bcff83a
commit 3ba96528bb
2 files changed
+22 -3

No files matched your search

+16
View File
@@ -311,6 +311,22 @@ func TestStopReactionCancelsPrompt(t *testing.T) {
}
}
func TestMentionedCommandInDM(t *testing.T) {
log := &slackLog{text: map[string]string{}, under: map[string]string{}}
srv := httptest.NewServer(log)
defer srv.Close()
store, _ := state.Open(filepath.Join(t.TempDir(), "state.json"))
b := &Bot{store: store, botID: "UBOT", api: slack.New("xoxb", slack.OptionAPIURL(srv.URL+"/"))}
b.onEvent(context.Background(), slackevents.EventsAPIEvent{InnerEvent: slackevents.EventsAPIInnerEvent{
Data: &slackevents.MessageEvent{User: "U1", Channel: "D1", ChannelType: "im", TimeStamp: "3.0", Text: "<@UBOT> help"},
}})
log.mu.Lock()
defer log.mu.Unlock()
if len(log.order) != 1 || !strings.Contains(log.text[log.order[0]], "Commands") {
t.Fatalf("@mentioning the bot in a DM should still run the command: %v %v", log.order, log.text)
}
}
func TestCommandsInAssistantThreads(t *testing.T) {
log := &slackLog{text: map[string]string{}, under: map[string]string{}}
srv := httptest.NewServer(log)