Sha256: 864a63c177c7f3477c2c4f59fc6f5086801d8563d8e02152f849214defa331c7

Contents?: true

Size: 621 Bytes

Versions: 2

Compression:

Stored size: 621 Bytes

Contents

# frozen_string_literal: true

require 'heart_top/plugin/base'
require 'singleton'
require 'json'

module HeartTop
  module Plugin
    class Slack < Base
      include Singleton

      def ping
        `curl -X POST --data-urlencode 'payload=#{payload}' #{webhook_url}`
      end

      private

      def payload
        {
          channel: '#hearttop',
          username: 'hearttop',
          text: 'This is posted to #hearttop and comes from a bot named hearttop.',
          icon_emoji: ':ghost:'
        }.to_json.to_s
      end

      def webhook_url
        ENV['SLACK_WEBHOOK_URL']
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
heart_top-0.3.0 lib/heart_top/plugin/slack.rb
heart_top-0.2.0 lib/heart_top/plugin/slack.rb