How to use the html-entities.AllHtmlEntities.decode function in html-entities

To help you get started, we’ve selected a few html-entities 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 statico / memorybot / lib / engine.js View on Github external
async handleMessage (bot, sender, channel, isDirect, msg) {
    // Ignore ourself.
    if (sender === bot.identity.id || sender === bot.identity.name) return

    const {mbMeta} = bot
    const team = bot.identifyTeam()
    const shouldLearn = isDirect || mbMeta.ambient // Should we be learning factoids?
    const shouldReply = isDirect || !mbMeta.direct // Should we reply to this?
    const isVerbose = mbMeta.verbose // TODO: Combine with shouldLearn

    // Sometimes Slack sends HTML entities.
    msg = Entities.decode(msg)

    // Basic input sanitization.
    msg = msg.substr(0, MAX_FACTOID_SIZE).trim().replace(/\0/g, '').replace(/\n/g, ' ')

    // Simple reply helper.
    const reply = text => bot.reply({channel}, {text})

    // Used to parse a factoid's contents and reply with it.
    const parseAndReply = async (key, value, tell = null) => {
      // Factoids are stored as { key: "foo", value: "is bar" }
      let [, verb, rest] = Array.from(value.match(/^(is|are)\s+(.*)/i))
      value = rest

      // Split on |, but don't split on \|. Use an HTML entity as a separator.
      value = value.replace(/\\\|/g, '\\|')
      value = this.oneOf(value.split(/\|/i)).trim()
github LakeYS / Discord-Trivia-Bot / triviabot.js View on Github external
game[id].correctId = 0;
  }
  else {
    // Sort the answers in reverse alphabetical order.
    answers.sort();
    answers.reverse();

    for(var i = 0; i <= answers.length-1; i++) {
      answers[i] = answers[i].toString();

      if(answers[i] === correct_answer) {
        game[id].correctId = i;
      }

      answerString = `${answerString}**${Letters[i]}:** ${entities.decode(answers[i])}${getConfigVal("debug-mode")&&i===game[id].correctId?" *(Answer)*":""}\n`;
    }
  }

  var categoryString = entities.decode(question.category);

  var timer = getConfigVal("round-length", channel);

  if(gameMode === 2) {
    // Hangman games get an extra ten seconds for balance.
    timer = timer+10000;
  }

  var infoString = "";
  if(!scheduled) {
    infoString = "\n";
github LakeYS / Discord-Trivia-Bot / triviabot.js View on Github external
Trivia.parseAnswerHangman = function(str, id, userId, username, scoreValue) {
  var input = str.toLowerCase();
  // Decode and remove all non-alphabetical characters
  var answer = entities.decode(game[id].answer).toLowerCase().replace(/\W/g, "");

  // Return -1 if the input is a command.
  // If the input is much longer than the actual answer, assume that it is not an attempt to answer.
  if(input.startsWith(getConfigVal("prefix", id)) || input.length > answer.length*2) {
    return -1;
  }

  if(input.replace(/\W/g, "") === answer) {
    return Trivia.parseAnswer(Letters[game[id].correctId], id, userId, username, scoreValue);
  }
  else {
    // The string doesn't match, so we'll pass the first incorrect answer.
    var incorrect = Letters.slice(0); // Copy to avoid modifying it
    incorrect.splice(game[id].correctId, 1);
    return Trivia.parseAnswer(incorrect[0], id, userId, username, scoreValue);
  }
github LakeYS / Discord-Trivia-Bot / triviabot.js View on Github external
case "hard":
        color = 14164000;
        break;
    }
  }
  game[id].color = color;

  var answerString = "";
  if(gameMode === 2) {
    var answer = entities.decode(correct_answer);

    var obscuredAnswer = createObscuredAnswer(answer);
    answerString = obscuredAnswer;

    if(getConfigVal("debug-mode")) {
      answerString = `${answerString} *(Answer: ${entities.decode(correct_answer)})*`;
    }

    game[id].correctId = 0;
  }
  else {
    // Sort the answers in reverse alphabetical order.
    answers.sort();
    answers.reverse();

    for(var i = 0; i <= answers.length-1; i++) {
      answers[i] = answers[i].toString();

      if(answers[i] === correct_answer) {
        game[id].correctId = i;
      }
github notable / notable / src / renderer / utils / markdown.ts View on Github external
replace ( match, $1 ) {
          init ();
          const id = `mermaid-${CRC32.str ( $1 )}`;
          try {
            const svg = mermaid.render ( id, entities.decode ( $1 ) );
            return `<div class="mermaid">${svg}</div>`;
          } catch ( e ) {
            console.error ( `[mermaid] ${e.message}` );
            $(`#${id}`).remove ();
            return `<p class="text-warning">[mermaid error: ${e.message}]</p>`;
          }
        }
      }];
github notable / notable / src / renderer / utils / highlighter.ts View on Github external
highlight ( str: string, language?: string ): string {

    if ( !language ) return str;

    const lang = Highlighter.languagesAliases[language] || language;

    if ( !Highlighter.initLanguage ( lang ) ) return str;

    return Prism.highlight ( entities.decode ( str ), Prism.languages[language], language );

  }
github TudbuT / bottyclient / node_modules / ytdl-core / lib / info-extras.js View on Github external
exports.getVideoDescription = (html) =&gt; {
  const regex = /(.+?)&lt;\/p&gt;[\n\r\s]*?&lt;\/div&gt;/im;
  const description = html.match(regex);
  return description ?
    Entities.decode(util.stripHTML(description[1])) : '';
};
github dragonbanshee / node-steam-chat-bot / lib / triggers / linkNameTrigger.js View on Github external
request(splitmes[i], function (error, response, body) {
			if (!error &amp;&amp; response.statusCode === 200) {
				//split at <title>
				var match = re.exec(body);
				if (match &amp;&amp; match[2]) {
					//send title message
					var ln = "" + match[2];
					that._sendMessageAfterDelay(toId, ent.decode(ln));
				}
				match = re.exec(body);
			}
		});
	}</title>
github pivotal-cf / pivotal-ui / styleguide_new / src / components / code_area / html_code_area.js View on Github external
changeHandler(value) {
    this.setState({code: AllHtmlEntities.decode(value)});
  }
github sogehige / sogeBot / src / bot / message.js View on Github external
}
      this.message = this.message.replace(/\$spotifySong/g, format.replace(/\$song/g, spotifySong.song).replace(/\$artist/g, spotifySong.artist));
    } else {this.message = this.message.replace(/\$spotifySong/g, translate('songs.not-playing'))};


    if (songs.enabled
        && this.message.includes('$ytSong')
        && Object.values(songs.isPlaying).find(o => o)) {
      let currentSong = _.get(JSON.parse(await songs.currentSong), 'title', translate('songs.not-playing'));
      if (opts.escape) {
        currentSong = currentSong.replace(new RegExp(opts.escape, 'g'), `\\${opts.escape}`);
      }
      this.message = this.message.replace(/\$ytSong/g, currentSong);
    } else {this.message = this.message.replace(/\$ytSong/g, translate('songs.not-playing'))};

    return Entities.decode(this.message);
  }