Skip to content
This repository was archived by the owner on Sep 22, 2025. It is now read-only.
This repository was archived by the owner on Sep 22, 2025. It is now read-only.

Extract attachments text #262

Description

@dblock

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions