Commit 47f65a7d authored by Eric Meier's avatar Eric Meier
parents e7222322 bc3a135c
......@@ -96,24 +96,29 @@ bot.on("conversationUpdate", activity => {
});
server.get("/redirect/:address/:url", (req, res, next) => {
const address = decodeURI(req.params.address);
const url = decodeURI(req.params.url);
bot.loadSession(address, (error, session) => {
let suggestion = suggestionStore.getSuggestionByUrl(
address,
session.userData
);
suggestionStore.addAnalytic(
address,
true,
suggestion.rating,
session.userData
);
});
res.setHeader("Content-Type", "text/html");
res.writeHead(200);
res.end(`<script>window.location = '${url}';</script>`);
next();
try {
var address = atob(req.params.address);
var url = atob(req.params.url);
}
if (url && address) {
bot.loadSession(address, (error, session) => {
let suggestion = suggestionStore.getSuggestionByUrl(
address,
session.userData
);
suggestionStore.addAnalytic(
address,
true,
suggestion.rating,
session.userData
);
});
res.setHeader("Content-Type", "text/html");
res.writeHead(200);
res.send(`<script>window.location = '${url}';</script>`);
next();
}else{
console.log("Not base64 encoded!");
}
});
......@@ -28,15 +28,13 @@ module.exports = [
session.dialogData.topic = session.dialogData.topic || args.response;
if (!session.dialogData.skillLevel) {
builder.Prompts.choice(
session,
answers.formatedRandomAnswer("learn.skill", [
session.userData.name,
session.dialogData.topic
]),
"nothing|something|a lot",
{ listStyle: 3 }
const choices = ["Nothing", "Something", "A lot"];
const reply = new builder.Message(session).addAttachment(
diffCard(session, choices)
);
builder.Prompts.choice(session, reply, choices);
} else next();
},
......@@ -114,3 +112,17 @@ const getDuration = entities => {
return duration.resolution.values[0].value;
return null;
};
const diffCard = (session, choices) => {
return new builder.HeroCard(session)
.text(
answers.formatedRandomAnswer("learn.skill", [
session.userData.name,
session.dialogData.topic
])
)
.buttons([
builder.CardAction.postBack(session, choices[0], choices[0]),
builder.CardAction.postBack(session, choices[1], choices[1]),
builder.CardAction.postBack(session, choices[2], choices[2])
]);
};
......@@ -35,9 +35,9 @@ const suggCard = (session, sugg) => {
.buttons([
builder.CardAction.openUrl(
session,
`http://localhost:3978/redirect/${encodeURI(
session.logger.address
)}/${encodeURI(sugg.url)}`,
`http://localhost:3978/redirect/${btoa(
session.logger.address.id
)}/${btoa(sugg.url)}`,
"Open Website"
),
builder.CardAction.postBack(
......
......@@ -25,20 +25,21 @@ const getSyns = base => {
let out = "";
let syns = {};
syns["learn"] = getSyns("learn");
syns["want"] = getSyns("search");
syns["need"] = getSyns("need");
syns["explore"] = getSyns("explore");
syns["about"] = getSyns("about");
syns["like"] = getSyns("like");
syns["have"] = getSyns("know");
syns["some"] = getSyns("a lot");
syns["knowledge"] = getSyns("medium");
syns["got"] = getSyns("got");
syns["average"] = getSyns("average");
syns["knowledge"] = getSyns("understanding");
for (let index = 0; index < 25; index++) {
out +=
"I " +
syns["have"][index] +
syns["need"][index] +
" " +
syns["about"][index] +
syns["explore"][index] +
" " +
randomTopic() +
" " +
randomTopic() +
" " +
......@@ -48,11 +49,9 @@ for (let index = 0; index < 25; index++) {
" " +
randomTopic() +
" and " +
syns["have"][index] +
syns["got"][index] +
" " +
syns["knowledge"][index] +
" " +
syns["about"][index] +
"\n";
}
......
......@@ -24,7 +24,8 @@ npm manifest:
"botbuilder-azure": "^3.0.4",
"cheerio": "^1.0.0-rc.2",
"restify": "^5.0.0",
"sync-request": "^6.0.0"
"sync-request": "^6.0.0",
"xmlhttprequest": "^1.8.0"
},
"devDependencies": {
"request": "^2.81.0",
......@@ -1868,6 +1869,10 @@ Lockfile:
version "0.4.3"
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-0.4.3.tgz#c4614ba74e0ad196e609c9272cd9e1ddb28a8a58"
xmlhttprequest@^1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz#67fe075c5c24fef39f9d65f5f7b7fe75171968fc"
xtend@^4.0.0, xtend@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"
......
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