Class: Janky::ChatService::HipChat

Inherits:
Object
  • Object
show all
Defined in:
lib/janky/chat_service/hipchat.rb

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ HipChat

Returns a new instance of HipChat.



6
7
8
9
10
11
12
13
14
# File 'lib/janky/chat_service/hipchat.rb', line 6

def initialize(settings)
  token = settings["JANKY_CHAT_HIPCHAT_TOKEN"]
  if token.nil? || token.empty?
    raise Error, "JANKY_CHAT_HIPCHAT_TOKEN setting is required"
  end

  @client = ::HipChat::Client.new(token)
  @from = settings["JANKY_CHAT_HIPCHAT_FROM"] || "CI"
end

Instance Method Details

#roomsObject



25
26
27
28
29
# File 'lib/janky/chat_service/hipchat.rb', line 25

def rooms
  @rooms ||= @client.rooms.map do |room|
    Room.new(room.room_id, room.name)
  end
end

#speak(message, room_id, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/janky/chat_service/hipchat.rb', line 16

def speak(message, room_id, options = {})
  default = {
    :color => "yellow",
    :message_format => "text"
  }
  options = default.merge(options)
  @client[room_id].send(@from, message, options)
end