예제 #1
0
파일: core.go 프로젝트: wcharczuk/jarvis
func (c *Core) handleMentionCatchAll(b core.Bot, m *slack.Message) error {
	message := util.TrimWhitespace(core.LessMentions(m.Text))
	if core.IsSalutation(message) {
		return c.handleSalutation(b, m)
	}
	return c.handleUnknown(b, m)
}
예제 #2
0
func TestHandleMentionCatchAllSalutation(t *testing.T) {
	assert := assert.New(t)
	c := &Core{}
	mb := core.NewMockBot(slack.UUIDv4().ToShortString())

	gotMessage := ""
	mb.MockMessageHandler(func(b core.Bot, m *slack.Message) error {
		gotMessage = m.Text
		return nil
	})

	message := "hey <@BOT>"
	assert.True(core.IsSalutation(message))
	err := c.handleSalutation(mb, core.MockMessage(message))
	assert.Nil(err)
	assert.False(strings.Contains(gotMessage, "how to respond"))
}