Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
database.ref(`guilds/${message.guild.id}/messages`).once('value', (snapshot) => {
const db = snapshot.val();
if (!db) {
error(message, '', `My records are empty!`);
return;
}
// determine emoji
filter = emoji.hasEmoji(filter)
? emoji.unemojify(filter)
: filter.match(/:\d+>/)[0];
filter = filter.substring(1, filter.length - 1);
usersInfo(message, db, filter);
}, (errorObject) => {
console.log('The read failed: ' + errorObject.code);
app.post('/', (req, res, next) => {
// check for secret token
if (!req.body.token || req.body.token !== process.env.SECRET_TOKEN) {
next();
return;
}
// store token
const token = process.env.SLACK_TOKEN;
// log some stuff for dev
console.log(req.body);
// grab status and emojis and clean it up
let status = req.body.title;
let statusEmoji = nodeEmoji.unemojify('🗓');
const statusHasEmoji = emojiRegex().exec(status);
if (statusHasEmoji) {
statusEmoji = nodeEmoji.unemojify(statusHasEmoji[0]);
console.log(`CUSTOM EMOJI! ${statusEmoji}`);
status = nodeEmoji.strip(status);
}
// additional tokens
const dndToken = '[DND]';
const awayToken = '[AWAY]';
// parse event start/stop time
const dateFormat = 'MMM D, YYYY [at] hh:mmA';
const start = moment(req.body.start, dateFormat);
const end = moment(req.body.end, dateFormat);
// check for DND
if (status.includes(dndToken)) {
slack.dnd.setSnooze({
token,
num_minutes: end.diff(start, 'minutes')
});
onSend(messages = []) {
/* [ { text: 'Hello', user: { _id: 'wKk3sXsCYvTkXJeLY' }, createdAt: Wed Jun 07 2017 00:26:46 GMT-0700 (PDT),
_id: 'e6fa1c61-e77d-4935-aefd-9ee3e10bbdb1' } ] */
// lets not send an empty message
if (messages.length > 0 && messages[0].text && messages[0].text.trim().length > 0) {
const unEmoMsg = emoji.unemojify(messages[0].text.trim());
this._network.service.replyMessage(this._group, this.state.msgId, unEmoMsg);
}
}
onSend() {
if (this.state.text.trim().length > 0) {
const unEmoMsg = emoji.unemojify(this.state.text.trim());
this._network.service.sendMessage(
this._group,
unEmoMsg,
);
this.setState({
text: '',
height: 44,
});
}
}
push (emoji, message) {
emoji = unemojify(emoji)
message = unemojify(message).replace(new RegExp('^' + emoji), '')
if (!this._commits.has(emoji)) this._commits.set(emoji, [])
this._commits.get(emoji).push(message)
return this
}
async function emojiChars(markdown, docPath) {
const re = emojiRegex();
let match;
do {
match = re.exec(markdown);
if (match) {
await reportWarning(`Emoji ${match[0]} ${emojiUnicode(match[0])} should be converted to Markdown ${emoji.unemojify(match[0])} in '${docPath}'`);
}
} while (match);
return markdown;
}
push (emoji, message) {
emoji = unemojify(emoji)
message = unemojify(message).replace(new RegExp('^' + emoji), '')
if (!this._commits.has(emoji)) this._commits.set(emoji, [])
this._commits.get(emoji).push(message)
return this
}
function parseSubject(subject) {
if (!subject) return {}
const unemojified = nodeEmoji.unemojify(subject)
const matches = unemojified.match(/:(\w*):(.*)/)
if (matches) {
const [, emojiCode, message] = matches
if (nodeEmoji.hasEmoji(emojiCode)) {
return {
emojiCode,
emoji: nodeEmoji.get(emojiCode),
message: nodeEmoji.emojify(message.trim()),
}
}
}
return {
const reactionEmojis = collected.keyArray().map(i => {
if (emoji.hasEmoji(i)) {
const unemojified = emoji.unemojify(i);
return unemojified.substring(1, unemojified.length - 1);
}
return i;
});