twitch-notifier

1.1.4 • Public • Published

TWITCH NOTIFIER

contributions
npm version

FeaturesRequirementsUsageDevelopmentAbout

see table of content

🎺 Overview

Receive an email informing whenever your favorite twitch streamers go live.

I developed this solution because I think twitch way to handle notifications is not so optimized when you follow a lot of streamers, since you have to disable all the ones you don't want to receive notifications, rather than select only the streamers you want to get notified about.

Desktop view

Mobile view

So this tool allows me to disable all twitch notifications and get notified when my favorite streamers (razah and theprimeagen) go live.

🎯 Features

   ✔️ receive an email informing whenever your favorite streamers go live;
   ✔️ option set hours to not get notifications, like between 0-6 am;
   ✔️ set custom filtering words to ignore: skip notifications when the live title contains the word 'rerun';
   ✔️ set custom filtering words to search: get notified only when the live title contains the word 'live'.

⚠️ Requirements

The only thing you need to use this project is a gmail/google account.

💡 Usage

How it works

It basically sets a function to run in google apps scripts to run everyday at a specified time, and this function is responsable for:

  • visit each of your favorite streamers twitch link and store the information;
  • fitler all the data to only remain the ones you should be notified about, considering your specified options;
  • if there's at least one stream to notify you about, send an email containing the details.

Installation

To effectively use this project, do the following steps:

1 - create a Google Apps Scripts (GAS) project

Go to the google apps script and create a new project by clicking in the button showed in the next image.
It would be a good idea to rename the project to something like "twitch-notifier".

2 - setup the twitch-notifier code on GAS

Click on the initial file, which is the rectangle-1 on the image.

Replace the initial content present in the rectangle-2 with the content present in code bellow.

⚠️ Warning
Remember to update the CONFIGS object according to your data and needs.

const CONFIGS = {
  twitch: {
    channels: [
      ['razah', {}],
      ['gaules', {}],
      ['mch_agg', { searchedWords: ['live'] }],  // specific searched words | you only will be notified if the current stream title contain at least one of these words
      ['brnwowzk1', { ignoredWords: ['rr'] }]    // specific ignored words | if a the current stream title contains any of these words, you will not be notified about it
    ],
    maximumUptimeMinutes: 60,                    // if a stream uptime is greater than 'x' minutes, you'll not be notified
    ignoredWords: ['rerun']                      // globally ignored words | if a stream title contains any of these words, you will not be notified about it
  },
  settings: {
    disabledHours: [0, 1, 2, 3, 4, 5],           // skiped hours that twitch-notifier will not notify you about your streamers
    timeZoneCorrection: -3,                      // hour difference between your timezone and UTC/GMT timezone | https://www.utctime.net/
    minutesBetweenChecks: 10,                    // delay time between every check
    checkFunction: 'checkLiveStreams'            // development option, dont change
  }
};

function getTwitchNotifier(){
  const version = "1.1.4"
  const content = UrlFetchApp.fetch(`https://cdn.jsdelivr.net/npm/twitch-notifier@${version}`).getContentText();
  eval(content)
  const twitchNotifier = new TwitchNotifier(CONFIGS)
  return twitchNotifier;
}

function checkLiveStreams() {
  const twitchNotifier = getTwitchNotifier();
  twitchNotifier.check();
}

function setup() {
  const twitchNotifier = getTwitchNotifier();
  twitchNotifier.install();
}

function uninstall() {
  const twitchNotifier = getTwitchNotifier();
  twitchNotifier.uninstall();
}
3 - allow the required google permissions

Go to the project settings by clicking on the first image rectangle. After that, check the option to show the appsscript.json in our project, a file that manages the required google api access.

Go back to the project files, and replace the content present in the appsscript.json with the following code:

{
  "timeZone": "Etc/GMT",
  "dependencies": {},
  "oauthScopes": [
    "https://www.googleapis.com/auth/script.scriptapp",
    "https://www.googleapis.com/auth/script.external_request",
    "https://www.googleapis.com/auth/script.send_mail",
    "https://www.googleapis.com/auth/userinfo.email"
  ],
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8"
}
4 - setup the twitch-notifier to run automatically every x minutes

