/
magic_eight_ball_dialogue.rb
59 lines (48 loc) · 1.11 KB
/
magic_eight_ball_dialogue.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
# If using the gem, replace with:
#
# require 'rubygems'
# require 'james'
require File.expand_path '../../lib/james', __FILE__
# Time dialogue by Florian Hanke.
#
# This is a very simple James example.
#
# It has only one state, :shake, and a single
# entry/hook phrase, "Shake the eight ball"
#
class MagicEightBallDialogue
include James::Dialogue
attr_reader :states
def initialize
@states = [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes – definitely",
"You may rely on it",
"As I see it, yes",
"Most likely",
"Outlook good",
"Signs point to yes",
"Yes",
"Reply hazy, try again",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Concentrate and ask again",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful"
]
end
hear 'Shake the eight ball' => :joke
state :joke do
hear ['Shake the eight ball', 'Again'] => :joke
into do
states[rand(states.size)]
end
end
end
James.listen