Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
total += roll;
rolls.push(roll);
}
// Format roll results
var results = '';
var multiLine = rolls.length > 5;
for (var i = 0; i < rolls.length; i++) {
if (i > 0) {
results += ' . ';
}
results += rolls[i];
}
// Render results using a card
var card = new builder.HeroCard(session)
.subtitle(game.count > 1 ? 'card_subtitle_plural' : 'card_subtitle_singular', game)
.buttons([
builder.CardAction.imBack(session, 'roll again', 'Roll Again'),
builder.CardAction.imBack(session, 'new game', 'New Game')
]);
if (multiLine) {
//card.title('card_title').text('\n\n' + results + '\n\n');
card.text(results);
} else {
card.title(results);
}
var msg = new builder.Message(session).addAttachment(card);
// Determine bots reaction for speech purposes
var reaction = 'normal';
var min = game.count;
const showProduct = function(session, product) {
session.sendTyping();
const tile = new builder.HeroCard(session)
.title(product.title)
.subtitle(`$${product.price}`)
.text(product.description)
.buttons(
product.modifiers.length === 0 ||
(product.size.length <= 1 && product.color.length <= 1)
? [
builder.CardAction.postBack(
session,
`@add:${product.id}`,
'Add To Cart'
)
]
: []
)
.images([builder.CardImage.create(session, product.image)]);
.type("imBack")
.value(button.url)
.title(button.name || button.content || "Click to send response to bot");
}, attachmentButtons);
let messageAttachments: any[] = [];
const messageBuilder = new botbuilder.Message()
.textFormat(botbuilder.TextFormat.markdown)
.address(address as botbuilder.IAddress);
if (type === "Note") {
if (!messageButtons) {
messageBuilder.text(content);
} else {
messageAttachments = [
new botbuilder.HeroCard()
.title(name)
.text(content)
.buttons(messageButtons),
];
}
} else if (type === "Image" || type === "Video") {
const url = R.path(["object", "url"], data);
const hero = new botbuilder.HeroCard()
.title(name)
.text(content);
if (messageButtons) {
hero.buttons(messageButtons);
}
if (type === "Image") {
function searchHitAsCard(showSave, searchHit) {
var buttons = showSave
? [new builder.CardAction().type('imBack').title('Save').value(searchHit.key)]
: [];
var card = new builder.HeroCard()
.title(searchHit.title)
.buttons(buttons);
if (searchHit.description) {
card.subtitle(searchHit.description);
}
if (searchHit.imageUrl) {
card.images([new builder.CardImage().url(searchHit.imageUrl)]);
}
return card;
}
} else if (type.length == 2 && type[1].type == "rss"){
var data = JSON.parse(body).answers[0].data;
var columns = type[1];
var key = Object.keys(columns);
var msg,title;
for (var i = 0; i < 4; i++) {
if(i==0){
msg = (JSON.parse(body)).answers[0].actions[0].expression;
session.sendTyping();
session.say(msg, msg);
} else{
msg =key[2].toUpperCase() + ": " + data[i][key[2]] + "\n" + "\n" + key[3].toUpperCase() + ": " + data[i][key[3]];
title = data[i][key[1]];
cards[i] = new builder.HeroCard(session)
.title(title)
.text(msg)
}
}
var reply = new builder.Message(session)
.attachmentLayout(builder.AttachmentLayout.carousel)
.attachments(cards);
session.sendTyping();
session.send(reply);
} else {
var msg = "Oops looks like SUSI is taking a break try again later."
session.sendTyping();
session.say(msg, msg);
}
function constructCard(session, image) {
return new builder.HeroCard(session)
.title(image.name)
.subtitle(image.hostPageDisplayUrl)
.images([
builder.CardImage.create(session, image.thumbnailUrl)
])
.buttons([
builder.CardAction.openUrl(session, image.hostPageUrl, 'Buy from merchant'),
builder.CardAction.openUrl(session, image.webSearchUrl, 'Find more in Bing')
]);
}
.onBegin(function (session, args) {
const possibleBranches = [ session.gettext(Strings.FavoriteLocations), session.gettext(Strings.OtherLocation) ];
let buttons = new Array();
for (let i =0; i < possibleBranches.length; i++) {
var button = new CardAction(session);
button.type("imBack");
button.value(possibleBranches[i]);
button.title(possibleBranches[i]);
buttons.push(button);
}
var card = new HeroCard();
card.buttons(buttons);
card.subtitle(session.gettext(Strings.DialogStartBranchAsk));
var attachments = new Array();
attachments.push(card.toAttachment());
session.send( new Message(session).attachmentLayout(AttachmentLayout.carousel).attachments(attachments)).sendBatch();
}).onDefault((session) => {
const text: string = session.message.text;
.address(address as botbuilder.IAddress);
if (objectType === 'Note') {
if (!messageButtons) {
messageBuilder.text(content);
} else {
messageAttachments = [
new botbuilder.HeroCard().title(name).text(content).buttons(messageButtons),
];
}
messageBuilder.attachments(messageAttachments);
return messageBuilder;
} else if (objectType === 'Image' || objectType === 'Video') {
const url: string = R.path(['object', 'url'], data) as string;
const hero = new botbuilder.HeroCard().title(name).text(content);
if (messageButtons) { hero.buttons(messageButtons); }
if (objectType === 'Image') {
hero.images([new botbuilder.CardImage().url(url)]);
messageAttachments = [hero];
messageBuilder.attachments(messageAttachments);
return messageBuilder;
} else {
return fileInfo(url, this.logger)
.then((infos) => {
messageAttachments = [{ contentType: infos.mimetype, contentUrl: url }, hero];
messageBuilder.attachments(messageAttachments);
return messageBuilder;
});
//message.type 0 means text message
case 0:
{
if (SkypeBot.isDefined(message.speech)) {
session.send(message.speech);
}
}
break;
//message.type 1 means card message
case 1:
{
let heroCard = new botbuilder.HeroCard(session).title(message.title);
if (SkypeBot.isDefined(message.subtitle)) {
heroCard = heroCard.subtitle(message.subtitle)
}
if (SkypeBot.isDefined(message.imageUrl)) {
heroCard = heroCard.images([botbuilder.CardImage.create(session, message.imageUrl)]);
}
if (SkypeBot.isDefined(message.buttons)) {
let buttons = [];
for (let buttonIndex = 0; buttonIndex < message.buttons.length; buttonIndex++) {
let messageButton = message.buttons[buttonIndex];
if (messageButton.text) {