-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.rb
executable file
·59 lines (56 loc) · 1.41 KB
/
bot.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env ruby
# The basic usage script from https://github.com/JEG2/highline.git
#
## Introduction
# This bot is responsible for handling a short information conversation
# with up to four choices.
#
## Installation
# cd to greeenbot-core
# npm install subprompts-bot
#
## Issues
# * We only support four choices
require './lib/greenbot.rb'
# When the script starts, send out the first two prompts to the inbound
# messager
#
tell ENV['PROMPT_1']
tell ENV['PROMPT_2']
begin
tasks = ENV['MENU_CHOICES'].split(',').map(&:strip)
tasks << 'quit'
tasks << 'contactme'
my_task = select(ENV['MENU_PROMPT'], tasks).downcase
case my_task
when 'contactme'
if confirm(ENV['CONFIRM_CONTACT'])
contact_me = true
contact_me.remember('contact_me')
name = ask(ENV['WHO_TO_ASK_FOR'])
name.remember('who_to_ask_for')
if confirm(ENV['PREFER_ALTERNATE_CONTACT'])
better_number = ask(ENV['ALTERNATE_CONTACT_COLLECTION'])
better_number.remember('better_number')
end
else
tell(ENV['DONT_CONTACT_PROMPT'])
contact_me = false
contact_me.remember('contact_me')
end
when 'quit'
break
else
case tasks.map(&:downcase).index(my_task)
when 0
tell ENV['FIRST_CHOICE']
when 1
tell ENV['SECOND_CHOICE']
when 2
tell ENV['THIRD_CHOICE']
when 3
tell ENV['FOURTH_CHOICE']
end
end
end while true
tell ENV['SIGNATURE']