Closed hmiyado closed 6 years ago
That probably means you need to be listening to file upload events, so I would start finding out what these are and writing some simple hook.
@dblock Attachments can come with message
events. For example Slack GitHub integration uses attachments for posting notifications. Example format:
{
"text": "",
"bot_id": "B9AL1G5DE",
"attachments": [
{
"fallback": "[mdudzinski\/gh-notifications-test] New comment by mdudzinski on pull request <https:\/\/github.com\/mdudzinski\/gh-notifications-test\/pull\/1#issuecomment-367010472|#1: second commit>",
"text": "foobar something",
"pretext": "[mdudzinski\/gh-notifications-test] New comment by mdudzinski on pull request <https:\/\/github.com\/mdudzinski\/gh-notifications-test\/pull\/1#issuecomment-367010472|#1: second commit>",
"id": 1,
"color": "C4E8B4",
"mrkdwn_in": [
"text",
"pretext"
]
}
],
"type": "message",
"subtype": "bot_message",
"team": "T09P9CDD3",
"channel": "G8S920G5N",
"event_ts": "1519139910.000648",
"ts": "1519139910.000648"
}
So currently slack-ruby-bot
cannot handle such messages.
As a short term solution I came up with an idea of message hook decorator which just appends attachment.text
to data.text
and calls SlackRubyBot::Hooks::Message#call
.
But I think this deserves a long term solution. Maybe a new DSL to listen for commands/matches on attachments text/pretext/title field? Or perhaps existing DSLs (command
etc) should just check against attachments field as well.
+1 on a new DSL
I think I can take this one. I'll see what can be done :)
This issue is addressed in #180.
I just merged https://github.com/slack-ruby/slack-ruby-bot/pull/180, please give it a try from HEAD!
Thanks, this is a great update!
I would like my bot to respond text in attachments. However, slack ruby bot can respond to only plain text now. Does anyone have good idea to implement this?