Class: Sinbotra::Messenger::Bot
- Inherits:
-
Object
- Object
- Sinbotra::Messenger::Bot
- Defined in:
- lib/sinbotra/messenger/bot.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
Instance Method Summary collapse
- #current_message ⇒ Object
- #generic_template(title, subtitle, image, link, buttons) ⇒ Object
- #has_conversation?(convo_id) ⇒ Boolean
- #image(url) ⇒ Object
-
#initialize(user) ⇒ Bot
constructor
A new instance of Bot.
- #location ⇒ Object
- #payload_button(text, payload) ⇒ Object
- #qr(text, postback = nil) ⇒ Object
- #quick_replies(text, replies) ⇒ Object
- #say(text) ⇒ Object (also: #text)
- #start_conversation(convo_id) ⇒ Object
- #text_with_buttons(text, buttons) ⇒ Object
- #typing(seconds = 0, &blk) ⇒ Object
- #url_button(text, url) ⇒ Object
- #video(url) ⇒ Object
Constructor Details
#initialize(user) ⇒ Bot
Returns a new instance of Bot.
5 6 7 |
# File 'lib/sinbotra/messenger/bot.rb', line 5 def initialize(user) @current_user = user end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
3 4 5 |
# File 'lib/sinbotra/messenger/bot.rb', line 3 def current_user @current_user end |
Instance Method Details
#current_message ⇒ Object
63 64 65 |
# File 'lib/sinbotra/messenger/bot.rb', line 63 def current_user. end |
#generic_template(title, subtitle, image, link, buttons) ⇒ Object
40 41 |
# File 'lib/sinbotra/messenger/bot.rb', line 40 def generic_template(title, subtitle, image, link, ) end |
#has_conversation?(convo_id) ⇒ Boolean
73 74 75 |
# File 'lib/sinbotra/messenger/bot.rb', line 73 def has_conversation?(convo_id) !!find_convo(convo_id) end |
#image(url) ⇒ Object
55 56 57 |
# File 'lib/sinbotra/messenger/bot.rb', line 55 def image(url) client.image(recipient_id: recipient_id, url: url) end |
#location ⇒ Object
59 60 61 |
# File 'lib/sinbotra/messenger/bot.rb', line 59 def location client.location(recipient_id: recipient_id) end |
#payload_button(text, payload) ⇒ Object
33 34 35 |
# File 'lib/sinbotra/messenger/bot.rb', line 33 def (text, payload) MessengerClient::PayloadButton.new(text, payload) end |
#qr(text, postback = nil) ⇒ Object
29 30 31 |
# File 'lib/sinbotra/messenger/bot.rb', line 29 def qr(text, postback=nil) MessengerClient::QuickReply.new(text, postback) end |
#quick_replies(text, replies) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/sinbotra/messenger/bot.rb', line 17 def quick_replies(text, replies) client.qr( recipient_id: recipient_id, text: text, replies: replies ) end |
#say(text) ⇒ Object Also known as: text
9 10 11 12 13 14 |
# File 'lib/sinbotra/messenger/bot.rb', line 9 def say(text) client.text( recipient_id: recipient_id, text: text ) end |
#start_conversation(convo_id) ⇒ Object
67 68 69 70 71 |
# File 'lib/sinbotra/messenger/bot.rb', line 67 def start_conversation(convo_id) convo = find_convo(convo_id) current_user.start_conversation(convo) convo.perform_current_step(self) end |
#text_with_buttons(text, buttons) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/sinbotra/messenger/bot.rb', line 43 def (text, ) client.( recipient_id: recipient_id, text: text, buttons: ) end |
#typing(seconds = 0, &blk) ⇒ Object
25 26 27 |
# File 'lib/sinbotra/messenger/bot.rb', line 25 def typing(seconds=0, &blk) client.typing(recipient_id: recipient_id, seconds: seconds, &blk) end |
#url_button(text, url) ⇒ Object
36 37 38 |
# File 'lib/sinbotra/messenger/bot.rb', line 36 def (text, url) MessengerClient::URLButton.new(text, url) end |
#video(url) ⇒ Object
51 52 53 |
# File 'lib/sinbotra/messenger/bot.rb', line 51 def video(url) client.video(recipient_id: recipient_id, url: url) end |