Sha256: 9f35fd3b4065194afabb945b5a619a739bba1f9592570e554765c875067d87eb

Contents?: true

Size: 870 Bytes

Versions: 3

Compression:

Stored size: 870 Bytes

Contents

# frozen_string_literal: true

module Fushin
  class Monitor
    attr_reader :rss
    def initialize
      @rss = RSS.new
    end

    def check
      rss.items.each do |item|
        next if Cache.cached?(item.link)

        attachements = [].tap do |out|
          out << item.post.btcs.map(&:to_attachements)
          out << item.post.urls.map(&:to_attachements)
          out << item.post.links.map(&:to_attachements)
          out << item.post.attachements.map(&:to_attachements)
        end.flatten
        attachements << { text: "IoC is not found." } if attachements.empty?
        Notifier.notify("#{item.title} (#{item.link})", attachements)

        Cache.save(item.link, true)
      rescue StandardError => e
        puts "#{e.class} (#{e}) is happened during processing #{item.link}"
      end
    end

    def self.check
      new.check
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fushin-0.3.1 lib/fushin/monitor.rb
fushin-0.3.0 lib/fushin/monitor.rb
fushin-0.2.0 lib/fushin/monitor.rb