<commit_before>require_relative './slack/webhooks.rb'

module R2S
  class SlackMsgBuilder
    # for feed_runner
    def self.build_for_feed
      payload = Slack::IncomingWebhooks::Payload.new
      payload.username = 'Rss2Slack'
      payload.text = 'Successfully fetched feed :tada: '
      payload
    end

    # for article_runner
    def self.build_for_article(articles)
      # TODO
    end
  end
end<commit_msg>payload builder for article runner<commit_after>require_relative './slack/webhooks.rb'
require_relative './date'

module R2S
  class SlackMsgBuilder
    # for feed_runner
    def self.build_for_feed
      payload = Slack::IncomingWebhooks::Payload.new
      payload.username = 'Rss2Slack'
      payload.text = 'Successfully fetched feed :tada: '
      payload
    end

    # for article_runner
    def self.build_for_article(articles)
      payload = Slack::IncomingWebhooks::Payload.new
      attachment = Slack::IncomingWebhooks::Attachment.new
      now = R2S::Date::now

      attachment.fallback = "Today's Feed"
      attachment.color = 'good'
      attachment.title = "#{now.month}月#{now.day}日の記事 :tada: "
      attachment.footer = 'from Rss2Slack'
      attachment.ts = now.to_i

      fields = []
      articles.each { |a|
        field = Slack::IncomingWebhooks::Field.new
        field.title = a.title
        field.value = a.url
        field.short = false
        fields.push(field)
      }
      attachment.fields = fields

      payload.attachments = [attachment]
      payload.username = 'Rss2Slack'
      payload.text = "Today's Feed :tada: "
      payload
    end
  end
end
{'fraction_non_alphanumeric': 0.09695463020509633, 'fraction_numerical': 0.00435052827843381, 'mean_word_length': 2.7096774193548385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4012377', 'n_tokens_mistral': 514, 'n_tokens_neox': 509, 'n_words': 104}