npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

message-filter

v1.0.32

Published

A library for filtering and categorizing incoming messages based on content, sentiment, or other criteria.

Downloads

27

Readme

Message Filter

Message Filter is an NPM package that provides tools for filtering and categorizing incoming messages based on content, sentiment, or other criteria. This enables bots to more effectively manage and respond to user messages.

Installation

To install the Message Filter package, use NPM:

npm install message-filter

You will also need to install all of the requirements to run the package, using NPM:

npm install

Usage

Here is an example of how to use the Message Filter package to filter and categorize messages:

const { MessageFilter, hasKeyword, getSentiment, filterMessages, categorizeMessages } = require('message-filter');

const messages = [  { content: 'Can you help me with something urgent?', sender: 'user123' },  { content: 'I need help with my account', sender: 'user456' },  { content: 'This product is amazing!', sender: 'user789' },  { content: 'I have a question about your service', sender: 'user123' }];

const messageFilter = new MessageFilter();

messageFilter.addFilter((message) => {
  return hasKeyword(message, ['urgent', 'important']) && getSentiment(message) > 0;
});

messageFilter.addCategory((message) => {
  if (hasKeyword(message, ['urgent', 'important']) && getSentiment(message) > 0) {
    return 'urgent';
  } else if (hasKeyword(message, ['help', 'support'])) {
    return 'support';
  } else {
    return 'other';
  }
});

const filteredMessages = messageFilter.filter(messages);
const categorizedMessages = messageFilter.categorize(messages);

console.log(filteredMessages);
// Output: [{ content: 'Can you help me with something urgent?', sender: 'user123' }]

console.log(categorizedMessages);
// Output: {
//   urgent: [{ content: 'Can you help me with something urgent?', sender: 'user123' }],
//   support: [
//     { content: 'Can you help me with something urgent?', sender: 'user123' },
//     { content: 'I need help with my account', sender: 'user456' },
//     { content: 'I have a question about your service', sender: 'user123' }
//   ],
//   other: [{ content: 'This product is amazing!', sender: 'user789' }]
// }

First, we import the necessary functions and class from the message-filter package. Then, we create a new MessageFilter instance and add a filter and a category function using the addFilter and addCategory methods. Finally, we use the filter and categorize methods to filter and categorize the messages.

Final Notes

Message Filter is a powerful tool for filtering and categorizing incoming messages in a way that enables bots and other software applications to more effectively manage and respond to user messages. By using the functions and methods provided by this package, you can quickly and easily filter messages based on content, sentiment, or other criteria, and categorize them for further processing. Whether you're building a chatbot, an email filtering system, or any other application that involves processing user messages, Message Filter can help you save time and increase efficiency.