How to use the node-emoji.strip function in node-emoji

To help you get started, we’ve selected a few node-emoji examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bjork24 / google-calendar-slack-status / index.js View on Github external
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')
    });
    status = status.replace(dndToken, '').trim();
  }