-
Notifications
You must be signed in to change notification settings - Fork 0
/
suggestion-chips.js
40 lines (34 loc) · 1.14 KB
/
suggestion-chips.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
const preferences = require('./preferences');
const SHOW_SUGGESTIONS_EVERY_N_TIMES = 5;
module.exports.chips = (conv) => {
const prefs = preferences.get(conv);
const ret = [];
ret.push('Smoke ' + (prefs.smoke_correction ? 'Off' : 'On'));
if (conv.surface.capabilities.has('actions.capability.INTERACTIVE_CANVAS'))
ret.push('Images ' + (prefs.backgrounds ? 'Off' : 'On'));
ret.push({ classname: 'location', text: 'Update location' });
ret.push('Remember location');
return ret;
}
module.exports.standard = (items) => {
return items.map(v => {
if (typeof v === 'string') {
return v;
}
return v.text;
});
}
module.exports.phrase = (conv) => {
let counter = conv.user.storage.q || 1;
if (counter % SHOW_SUGGESTIONS_EVERY_N_TIMES == 0) {
counter = 1;
} else {
counter++;
}
conv.user.storage.q = counter;
if (counter != 2) {
return null;
}
const s = preferences.get(conv).smoke_correction ? 'off' : 'on';
return 'By the way, you can ask me to update or remember location, enable brief mode, or turn ' + s + ' smoke correction.';
}