Class: Say2Slack::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/say2slack/main.rb

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ Main

Returns a new instance of Main.



4
5
6
7
8
# File 'lib/say2slack/main.rb', line 4

def initialize(user)
  @user = user
  @token = ENV['SLACK_API_TOKEN'] || ""
  @image = ENV['SLACK_BOT_IMG'] || "http://i.imgur.com/EEdDLWz.png"
end

Instance Method Details

#says(message) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/say2slack/main.rb', line 10

def says(message)
  endpoint = "https://slack.com/api/chat.postMessage"
  return [
    "#{endpoint}?token=#{@token}",
    "username=#{@user}",
    "text=#{message}",
    "icon_url=#{@image}",
  ].join("&")
end