Sha256: b675a4ffead96dc57423793bcbf26c9537eb49d43b10e17b43c307aad568ff73

Contents?: true

Size: 686 Bytes

Versions: 2

Compression:

Stored size: 686 Bytes

Contents

module Biobot
  module Periodicals
    module Notify
      class Notification < ActiveRecord::Base
        set_table_name 'notifications'
      end

      def self.included(base)
        base.register_periodical(:handle_notifications, 60)
      end

      def handle_notifications
        if Notification.count > 0
          Notification.all.each do |notification|
            to   = notification.to
            body = notification.body
            message = Jabber::Message.new(
              to =~ /@/ ? to : "#{to}@#{@server}",
              body
            )
            @client.send(message)
          end
          Notification.delete_all
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
viking-biobot-0.0.3 lib/biobot/periodicals/notify.rb
viking-biobot-0.0.4 lib/biobot/periodicals/notify.rb