Module: NononoReciever::Slack

Extended by:
NononoReciever, Slack
Included in:
Slack
Defined in:
lib/nonono_reciever/slack.rb,
lib/nonono_reciever/slack/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
"0.1.0"

Instance Method Summary collapse

Instance Method Details

#initObject

Raises:



11
12
13
14
15
16
17
# 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) ⇒ Object



25
26
27
28
29
# 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) ⇒ Object



19
20
21
22
23
# File 'lib/nonono_reciever/slack.rb', line 19

def take(event)
  case event.class.to_s
  when 'String' then event
  end
end