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

document changes in hubot-slack 4 #355

Closed
Closed
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
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,41 @@ need to upgrade:
- Once you're happy it works, disable the old hubot integration from
https://my.slack.com/services

## Upgrading from version 3 or earlier of hubot-slack

Version 4 of the hubot-slack adapter uses a more recent version of
`node-slack-sdk`. As a result, there are some syntax changes within Hubot:

1. Before version 4, `msg.message.room` would return the name of the room
Copy link

@DDAZZA DDAZZA Sep 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a good idea to mention that it also previously returned the slack username if the message was a direct message from a client.

I think the following should work as a replacement robot.adapter.client.rtm.dataStore.getUserById(room).name

(e.g. `general`). `msg.message.room` now returns a room identifier
(e.g. `C03NM270D`). If you need to translate the room id to a room name,
you can look it up with the client:

```coffeescript
robot.respond /what room am i in\?/i, (msg) ->
room = msg.message.room
roomName = robot.adapter.client.rtm.dataStore.getChannelById(room).name
msg.send roomName
```

2. Version 3 of hubot-slack supported attachments by emitting a
`slack.attachment` event. In version 4, you use `msg.send`, passing an object
with an `attachments` array:

```coffeescript
robot.respond /send attachments/i, (msg) ->
msg.send(
attachments: [
{
text: '*error*: something bad happened'
fallback: 'error: something bad happened'
color: 'danger'
mrkdwn_in: ['text']
}
]
)
```

## Configuration

This adapter uses the following environment variables:
Expand Down