Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports.createMessage = function (roomMember, text) {
text = ent.encode(text);
if (!text || !text.length) {
throw new InvalidInputError(); // block the trolls
}
else if (/^\/nick\s+/i.test(text)) {
return setUserNick(roomMember, text); // Change the current user's nick
}
else if (/^\/(away|afk|busy)/i.test(text)) {
return setUserBusy(roomMember, text); // away, afk, busy (with optional message)
}
else if (/^\/help/i.test(text)) {
return getHelp(roomMember, text);
}
else if (/^\/stats/i.test(text)) {
return stats(roomMember, text);
}
.map(command => {
const signature =
typeof command === 'object'
? command.signature // Capitano
: capitanoizeOclifUsage(command.usage); // oclif
return `\t- [${ent.encode(signature)}](${getAnchor(signature)})`;
})
.join('\n'),
function generateTextCostSymbols(source) {
var tagged;
if (source !== undefined) {
// Get rid of / in any costs first, but only if inside {} brackets (so as not to affect +1/+1).
source = source.replace(/(\/)(?=\w\})/g,'');
// Then generate the tags through setting the innerHtml. This is the only way to preserve the text around the img tags.
// Encode the source in html, to prevent XSS nastiness. Then replace the newlines with <br>. Then insert the <img> tags.
tagged = <div>').replace(/\{([0-z,½,∞]+)\}/g, (fullMatch, firstMatch) =>
`<img height="12px/" src="./src/img/${firstMatch.toLowerCase()}.png">`
)}}></div>
}
return tagged;
}
challenger,
opponent
) {
var opponentNick = opponent.nick;
var challengerNick = challenger.nick;
var message = [];
message.push("@" + challengerNick + " has challenged @" + opponentNick + " to a fight!");
message.push(
"Respond using /f " +
challengerNick +
" with 3 round moves, i.e. /f " +
challengerNick +
" h m l (see /help fight for more details)"
);
return { message: ent.encode(message.join("\n")) };
});
}
_format: function (def, str) {
var key, bundle, orig;
key = ent.encode(def.attributes.key || '');
bundle = ent.encode(this._handler.bundle.file || '');
orig = ent.encode(str || '');
return util.format(this._pattern, key, bundle, orig, str);
},
function renderCapitanoCommand(command: CapitanoCommand): string[] {
const result = [`## ${ent.encode(command.signature)}`, command.help];
if (!_.isEmpty(command.options)) {
result.push('### Options');
for (const option of command.options!) {
if (option == null) {
throw new Error(`Undefined option in markdown generation!`);
}
result.push(
`#### ${utils.parseCapitanoOption(option)}`,
option.description,
);
}
}
return result;
}