Class: BotMob::InboundMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/bot_mob/inbound_message.rb

Overview

## BotMob::Inbound Message

The InboundMessage class provides easy access to messages received from Slack’s Real Time API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, data) ⇒ InboundMessage

Returns a new instance of InboundMessage.



11
12
13
14
# File 'lib/bot_mob/inbound_message.rb', line 11

def initialize(source, data)
  @data = data
  send("parse_#{source}".to_sym, data)
end

Instance Attribute Details

#bot_idObject (readonly)

Returns the value of attribute bot_id.



7
8
9
# File 'lib/bot_mob/inbound_message.rb', line 7

def bot_id
  @bot_id
end

#channel_idObject (readonly)

Returns the value of attribute channel_id.



7
8
9
# File 'lib/bot_mob/inbound_message.rb', line 7

def channel_id
  @channel_id
end

#channel_nameObject (readonly)

Returns the value of attribute channel_name.



7
8
9
# File 'lib/bot_mob/inbound_message.rb', line 7

def channel_name
  @channel_name
end

#commandObject (readonly)

Returns the value of attribute command.



7
8
9
# File 'lib/bot_mob/inbound_message.rb', line 7

def command
  @command
end

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/bot_mob/inbound_message.rb', line 7

def data
  @data
end

#response_urlObject (readonly)

Returns the value of attribute response_url.



7
8
9
# File 'lib/bot_mob/inbound_message.rb', line 7

def response_url
  @response_url
end

#sourceObject (readonly)

Returns the value of attribute source.



7
8
9
# File 'lib/bot_mob/inbound_message.rb', line 7

def source
  @source
end

#team_domainObject (readonly)

Returns the value of attribute team_domain.



7
8
9
# File 'lib/bot_mob/inbound_message.rb', line 7

def team_domain
  @team_domain
end

#team_idObject (readonly)

Returns the value of attribute team_id.



7
8
9
# File 'lib/bot_mob/inbound_message.rb', line 7

def team_id
  @team_id
end

#textObject (readonly)

Returns the value of attribute text.



7
8
9
# File 'lib/bot_mob/inbound_message.rb', line 7

def text
  @text
end

#tokenObject (readonly)

Returns the value of attribute token.



7
8
9
# File 'lib/bot_mob/inbound_message.rb', line 7

def token
  @token
end

#tsObject (readonly)

Returns the value of attribute ts.



7
8
9
# File 'lib/bot_mob/inbound_message.rb', line 7

def ts
  @ts
end

#user_idObject (readonly)

Returns the value of attribute user_id.



7
8
9
# File 'lib/bot_mob/inbound_message.rb', line 7

def user_id
  @user_id
end

#user_nameObject (readonly)

Returns the value of attribute user_name.



7
8
9
# File 'lib/bot_mob/inbound_message.rb', line 7

def user_name
  @user_name
end

Instance Method Details

#argumentsObject



16
17
18
# File 'lib/bot_mob/inbound_message.rb', line 16

def arguments
  @arguments ||= text[%r{\/[\w'_-]+\s*[\w'_-]+\s*(.*)}, 1]
end

#command?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/bot_mob/inbound_message.rb', line 20

def command?
  !command.nil?
end

#human?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/bot_mob/inbound_message.rb', line 24

def human?
  bot_id.nil?
end