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

reddit-notifier

v1.3.0

Published

## Summary This tool can be run as either a service or as a regular process and can notify you via Pushbullet when posts are made to a subreddit based on criteria you specify.

Downloads

5

Readme

Reddit Notifier

Summary

This tool can be run as either a service or as a regular process and can notify you via Pushbullet when posts are made to a subreddit based on criteria you specify.

Eventually, more notification mechanisms may come, and contributions are welcome

Usage

Installing this package globally will provide a global script named reddit-notifier.

npm i -g reddit-notifier@latest

reddit-notifier --version
reddit-notifier --help
reddit-notifier --config ~/.reddit-notifier/config.js --data-dir ~/.reddit-notifier/data

The data directory is where logs and state will be stored.

Configuration

Below is a sample configuration

{
  "pushbullet": {
    "apiKey": "",
    "deviceId": "",
    "encryptionKeyBase64": ""
  },
  "monitor": {
    "subreddit": "test",
    "matches": {
      "title": {
        "any": [
          {
            "matches": "^reddit-notifier"
          }
        ]
      }
    }
  }
}
  • pushbullet.apiKey: the api key to pushbullet. It can be retrieved from your Pushbullet Settings
  • pushbullet.deviceId: string | string[] | {}. It can be a single device id, an array of them, or {} if you want to notify all of your devices. You can get your device ids in the settings under devices. Simply select your device and pull the hash from the URL
  • monitor.subreddit: the name of the subreddit to monitor. currently only one is supported
  • monitor.matches: you may specify any key in this section that matches a field of the reddit post json. Common fields are title and author. See Pushshift api for a list
  • monitor.matches..any: to be notified of a post, at least one item in this array must match
  • monitor.matches..none: to be notified of a post, at no item in this array must match

JS Configuration

You may specify your configuration as an ES6 module

module.exports = {
  "pushbullet": {
    "apiKey": "",
    "deviceId": "",
    "encryptionKeyBase64": ""
  },
  "monitor": {
    "subreddit": "test",
    "matches": {
      "title": {
        "any": [
          {
            "matches": "^reddit-notifier"
          }
        ]
      }
    }
  }
}

Matchers

A configuration may be specified as either a JSON or a JS file. Either one can specify matchers as an object, but a JS configuration can also specify a matcher as a function.

Object matchers

monitor.matches..any and monitor.matches..none follow the same specification. They may have one or more keys from the following set:

  • matches: regular expression match on the field (case insensitive)
  • equals: direct equality match (case sensitive)
  • greaterThan: numeric comparison
  • lessThan: numeric comparison

The implication with this design is that you may specify multiple criteria for multiple fields. In order to match, a post must match on ALL of the fields specified under monitor.matches (works like a logical AND), but each field may have a number of OR conditions (each item in ANY). Every clause under monitor.matches.<FIELD>.any[#] must be matched (see second example)

Examples

Title field must start with 'hello'
{
  "title": {
    "any": [{
      "matches": "^hello"    
    }]
  }
}
Created field must be greater than 2, but less than 5
{
  "created": {
    "any": [{
      "lessThan": 5,
      "greaterthan": 2
    }],
  }
}
Created field must be greater than 2, but less than 5, and not 3
{
  "created": {
    "any": [{
      "lessThan": 5,
      "greaterthan": 2
    }],
    "none": [{
      "equals": 3
    }]
  }
}
Author must be Bob, and title must start with hello''
{
  "title": {
    "any": [{
      "matches": "^hello"
    }]
  },
  "author": {
    "any": [{
      "equals": "Bob"
    }]
  }
}

Function matchers

{ 
  "title": function(post) {
    return post.startsWith('hello');
  }
}