New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

reddit-notifier

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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.

latest
npmnpm
Version
1.3.0
Version published
Maintainers
1
Created
Source

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');
  }
}

FAQs

Package last updated on 25 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts