Class: BotMob::InboundMessage

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

Overview

## BotMob::InboundMessage

The InboundMessage class provides easy access to messages received by bots in your application

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ InboundMessage

Returns a new instance of InboundMessage.



9
10
11
# File 'lib/bot_mob/inbound_message.rb', line 9

def initialize(text)
  @text = text
end

Instance Attribute Details

#networkObject (readonly)

Returns the value of attribute network.



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

def network
  @network
end

#paramsObject (readonly)

Returns the value of attribute params.



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

def params
  @params
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

Class Method Details

.parse(params) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/bot_mob/inbound_message.rb', line 13

def self.parse(params)
  network = params[:network]
  invalid_network_error(network) unless BotMob.valid_network?(network)

  parser = network_delegate(network)
  invalid_delegate_error(network) unless parser.respond_to?(:parse)

  parser.parse(params)
end

Instance Method Details

#argumentsObject



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

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