How to use the twitter-text.extractHashtags function in twitter-text

To help you get started, we’ve selected a few twitter-text 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 FreeFeed / freefeed-server / reindex_hashtags.js View on Github external
async function processPost(post){
  const postUUID = post.uid
    , postBody   = post.body
  try{
    const postTags = _.uniq(twitter.extractHashtags(postBody))

    if (!postTags || postTags.length == 0) {
      return
    }
    console.log(postTags)
    await dbAdapter.linkHashtagsByNames(postTags, postUUID)
  } catch (e) {
    console.log("-------------------------------------------------------")
    console.log(e)
    console.log("-------------------------------------------------------")
  }
}
github hackjutsu / Lepton / app / utilities / parser / index.js View on Github external
function parseCustomTagsTwitter (payload) {
  const rawCustomTags = twitter.extractHashtags(payload)
  if (rawCustomTags.length === 0) {
    return ''
  }

  const prefix = '#tags:'
  const customTags = prefix + rawCustomTags.reduce((acc, cur) => acc + ', ' + cur)
  return customTags
}
github kenforthewin / mentat / assets / js / components / App.js View on Github external
}

    if (e.key === "Enter") {
      e.preventDefault();
      this.typing = false;
      clearTimeout(this.typeTimeout);
      this.channel.push("new_typing", {uuid: this.props.userReducer.uuid, typing: false});

      if(e.target.value.length > 0 ) {
        if (e.target.value[0] === '#' && !e.target.value.includes(" ")) {
          return this.processTagFromInput(e);
        }
        const message = e.target.value;
        let allTags = this.state.tags.slice(0,1);
        const urls = this.props.userReducer.urlPreviews ? twitter.extractUrls(message).map((url) => url.startsWith('http') ? url : 'https://' + url) : [];
        const extractedTags = twitter.extractHashtags(message);
        extractedTags.forEach((extractedTag) => {
          const downcaseTag = extractedTag.toLowerCase();
          allTags = allTags.includes(downcaseTag) ? allTags : [
            ...allTags,
            downcaseTag
          ]
        })

        this.pubKeyObj = this.pubKeyObj || openpgp.key.readArmored(this.props.cryptoReducer.groups[this.room].publicKey).keys
        const options = {
          data: message,
          publicKeys: this.pubKeyObj,
          armored: false
        };

        openpgp.encrypt(options).then((ciphertext) => {
github GetStream / react-activity-feed / src / utils.js View on Github external
return (
          
            {!word.startsWith(`@${mention[0]}`) &&
              word.slice(0, word.indexOf(mention[0]) - 1)}
            <a> onClickMention &amp;&amp; onClickMention(mention[0])}
              className={`${parentClass}__mention`}
            &gt;
              @{mention[0]}
            </a>
            {!word.endsWith(mention[0]) &amp;&amp;
              word.slice(word.indexOf(mention[0]) + mention[0].length)}
          
        );
      } else if (onClickHashtag &amp;&amp; word.includes('#')) {
        const hashtag = twitter.extractHashtags(word);
        if (!hashtag.length) return word;

        return (
          
            {!word.startsWith(`#${hashtag[0]}`) &amp;&amp;
              word.slice(0, word.indexOf(hashtag[0]) - 1)}
            <a> onClickHashtag &amp;&amp; onClickHashtag(hashtag[0])}
              className={`${parentClass}__hashtag`}
            &gt;
              #{hashtag[0]}
            </a>
            {!word.endsWith(hashtag[0]) &amp;&amp;
              word.slice(word.indexOf(hashtag[0]) + hashtag[0].length)}
          
        );