Skip to content

Commit

Permalink
Do not strip bot name from messages
Browse files Browse the repository at this point in the history
Engines have access to the bot user ID (`TEABOT_USER_ID`) anyway. They
can strip it out if they want to.
  • Loading branch information
venkytv committed Apr 26, 2023
1 parent 0e80958 commit 8a0f16c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
11 changes: 2 additions & 9 deletions backend/slack_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,6 @@ func (s *SlackBackend) Read() {
// Set up regex to recognise @mentions of bot
s.atMePattern = regexp.MustCompile(fmt.Sprintf(`<@%s>`, s.me))

// Set up the sanitiser to remove references to bot ID in message
logrus.Debug("Setting up message sanitiser")
re := regexp.MustCompile(fmt.Sprintf(`^\s*<@%s>\s+`, s.me))
s.sanitiser = func(m *message.Message) *message.Message {
m.Text = re.ReplaceAllString(m.Text, "")
return m
}

case *slack.MessageEvent:
if s.me == "" {
logrus.Debug("Not connected yet!")
Expand Down Expand Up @@ -231,5 +223,6 @@ func (s SlackBackend) Post() {
}

func (s SlackBackend) Sanitize(m *message.Message) *message.Message {
return s.sanitiser(m)
// Do nothing
return m
}
7 changes: 4 additions & 3 deletions conversation/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,17 @@ func (cm *Manager) GetConversations(ctx context.Context, m *message.Message) []*
if config.Threaded {
cm.addThreadedConversation(ctx, &c, m.ThreadId)
conversations = append(conversations, &c)
logrus.Debugf("New threaded conversation with %s: %+v", config.Name, c)
} else {
if cm.addChannelConversation(ctx, &c, m.ChannelId, config.Name) {
conversations = append(conversations, &c)
logrus.Debugf("New channel conversation with %s: %+v", config.Name, c)
} else {
logrus.Debugf("Ignoring trigger as bot already active on channel: %s: %s: %#v",
c.channelName, m.Text, ef)
logrus.Debugf("Ignoring trigger as bot already active: channel='%s' msg='%s' trigger='%s'",
c.channelName, m.Text, re.String())
}
}

logrus.Debugf("New conversation with %s: %+v", config.Name, c)
}
}
}
Expand Down

0 comments on commit 8a0f16c

Please sign in to comment.