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

Bot responds to text in attachments. #177

Closed
hmiyado opened this issue Feb 5, 2018 · 7 comments
Closed

Bot responds to text in attachments. #177

hmiyado opened this issue Feb 5, 2018 · 7 comments
Labels

Comments

@hmiyado
Copy link

hmiyado commented Feb 5, 2018

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?

@dblock dblock added the question label Feb 5, 2018
@dblock
Copy link
Collaborator

dblock commented Feb 5, 2018

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.

@mdudzinski
Copy link
Collaborator

mdudzinski commented Feb 23, 2018

@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.

@dblock
Copy link
Collaborator

dblock commented Feb 23, 2018

+1 on a new DSL

@mdudzinski
Copy link
Collaborator

I think I can take this one. I'll see what can be done :)

@mdudzinski
Copy link
Collaborator

This issue is addressed in #180.

@dblock
Copy link
Collaborator

dblock commented Mar 9, 2018

I just merged #180, please give it a try from HEAD!

@hmiyado
Copy link
Author

hmiyado commented Mar 12, 2018

Thanks, this is a great update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants