hubot-slack 4系でAttachmentsを投稿する
3系では、 robot.emit 'slack.attachment'
で投稿できたが、4系では投稿できなくなった。
なので、少しやってみた。
slack = require 'hubot-slack'
module.exports = (robot) ->
robot.respond /test/, (res) ->
room = res.envelope.room
timestamp = new Date/1000|0
# https://api.slack.com/docs/message-attachments
attachments = [
{
fallback: 'デプロイしたよ',
color: 'good',
pretext: 'デプロイしたよ',
fields: [
{
title: 'Command',
value: 'cap staging deploy',
short: false
}
{
title: 'Stage',
value: 'staging',
short: true
},
{
title: 'Status',
value: '0',
short: true
},
{
title: 'Output',
value: '12323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323123231232312323',
short: false
}
],
footer: 'hubot',
footer_icon: 'https://hubot.github.com/assets/images/layout/[email protected]',
ts: timestamp
}
]
options = { as_user: true, link_names: 1, attachments: attachments }
client = robot.adapter.client
client.web.chat.postMessage(room, '', options)
要は、 hubot-slack
が使っている slack を直接呼んでしまえばできた。
Author And Source
この問題について(hubot-slack 4系でAttachmentsを投稿する), 我々は、より多くの情報をここで見つけました https://qiita.com/taka0125/items/6260bc7cfc1a5f6026f1著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .