-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwordFilling.ts
More file actions
37 lines (33 loc) · 1.5 KB
/
Copy pathwordFilling.ts
File metadata and controls
37 lines (33 loc) · 1.5 KB
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
'use strict';
import { IBlankGrabber, BlankGrabber } from './blankGrabber';
export class WordFillingHandler {
constructor(private blankGrabber : IBlankGrabber = new BlankGrabber()) {
}
public handler() {
console.log('word filling handler func called');
const self = this;
return {
'ProvideWordIntent' : function() {
const wordSlot = this.event.request.intent.slots.word;
if(!(wordSlot && wordSlot.value)) {
this.emitWithState('Unhandled');
return;
}
self.blankGrabber.fillBlank(this.attributes.blanks, wordSlot.value);
console.log(`blanks is ${JSON.stringify(this.attributes.blanks)}`);
let blank = self.blankGrabber.getNextBlank(this.attributes.blanks);
console.log(`blanks is ${JSON.stringify(blank)}`);
//TODO: Check if they are all filled out
if(blank == undefined) {
let story = self.blankGrabber.replaceInStory(this.attributes.blanks, this.attributes.story);
this.emit(':tell', `OK heres the story. ${story}`);
return;
}
this.emit(':ask', `Great! Could you give me a ${blank.spoken_name} ?`);
},
'Unhandled' : function() {
this.emit(':ask', "Sorry, I didn't understand that, try saying it again.")
}
}
}
}