3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

hubot-slack v4でチャンネルIDからチャンネル名を拾ってくる方法

Last updated at Posted at 2018-03-17

hubot-slack v3までは msg.envelope.room にはRoomの名前が入っていたのが、hubot-slack v4からはRoom IDに変わったらしい。

ここの記事を見ると簡単に変換できるように見えたのだが、SlackDataStoreがdeprecatedらしくWarnが出てMigrationガイドを案内された。

Migrationガイドとソースコードを読んだ感じから次のようにすればSlackDataStoreを使わずにRoomの名前が取れることがわかった。

robot.hear /.*/i, (res) ->
  robot.adapter.client.web.channels.info(res.message.room)
    .then((response) ->
      roomName = response.channel.name

そんなわけでRoomの名前が必要な場合は上のような感じで拾ってきましょう。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?