Sha256: 1615ca4bfa9059da6c8c8528ceb3ab1dd32decfa4f75e876b4b49b23f156320b

Contents?: true

Size: 923 Bytes

Versions: 4

Compression:

Stored size: 923 Bytes

Contents

require "irc-notify"

module Glman
  module Commands
    class Notify
      attr_reader :config, :irc_config, :irc_client, :nick, :server, :port, :ssl

      def initialize(opts={})
        @config = opts.fetch(:config)
      end

      def send(msg)
        irc_client.register(nick)
        irc_client.notify(channel, msg)
        client.quit
      end

      def nick
        @nick ||= irc_config.fetch(:nick)
      end

      def channel
        @channel ||= irc_config.fetch(:channel)
      end

      def server
        @server ||= irc_config.fetch(:server)
      end

      def port
        @port ||= irc_config.fetch(:port)
      end

      def ssl
        @ssl ||= irc_config.fetch(:ssl)
      end

      def irc_config
        @irc_config ||= config.fetch(:notify_cfg).fetch(:irc)
      end

      def irc_client
        @irc_client ||= IrcNotify::Client.build(server, port, ssl: ssl)
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
glman-0.1.3 lib/glman/commands/notify.rb
glman-0.1.2 lib/glman/commands/notify.rb
glman-0.1.1 lib/glman/commands/notify.rb
glman-0.1.0 lib/glman/commands/notify.rb