Class: Civility::Ext::Slack

Inherits:
Object
  • Object
show all
Defined in:
lib/civility/ext/slack.rb

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Slack

Returns a new instance of Slack.



8
9
10
# File 'lib/civility/ext/slack.rb', line 8

def initialize(token)
  @token = token
end

Instance Method Details

#post_message(channel_name, text, username) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/civility/ext/slack.rb', line 12

def post_message(channel_name, text, username)
  params = {
    token: @token,
    channel: channel_name,
    link_names: 1,
    username: username,
    icon_emoji: ':robot_face:',
    text: text
  }
  post('https://slack.com/api/chat.postMessage', params)
end