Commit 57807ebb authored by Eric Meier's avatar Eric Meier

dynmic reconnect messages

parent 0a994819
......@@ -73,7 +73,7 @@ bot.dialog("vote", require("./dialogs/vote"));
bot.dialog("welcome", require("./dialogs/welcome"));
bot.dialog("settings", require("./dialogs/settings"));
bot.dialog("learning", require("./dialogs/learning"));
bot.dialog("join", require("./dialogs/join"));
bot.dialog("recent", require("./dialogs/recent"));
/*bot.dialog("debug", session => {
session.beginDialog("welcome");
......@@ -88,7 +88,14 @@ bot.on("conversationUpdate", activity => {
activity.membersAdded.forEach(identity => {
// say hello only when bot joins and not when user joins
if (identity.id === activity.address.bot.id) {
bot.beginDialog(activity.address, "welcome");
var session = bot.loadSession(
activity.address,
(error, session) => {
if (session.userData.currentArticle)
bot.beginDialog(activity.address, "vote");
else bot.beginDialog(activity.address, "recent");
}
);
}
});
}
......
......@@ -58,8 +58,6 @@ module.exports = [
topic: "a topic"
};
session.beginDialog("vote");
next();
}
];
......
......@@ -5,7 +5,7 @@ const GSearch = require("../utils/gsearch");
module.exports = [
(session, args, next) => {
session.send(
"Give me a sec, \n\n I am currently looking through your history 😨"
"Give me a sec, \n\n I am currently looking through your history to get you started where you left of! 😨"
);
setTimeout(() => next(), 1000);
},
......
......@@ -33,7 +33,12 @@ module.exports = [
session.userData.currentArticle.topic,
session.userData.currentArticle.url,
true,
args.response.index
args.response.index,
session.userData
);
session.userData.currentArticle = undefined;
next();
}
];
var getRecentQueryStrings = (count, userData) => {
if (!userData.recentQueries) userData.recentQueries = [];
return userData.recentQueries
.slice(0, count)
.map(query => query.queryString);
};
var getRecentQueries = (count, userData) => {
if (!userData.recentQueries) userData.recentQueries = [];
return userData.recentQueries.slice(0, count);
};
var addQuery = (query, userData) => {
if (!userData.recentQueries) userData.recentQueries = [];
userData.recentQueries.push({
query: queryString,
suggestions: suggestions
......@@ -18,9 +22,12 @@ var addQuery = (query, userData) => {
};
var addAnalytic = (queryString, url, clicked, rating, userData) => {
var suggestion = userData.recentQueries
.find(q => q.query == queryString)
.suggestions.find(suggestion => suggestion.url == url);
if (!userData.recentQueries) userData.recentQueries = [];
var query = userData.recentQueries.find(q => q.query == queryString);
if (!query) return;
suggestion = query.suggestions.find(suggestion => suggestion.url == url);
suggestion.clicked = clicked;
suggestion.rating = rating;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment