Sha256: b4aafe3155b5b4dbbb0bb2757a66a73708484609ca027441f87625f724a69db7

Contents?: true

Size: 675 Bytes

Versions: 7

Compression:

Stored size: 675 Bytes

Contents

module Ruboty::Actions::Ragoon
  class Notification < ::Ruboty::Actions::Base
    include ::Ruboty::Actions::Ragoon

    def call
      notifications = ::Ruboty::Ragoon::Notification.new(message.robot.brain)
      notifications.retrieve
      unless notifications.empty?
        reply = [":new: #{notifications.unread_count}件の新着通知があります #{notification_url}"]

        if private?
          reply += notifications.list.find_all(&:unread).map(&:format)
        end

        message.reply(reply.join("\n"))
      end
    end

    private

    def notification_url
      "#{::Ragoon::garoon_endpoint.gsub(/\?.*\Z/, '')}/notification/index"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruboty-ragoon-0.7.0 lib/ruboty/actions/ragoon/notification.rb
ruboty-ragoon-0.6.1 lib/ruboty/actions/ragoon/notification.rb
ruboty-ragoon-0.6.0 lib/ruboty/actions/ragoon/notification.rb
ruboty-ragoon-0.5.2 lib/ruboty/actions/ragoon/notification.rb
ruboty-ragoon-0.5.1 lib/ruboty/actions/ragoon/notification.rb
ruboty-ragoon-0.5.0 lib/ruboty/actions/ragoon/notification.rb
ruboty-ragoon-0.4.0 lib/ruboty/actions/ragoon/notification.rb