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

Extract attachments text #262

Open
dblock opened this issue Jun 27, 2020 · 0 comments
Open

Extract attachments text #262

dblock opened this issue Jun 27, 2020 · 0 comments

Comments

@dblock
Copy link
Collaborator

dblock commented Jun 27, 2020

IFTT messages are attachments, use fallback text or extract text from those.

 #<Slack::Messages::Message attachments=#<Hashie::Array [#<Slack::Messages::Message fallback="MSFT" mrkdwn_in=#<Hashie::Array ["text", "pretext"]> pretext="MSFT" title="https://ifttt.com/share/XnSQgQ2fJZ24" title_link="https://ifttt.com/share/XnSQgQ2fJZ24">]> bot_id="B01641RK3SR" bot_profile=#<Slack::Messages::Message app_id="A028LGAFF" deleted=false icons=#<Slack::Messages::Message image_36="https://avatars.slack-edge.com/2020-03-31/1037355424996_31b25e6141973a9d613b_36.jpg" image_48="https://avatars.slack-edge.com/2020-03-31/1037355424996_31b25e6141973a9d613b_48.jpg" image_72="https://avatars.slack-edge.com/2020-03-31/1037355424996_31b25e6141973a9d613b_72.jpg"> id="B01641RK3SR" name="IFTTT" team_id="T04KB5WQH" updated=1593219506> channel="C0LAW5Z1U" event_ts="1593220314.001400" icons=#<Slack::Messages::Message image_36="https://a.slack-edge.com/095d8b/img/services/ifttt_36.png" image_48="https://a.slack-edge.com/095d8b/img/services/ifttt_48.png" image_72="https://a.slack-edge.com/095d8b/img/services/ifttt_72.png"> subtype="bot_message" suppress_notification=false team="T04KB5WQH" text="" ts="1593220314.001400" type="message" username="IFTTT">

Workaround:

module SlackRubyBot
  module Hooks
    class Message
      alias_method :_call, :call

      def call(client, data)
        data.text = data.attachments&.map(&:fallback)&.join("\n") if data.text.blank?
        _call(client, data)
      end
    end
  end
end
@dblock dblock changed the title Fallback on attachments fallback Extract attachments text Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant