Module: Slackr::IncomingWebhook

Extended by:
IncomingWebhook
Included in:
IncomingWebhook
Defined in:
lib/slackr/webhooks/incoming.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



10
11
12
# File 'lib/slackr/webhooks/incoming.rb', line 10

def connection
  @connection
end

Instance Method Details

#say(connection, text = "", options = {}) ⇒ Object

{ :formatter => [BasicFormatter, LinkFormatter, AttachmentFormatter] }



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/slackr/webhooks/incoming.rb', line 15

def say(connection, text="", options={})
  @connection = connection
  #formatter = options[:formatter] || BasicFormatter
  #text      = format_text(formatter, text)
  #TODO: fix law of demeter violations
  request      = Net::HTTP::Post.new(service_url)
  request.body = encode_message(text, options)
  response     = connection.http_request(request)
  if response.code != "200"
    raise Slackr::ServiceError, "Slack.com - #{response.code} - #{response.body}"
  end
end