module NononoReciever::Slack

Constants

VERSION

Public Instance Methods

init() click to toggle source
# File lib/nonono_reciever/slack.rb, line 11
def init
  raise Error if ENV['SLACK_API_TOKEN'].empty? || ENV['SLACK_CHANNEL'].empty?
  ::Slack.configure do |config|
    config.token = ENV['SLACK_API_TOKEN']
  end
  @@client = ::Slack::Web::Client.new
end
recieve(event) click to toggle source
# File lib/nonono_reciever/slack.rb, line 25
def recieve(event)
  ch = ENV['SLACK_CHANNEL']
  text = take(event)
  @@client.chat_postMessage(channel: ch, text: text, as_user: false) unless text.nil?
end
take(event) click to toggle source
# File lib/nonono_reciever/slack.rb, line 19
def take(event)
  case event.class.to_s
  when 'String' then event
  end
end