-
Notifications
You must be signed in to change notification settings - Fork 0
/
Filmistaan.js
132 lines (121 loc) · 2.99 KB
/
Filmistaan.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
const genres = [
{
"id": 28,
"name": "Action"
},
{
"id": 12,
"name": "Adventure"
},
{
"id": 16,
"name": "Animation"
},
{
"id": 35,
"name": "Comedy"
},
{
"id": 80,
"name": "Crime"
},
{
"id": 99,
"name": "Documentary"
},
{
"id": 18,
"name": "Drama"
},
{
"id": 10751,
"name": "Family"
},
{
"id": 14,
"name": "Fantasy"
},
{
"id": 36,
"name": "History"
},
{
"id": 27,
"name": "Horror"
},
{
"id": 10402,
"name": "Music"
},
{
"id": 9648,
"name": "Mystery"
},
{
"id": 10749,
"name": "Romance"
},
{
"id": 878,
"name": "Science Fiction"
},
{
"id": 10770,
"name": "TV Movie"
},
{
"id": 53,
"name": "Thriller"
},
{
"id": 10752,
"name": "War"
},
{
"id": 37,
"name": "Western"
}
]
const stringifiedGenres = genres.map(({ name }) => name.toLowerCase()).join("|");
intent(['What does this app do?', 'What can I do here?', 'What is this app about?', 'Hi', 'Hello'], (p) => {
p.play(`Hello There! This is Filmistaan, an app where you can find the movies you love.
Try saying: 'Go to Comedy', 'Surprise me', 'Search for Superman', 'Make it dark', 'Log in'
`)
})
intent(["Make it dark","dark mode","kala kar de"], (p) => {
p.play({ command: 'changeMode', mode: 'dark' });
p.play('Batman likes it, I hope you do too!');
})
intent(["Make it light","light mode"], (p) => {
p.play({ command: 'changeMode', mode: 'light' });
p.play('Ahh, my eyes hurt. Looks good though.');
})
intent(["Log in", "Login"], (p) => {
p.play('Logging you in.');
p.play({ command: 'login' });
})
intent(["Log out", "Logout"], (p) => {
p.play('Logging you out.');
p.play({ command: 'logout' });
})
intent(`go to $(GENRE ${stringifiedGenres}|top rated|popular|upcoming)`, (p) => {
p.play(`Going to ${p.GENRE.value} category.`);
p.play({ command: 'chooseGenre', genreOrCategory: p.GENRE.value, genres });
})
intent('Search for $(QUERY* (.*))', (p) => {
p.play(`Searching for ${p.QUERY.value}`);
p.play({ command: 'search', query: p.QUERY.value });
})
intent(["It's Halloween.", "I want to get scared"], (p) => {
p.play({ command: 'chooseGenre', genreOrCategory: 'Horror', genres });
p.play("When Witches Go Riding and Black Cats Are Seen: The Moon Laughs and Whispers - It's Halloween");
})
intent(["Give me something funny.", "I want to laugh"], (p) => {
p.play({ command: 'chooseGenre', genreOrCategory: 'Comedy', genres });
p.play("Comedy it is. Enjoy!");
})
intent("Surprise me", (p) => {
const selectedCategory = genres[Math.floor(Math.random() * genres.length)].name;
p.play(`Sounds good. Enjoy some ${selectedCategory} movies.`);
p.play({ command: 'chooseGenre', genreOrCategory: selectedCategory, genres })
})