Class: Sinbotra::Messenger::Bot

Inherits:
Object
  • Object
show all
Defined in:
lib/sinbotra/messenger/bot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_userObject (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_messageObject



63
64
65
# File 'lib/sinbotra/messenger/bot.rb', line 63

def current_message
  current_user.current_message
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, buttons)
end

#has_conversation?(convo_id) ⇒ Boolean

Returns:

  • (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

#locationObject



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 payload_button(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_with_buttons(text, buttons)
  client.button_template(
    recipient_id: recipient_id,
    text:         text,
    buttons:      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 url_button(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