Skip to content

Commit c9b8978

Browse files
fixes from new skills test run on glitch
1 parent 632bde7 commit c9b8978

File tree

5 files changed

+29
-62
lines changed

5 files changed

+29
-62
lines changed

skills/about.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ module.exports = function (controller, bot) {
2121
"support-contact": "Stève Sfartz <mailto:[email protected]>",
2222

2323
// Messaging platform
24-
"plaform": bot.type,
24+
// [WORKAROUND] overriding Botkit's integrated support temporarly as 'ciscospark' is still returned
25+
//"plaform": bot.type,
26+
"plaform": "webex",
2527

2628
// the precise bot identity is loaded asynchronously, from a GET /people/me request
2729
"identity": "unknown",

skills/help.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ module.exports = function (controller) {
66
controller.hears([/^help$/], 'direct_message,direct_mention', function (bot, message) {
77
var text = "Here are my skills:";
88
text += "\n- " + bot.appendMention(message, "color") + ": ask to pick a random color";
9-
text += "\n- " + bot.enrichCommand(message, "loop") + ": example of a menu that loops until explicitly stopped";
10-
text += "\n- " + bot.enrichCommand(message, "menu") + ": implement a menu via a conversation";
11-
text += "\n- " + bot.enrichCommand(message, "quiz") + ": multi-threaded conversation with timeout";
9+
text += "\n- " + bot.appendMention(message, "loop") + ": example of a menu that loops until explicitly stopped";
10+
text += "\n- " + bot.appendMention(message, "menu") + ": implement a menu via a conversation";
11+
text += "\n- " + bot.appendMention(message, "quiz") + ": multi-threaded conversation with timeout";
1212
text += "\n- " + bot.appendMention(message, "restricted") + ": let a user pick a color among a set of options";
1313
text += "\n- " + bot.appendMention(message, "storage") + ": store picked color as a user preference";
14-
text += "\n- " + bot.enrichCommand(message, "timeout") + ": experience Botkit timeout";
1514
text += "\n- " + bot.appendMention(message, "threads") + ": branch to another thread";
1615
text += "\n- " + bot.appendMention(message, "variables") + ": enriched user-context among threads";
1716
text += "\n\nI also understand:";

skills/restricted.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ module.exports = function (controller) {
1818
{
1919
default: true,
2020
callback: function (response, convo) {
21-
convo.say("Sorry, I don't know this color. Try another one...");
22-
convo.repeat();
23-
convo.next();
21+
convo.gotoThread('bad_response');
2422
}
2523
}
2624
]);
25+
26+
// Bad response
27+
convo.addMessage({
28+
text: "Sorry, I don't know this color.<br/>_Tip: try blue, green, pink, red or yellow!_",
29+
action: 'default',
30+
}, 'bad_response');
2731
});
2832
});
2933
};

skills/storage.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ module.exports = function (controller) {
2222
return;
2323
}
2424

25-
// Ask for favorite color
26-
askForFavoriteColor(controller, bot, message, userId);
25+
// Ask for prefrence
26+
askForUserPreference(controller, bot, message, userId);
2727
});
2828
});
2929
}
@@ -33,19 +33,14 @@ function showUserPreference(controller, bot, message, userId, color) {
3333

3434
convo.sayFirst(`Hey, I know you <@personId:${userId}>!<br/> '${color}' is your favorite color.`);
3535

36-
// Remove user preferences if supported
37-
if (!controller.storage.users.remove) {
38-
convo.say("_To erase your preference, simply restart the bot as you're using in-memory transient storage._");
39-
convo.next();
40-
return;
41-
}
42-
43-
convo.ask("Should I erase your preference? yes/(no)", [
36+
convo.ask("Should I erase your preference? (yes/no)", [
4437
{
4538
pattern: "^yes|ya|da|si|oui$",
4639
callback: function (response, convo) {
4740

48-
controller.storage.users.remove(userId, function (err) {
41+
// [WORKAROUND] use storage.users.delete if in-memory storage and storage.users.remove if redis storage
42+
// controller.storage.users.remove(userId, function (err) {
43+
controller.storage.users.delete(userId, function (err) {
4944
if (err) {
5045
convo.say(message, 'sorry, could not access storage, err: ' + err.message);
5146
convo.repeat();
@@ -61,15 +56,15 @@ function showUserPreference(controller, bot, message, userId, color) {
6156
{
6257
default: true,
6358
callback: function (response, convo) {
64-
convo.say("Got it, leaving your color preference as is.");
59+
convo.say("Got it, leaving your preference as is.");
6560
convo.next();
6661
}
6762
}
6863
]);
6964
});
7065
}
7166

72-
function askForFavoriteColor(controller, bot, message, userId) {
67+
function askForUserPreference(controller, bot, message, userId) {
7368
bot.startConversation(message, function (err, convo) {
7469

7570
convo.ask("What is your favorite color?", [
@@ -87,21 +82,25 @@ function askForFavoriteColor(controller, bot, message, userId) {
8782
return;
8883
}
8984

90-
convo.transitionTo("success", `_stored user preference_`);
85+
convo.transitionTo("success", "_successfully stored user preference_");
9186
});
9287

9388
},
9489
},
9590
{
9691
default: true,
9792
callback: function (response, convo) {
98-
convo.say("Sorry, I don't know this color. Try another one...");
99-
convo.repeat();
100-
convo.next();
93+
convo.gotoThread('bad_response');
10194
}
10295
}
10396
], { key: "answer" });
10497

98+
// Bad response
99+
convo.addMessage({
100+
text: "Sorry, I don't know this color.<br/>_Tip: try blue, green, pink, red or yellow!_",
101+
action: 'default',
102+
}, 'bad_response');
103+
105104
// Success thread
106105
convo.addMessage(
107106
"Cool, I love '{{responses.answer}}' too",

skills/timeout.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)