class_docstr: SlackOutput handles all alert dispatching for Slack
class_docstr_tok: ["SlackOutput","handles","all","alert","dispatching","for","Slack"]
docstr: Format the message to be sent to slack.
  
  Args:
      alert (Alert): The alert
      alert_publication (dict): Alert relevant to the triggered rule
      fallback_text (str): A formatted rule header to be included with each
          attachment as fallback text (to be shown on mobile, etc)
  
  Returns:
      list(dict): A list of dictionaries with the formatted attachment to be sent to Slack
          as the text
docstr_tok: ["Format","the","message","to","be","sent","to","slack",".","Args",":","alert","(","Alert",")",":","The","alert","alert_publication","(","dict",")",":","Alert","relevant","to","the","triggered","rule","fallback_text","(","str",")",":","A","formatted","rule","header","to","be","included","with","each","attachment","as","fallback","text","(","to","be","shown","on","mobile",",","etc",")","Returns",":","list","(","dict",")",":","A","list","of","dictionaries","with","the","formatted","attachment","to","be","sent","to","Slack","as","the","text"]
code: def _format_default_attachments(
      cls, alert, alert_publication, fallback_text
  ):
      """Format the message to be sent to slack.
  
      Args:
          alert (Alert): The alert
          alert_publication (dict): Alert relevant to the triggered rule
          fallback_text (str): A formatted rule header to be included with each
              attachment as fallback text (to be shown on mobile, etc)
  
      Returns:
          list(dict): A list of dictionaries with the formatted attachment to be sent to Slack
              as the text
      """
      record = alert.record
      rule_description = alert.rule_description
  
      messages = list(cls._split_attachment_text(record))
  
      attachments = []
      for index, message in enumerate(messages, start=1):
          title = "Record:"
          if len(messages) > 1:
              title = "Record (Part {} of {}):".format(
                  index, len(messages)
              )
          rule_desc = ""
          # Only print the rule description on the first attachment
          if index == 1:
              rule_desc = rule_description
              rule_desc = "*Rule Description:*\n{}\n".format(rule_desc)
  
          # https://api.slack.com/docs/message-attachments#attachment_structure
          attachments.append(
              {
                  "fallback": fallback_text,
                  "color": "#b22222",
                  "pretext": rule_desc,
                  "title": title,
                  "text": message,
                  "mrkdwn_in": ["text", "pretext"],
              }
          )
  
          if index == cls.MAX_ATTACHMENTS:
              LOGGER.warning(
                  "%s: %d-part message truncated to %d parts",
                  alert_publication,
                  len(messages),
                  cls.MAX_ATTACHMENTS,
              )
              break
  
      return attachments
  
file_path: streamalert/streamalert/alert_processor/outputs/slack.py
imports: import html
  from collections import OrderedDict
  from streamalert.alert_processor.helpers import compose_alert, elide_string_middle
  from streamalert.alert_processor.outputs.output_base import OutputDispatcher, OutputProperty, OutputRequestFailure, StreamAlertOutput
  from streamalert.shared.logger import get_logger
label_desc: Use image node_id 3 for calling the SlackOutput obj's underlying member method code with example usage: obj._format_default_attachments(cls, alert, alert_publication, fallback_text) and returns: attachments