Sha256: b759fd31d6f2bb152dc1f2da73eb1b657d9824b3adba962fd9879d1b3cd7afb9

Contents?: true

Size: 984 Bytes

Versions: 1

Compression:

Stored size: 984 Bytes

Contents

module Firetower
  module Plugins
    class NotifyPlugin < Firetower::Session::Listener

      def startup(session)
        if session.kind == :server
          notify("Firetower", "Firetower is vigilant!")
        end
      end

      def join(session, room)
        notify("Firetower", "Joined room \"#{room.name}\"")
      end

      def receive(session, event)
        case event['type']
        when "TextMessage"
          user = event.room.account.users[event['user_id']]
          notify(user['name'], event['body'])
        else
          # NOOP
        end
      end

      def error(session, description)
        notify("Campfire Error", description)
      end

      private

      def notify(*args)
        system('notify-send', '--icon',
          File.expand_path(
            '../images/campfire-logo-for-fluid.png',
            File.dirname(__FILE__)),
          '-c', 'Firetower',
          *args) or raise "Desktop notification failed"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
firetower-0.0.1 lib/firetower/plugins/core/notify_plugin.rb