Class: Boty::Slack::Chat

Inherits:
Object
  • Object
show all
Includes:
URL
Defined in:
lib/boty/slack/chat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from URL

get, included

Constructor Details

#initializeChat

Returns a new instance of Chat.



9
10
11
# File 'lib/boty/slack/chat.rb', line 9

def initialize
  @im = IM.new
end

Instance Attribute Details

#imObject (readonly)

Returns the value of attribute im.



7
8
9
# File 'lib/boty/slack/chat.rb', line 7

def im
  @im
end

Instance Method Details

#post_im(user_id, message) ⇒ Object



22
23
24
25
# File 'lib/boty/slack/chat.rb', line 22

def post_im(user_id, message)
  channel = im.open user_id
  post_message message, channel: channel.id
end

#post_message(message, parameters = {}) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/boty/slack/chat.rb', line 13

def post_message(message, parameters = {})
  defaults = {
    as_user: true,
    channel: "general",
    text: message
  }
  URL.get parameterize(defaults.merge parameters)
end