Class: Bobot::Event::Message
- Inherits:
-
Object
- Object
- Bobot::Event::Message
show all
- Includes:
- Common
- Defined in:
- lib/bobot/events/message.rb
Constant Summary
collapse
- ATTACHMENT_TYPES =
%w[image audio video file location fallback].freeze
Instance Attribute Summary
Attributes included from Common
#messaging, #page
Instance Method Summary
collapse
Methods included from Common
#initialize, #mark_as_seen, #prior_message, #recipient, #reply, #reply_with_attachment, #reply_with_audio, #reply_with_buttons, #reply_with_file, #reply_with_generic, #reply_with_image, #reply_with_quick_replies, #reply_with_text, #reply_with_video, #reply_with_youtube_video, #send_pass_thread_control, #send_take_thread_control, #sender, #sender_action, #sent_at, #show_typing
Instance Method Details
#app_id ⇒ Object
32
33
34
|
# File 'lib/bobot/events/message.rb', line 32
def app_id
@messaging['message']['app_id']
end
|
#attachment_type ⇒ Object
42
43
44
45
46
|
# File 'lib/bobot/events/message.rb', line 42
def attachment_type
return if attachments.nil?
attachments.first['type']
end
|
#attachment_url ⇒ Object
48
49
50
51
52
53
|
# File 'lib/bobot/events/message.rb', line 48
def attachment_url
return if attachments.nil?
return unless %w[image audio video file].include? attachment_type
attachments.first['payload']['url']
end
|
#attachments ⇒ Object
24
25
26
|
# File 'lib/bobot/events/message.rb', line 24
def attachments
@messaging['message']['attachments']
end
|
#echo? ⇒ Boolean
20
21
22
|
# File 'lib/bobot/events/message.rb', line 20
def echo?
@messaging['message']['is_echo'].present?
end
|
#id ⇒ Object
8
9
10
|
# File 'lib/bobot/events/message.rb', line 8
def id
@messaging['message']['mid']
end
|
#location_coordinates ⇒ Object
55
56
57
58
59
60
|
# File 'lib/bobot/events/message.rb', line 55
def location_coordinates
return [] unless attachment_type?('location')
coordinates_data = attachments.first['payload']['coordinates']
[coordinates_data['lat'], coordinates_data['long']]
end
|
#nlp ⇒ Object
28
29
30
|
# File 'lib/bobot/events/message.rb', line 28
def nlp
@messaging['message']['nlp']
end
|
#quick_reply ⇒ Object
Also known as:
payload
62
63
64
65
66
|
# File 'lib/bobot/events/message.rb', line 62
def quick_reply
return unless @messaging['message']['quick_reply']
@messaging['message']['quick_reply']['payload']
end
|
#seq ⇒ Object
12
13
14
|
# File 'lib/bobot/events/message.rb', line 12
def seq
@messaging['message']['seq']
end
|
#text ⇒ Object
16
17
18
|
# File 'lib/bobot/events/message.rb', line 16
def text
@messaging['message']['text']
end
|