Just follow what the bellow image shows, which is to select the setup function and run it.
After, a popup will appear asking your permission, and you'll have to accept it.

Updating

To update your twitch-notifier instance and use the latest features, you just need to change the version number in the getTwitchNotifier function, as it is shown bellow:

function getTwitchNotifier(){
  const version = "1.0.0" // update here to use the latest features
  const content = UrlFetchApp.fetch(`https://cdn.jsdelivr.net/npm/twitch-notifier@${version}`).getContentText();
  eval(content)
  const twitchNotifier = new TwitchNotifier(CONFIGS)
  return twitchNotifier;
}

So if your instance is running at version "1.0.0" and the latest is "3.6.1", just replace those numbers in the version variable.

It is a good practice to go to the dist folder everytime you update your instance to check if your files in GAS have same properties as the new version; if they're not this may cause errors.

Uninstall

If you want to receive the daily emails, just go to the GAS respective project in the header dropdown menu select the uninstall function and then click on the Run button. By doing that, the GAS trigger responsable for running everyday the function will be deleted.

🔧 Development

Development setup

Instructions for development setup

To setup this project in your computer, run the following commands:
# Clone this repository
$ git clone https://github.com/lucasvtiradentes/twitch-notifier

# Go into the repository
$ cd twitch-notifier

# Install dependencies
$ npm install

If you want to contribute to the project, fork the project, make the necessary changes, and to test your work you can load your version in apps scripts with almost no effort do this: replace the content of the getTwitchNotifier function with the following code:

function getTwitchNotifier() {
  // const version = "1.1.4" // version
  // const content = getTwitchNotifierProduction(version)
  const content = getTwitchNotifierDevelopment('yourgithub/project-fork', 'develop');
  eval(content);
  const twitchNotifier = new TwitchNotifier(CONFIGS);
  return twitchNotifier;
}

function getTwitchNotifierProduction(version) {
  return UrlFetchApp.fetch(`https://cdn.jsdelivr.net/npm/twitch-notifier@${version}`).getContentText();
}

function getTwitchNotifierDevelopment(repository, branch) {
  const filePath = 'dist/TwitchNotifier.min.js';
  const final_link = `https://api.github.com/repos/${repository}/contents/${filePath}${branch ? `?ref=${branch}` : ''}`;
  const response = UrlFetchApp.fetch(final_link, { method: 'get', contentType: 'application/json' });
  const base64Content = JSON.parse(response.toString()).content;
  const decodedArr = Utilities.base64Decode(base64Content);
  const decodedAsString = Utilities.newBlob(decodedArr).getDataAsString();
  return decodedAsString;
}

This will allow you to select the twitch-notifier source place (github repository or npm package) and specify the intended version.

Used technologies

This project uses the following thechnologies:

Scope Subject Technologies
Project Main
Setup Code linting
Commit linting Gitmoji
Other

📚 About

Related

  • [x] esports-notifier: receive a daily email informing whenever at least one of your favorite esports teams has a match on the current date;
  • [x] gcal-sync: sync your github commits and ticktick tasks to your google calendar and track your work effortlessly;
  • [x] GAS docs: documentation related to triggering functions in Google Apps script.

License

This project is distributed under the terms of the MIT License Version 2.0. A complete version of the license is available in the LICENSE file in this repository. Any contribution made to this project will be licensed under the MIT License Version 2.0.

Feedback

If you have any questions or suggestions you are welcome to discuss it on github issues or, if you prefer, you can reach me in my social media provided bellow.

LinkedIn Gmail Discord Github

Made with ❤️ by Lucas Vieira

👉 See also all my projects

👉 See also all my articles

Package Sidebar

Install

npm i twitch-notifier

Weekly Downloads

1

Version

1.1.4

License

MIT

Unpacked Size

32.4 kB

Total Files

6

Last publish

Collaborators

  • lucasvtiradentes