Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One way to fix bot_not_found due to SlackBot #520

Merged
merged 5 commits into from
Aug 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class SlackClient

# Map to convert bot user IDs (BXXXXXXXX) to user representations for events from custom
# integrations and apps without a bot user
@botUserIdMap = {}
@botUserIdMap = {
"B01": { id: "B01", user_id: "USLACKBOT" }
}

# Map to convert conversation IDs to conversation representations
@channelData = {}
Expand Down
8 changes: 8 additions & 0 deletions test/client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ describe 'fetchBotUser()', ->
result = @client.fetchBotUser @stubs.bot.id
result.should.be.Promise()

it 'should return constant data if id is slackbots id', ->
user = @stubs.slack_bot
@client.fetchBotUser @stubs.slack_bot.id
.then((res) ->
res.id.should.equal user.id
res.user_id.should.equal user.user_id
)

describe 'fetchUser()', ->
it 'should return user representation from brain', ->
user = @stubs.user
Expand Down
4 changes: 4 additions & 0 deletions test/stubs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ beforeEach ->
@stubs.undefined_user_bot =
name: 'testbot'
id: 'B789'
@stubs.slack_bot =
name: 'slackbot'
id: 'B01'
user_id: 'USLACKBOT'
@stubs.self =
name: 'self'
id: 'U456'
Expand Down