Module: Bobot::Event::Common
- Defined in:
- lib/bobot/events/common.rb
Overview
Common attributes for all incoming data from Facebook.
Instance Attribute Summary collapse
-
#messaging ⇒ Object
readonly
Returns the value of attribute messaging.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
- #initialize(messaging) ⇒ Object
- #mark_as_seen ⇒ Object
- #recipient ⇒ Object
- #reply(payload_message:) ⇒ Object
- #reply_with_attachment(url:, type:) ⇒ Object
- #reply_with_audio(url:) ⇒ Object
- #reply_with_buttons(text:, buttons:) ⇒ Object
- #reply_with_file(url:) ⇒ Object
- #reply_with_generic(elements:, image_aspect_ratio: 'square') ⇒ Object (also: #reply_with_carousel)
- #reply_with_image(url:) ⇒ Object
- #reply_with_quick_replies(text:, quick_replies:) ⇒ Object
- #reply_with_text(text:) ⇒ Object
- #reply_with_video(url:) ⇒ Object
- #sender ⇒ Object
- #sender_action(sender_action:) ⇒ Object
- #sent_at ⇒ Object
- #show_typing(state:) ⇒ Object
Instance Attribute Details
#messaging ⇒ Object (readonly)
Returns the value of attribute messaging.
5 6 7 |
# File 'lib/bobot/events/common.rb', line 5 def messaging @messaging end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
5 6 7 |
# File 'lib/bobot/events/common.rb', line 5 def page @page end |
Instance Method Details
#initialize(messaging) ⇒ Object
7 8 9 |
# File 'lib/bobot/events/common.rb', line 7 def initialize(messaging) @messaging = messaging end |
#mark_as_seen ⇒ Object
31 32 33 |
# File 'lib/bobot/events/common.rb', line 31 def mark_as_seen page.mark_as_seen(to: sender["id"]) end |
#recipient ⇒ Object
15 16 17 |
# File 'lib/bobot/events/common.rb', line 15 def recipient @messaging['recipient'] end |
#reply(payload_message:) ⇒ Object
35 36 37 |
# File 'lib/bobot/events/common.rb', line 35 def reply(payload_message:) page.send(payload_message: , to: sender["id"]) end |
#reply_with_attachment(url:, type:) ⇒ Object
43 44 45 |
# File 'lib/bobot/events/common.rb', line 43 def (url:, type:) page.(url: url, type: type, to: sender["id"]) end |
#reply_with_audio(url:) ⇒ Object
51 52 53 |
# File 'lib/bobot/events/common.rb', line 51 def reply_with_audio(url:) page.send_audio(url: url, to: sender["id"]) end |
#reply_with_buttons(text:, buttons:) ⇒ Object
67 68 69 |
# File 'lib/bobot/events/common.rb', line 67 def (text:, buttons:) page.(text: text, buttons: , to: sender["id"]) end |
#reply_with_file(url:) ⇒ Object
59 60 61 |
# File 'lib/bobot/events/common.rb', line 59 def reply_with_file(url:) page.send_file(url: url, to: sender["id"]) end |
#reply_with_generic(elements:, image_aspect_ratio: 'square') ⇒ Object Also known as: reply_with_carousel
71 72 73 |
# File 'lib/bobot/events/common.rb', line 71 def reply_with_generic(elements:, image_aspect_ratio: 'square') page.send_generic(elements: elements, image_aspect_ratio: image_aspect_ratio, to: sender["id"]) end |
#reply_with_image(url:) ⇒ Object
47 48 49 |
# File 'lib/bobot/events/common.rb', line 47 def reply_with_image(url:) page.send_image(url: url, to: sender["id"]) end |
#reply_with_quick_replies(text:, quick_replies:) ⇒ Object
63 64 65 |
# File 'lib/bobot/events/common.rb', line 63 def reply_with_quick_replies(text:, quick_replies:) page.send_quick_replies(text: text, quick_replies: quick_replies, to: sender["id"]) end |
#reply_with_text(text:) ⇒ Object
39 40 41 |
# File 'lib/bobot/events/common.rb', line 39 def reply_with_text(text:) page.send_text(text: text, to: sender["id"]) end |
#reply_with_video(url:) ⇒ Object
55 56 57 |
# File 'lib/bobot/events/common.rb', line 55 def reply_with_video(url:) page.send_video(url: url, to: sender["id"]) end |
#sender ⇒ Object
11 12 13 |
# File 'lib/bobot/events/common.rb', line 11 def sender @messaging['sender'] end |
#sender_action(sender_action:) ⇒ Object
23 24 25 |
# File 'lib/bobot/events/common.rb', line 23 def sender_action(sender_action:) page.sender_action(sender_action: sender_action, to: sender["id"]) end |
#sent_at ⇒ Object
19 20 21 |
# File 'lib/bobot/events/common.rb', line 19 def sent_at Time.zone.at(@messaging['timestamp'] / 1000) end |
#show_typing(state:) ⇒ Object
27 28 29 |
# File 'lib/bobot/events/common.rb', line 27 def show_typing(state:) page.show_typing(state: state, to: sender["id"]) end |