Skip to content

Commit

Permalink
fix: handle the official Slackbot ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Kearney committed Nov 7, 2023
1 parent fb87d90 commit e4d1547
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions slacker.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const (
boldMessageFormat = "*%s*"
italicMessageFormat = "_%s_"
exampleMessageFormat = "_*Example:*_ %s"

slackBotID = "B01" // Hardcoded SlackBot ID
)

// NewClient creates a new client using the Slack API
Expand Down Expand Up @@ -534,6 +536,14 @@ func (s *Slacker) handleMessageEvent(ctx context.Context, event any) {
func (s *Slacker) ignoreBotMessage(messageEvent *MessageEvent) bool {
switch s.botInteractionMode {
case BotModeIgnoreApp:

// Special case the official SlackBot ID, the API returns an error if
// we look this up and the Go package doesn't handle it for us. See
// https://github.com/slackapi/python-slack-sdk/issues/1260#issuecomment-1236715741
// for more discussion effecting other users of the API.
if messageEvent.BotID == slackBotID {
return false
}
bot, err := s.slackClient.GetBotInfo(messageEvent.BotID)
if err != nil {
if err.Error() == "missing_scope" {
Expand Down

0 comments on commit e4d1547

Please sign in to comment.