Class: SlackBot::Notify

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/slack_bot/notify.rb

Class Method Summary collapse

Class Method Details

.execute(body, bot_name, channel) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/models/slack_bot/notify.rb', line 4

def self.execute(body, bot_name, channel)
  return 'SlackBot is unactive mode.' if SlackBot.unactive
  query = {
      token: ::SlackBot.token,
      channel: channel,
      text: body,
      username: bot_name
  }
  uri = Addressable::URI.parse(::SlackBot.endpoint)
  uri.query_values ||= {}
  uri.query_values = uri.query_values.merge(query)

  Net::HTTP.get(URI.parse(uri))
end