Coder Social home page Coder Social logo

d0p3t / subnotifier Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 3.0 239 KB

🔔 Simple Sub, Gifted Sub, and Resub Notifier for Twitch Chat (also supports Cheers) 🎮

License: ISC License

JavaScript 100.00%
twitch twitchbot nodejs subscription bits resub alert

subnotifier's Introduction

SubNotifier (v1.0.9-1)

A Simple Sub and Resub Notifier for Twitch Chat

Version Discord license

Want to use SubNotifier but need a Host? Follow + Tweet me @d0p3t

Features

  • Chat alerts on subscriptions, subscription gifting and resubscriptions
  • Chat alerts on bits cheered including custom thresholds (i.e. 5000 bits)
  • Add your own custom alert messages for every channel and chat alert
  • Easy configuration with ability to enable/disable features
  • Multi channel support
  • Logfile to track subscriptions, gifted subscriptions, resubscriptions and bits chat alerts

Screenshot

Alert


Quickstart

  1. Install NodeJS
  2. Download and Extract Latest Release
  3. Open a terminal window and navigate to the directory
  4. Install dependencies npm install
  5. Edit config/config.js

(HIGHLY RECOMMENDED) Start the application in Production Mode

  • npm start

If you are a developer go into Development Mode (Requires Source Code)

  • Set process.env.NODE_ENV = "development"
  • Start npm dev

Configuration

A configuration file can be found in ./config/config.js. Configure all settings as you desire.

Connecting to Twitch Chat

To be able to connect to Twitch chat, you have to register an application and get an OAuth token with the correct scopes. You will also have to specify at least one channel. Please keep in mind that you need custom alerts for each channel if you have enableCustomMessages: true.

  • Register an application on Twitch here and copy the clientId
  • Login to the Twitch account to be used and get an OAuth token
clientId: 'xxxxxxxxxxxxxxxx',
username: 'd0p3tbot',
token: 'xxxxxxxxxxxxxxxxx',
channels: ['#d0p3t', '#summit1g', '#ninja'],

Configure Chat Messages

There are three types of chat notifiers, we call them Chat Alerts.

  • subscriptions
  • resubscriptions
  • bits

You can use as many custom chat alerts as you wish. If you activate custom chat alerts, you MUST set at least 1 custom chat alert per type and channel. If custom alerts are not enabled, it will default to predefined messages.

Within the chat alerts you can use various variables. Below is a list of available variables with a description and where you can use them.

Variable Description Uses
{{username}} Displays the username of the (re)subscriber/cheerer subscriptions, resubscriptions, bits, bitsThresholds
{{months}} Number of months resubscribed resubscriptions
{{years}} Displays # years if 1 year or more (as [ X year(s) and X month(s) ]) resubscriptions
{{bits}} Amount of bits cheered bits
{{message}} Message sent with event subscriptions, resubscriptions, bits, bitsThresholds
{{recipient}} Recipient of a gifted subscription giftsubscriptions
'#d0p3t': {
  subscriptions: {
    custom1: 'PogChamp SUB Thank you for subscribing {{username}}',
    custom2: 'CoolStoryBob SUB Thank you for subscribing {{username}}',
    custom3: 'DansGame SUB Thank you for subscribing {{username}}' },
  giftsubscriptions: {
    custom1: 'PogChamp SUB Thank you for gifting {{recipient}} a subscription, {{username}}',
    custom2: 'CoolStoryBob SUB Thank you for gifting {{recipient}} a subscription, {{username}}',
    custom3: 'DansGame SUB Thank you for gifting {{recipient}} a subscription, {{username}}' },
  resubscriptions: {
    custom1: 'PogChamp RESUB Thank you {{username}} for resubscribing for {{months}} months! {{years}} {{message}}',
    custom2: 'WutFace RESUB Thank you {{username}} for resubscribing for {{months}} months! {{years}}',
    custom3: '<3 RESUB Thank you {{username}} for resubscribing for {{months}} months! {{years}}' },
  bits: {
    custom1: 'Wowzers, {{username}} cheered {{bits}} BITS!',
    custom2: 'Oh so kind, {{username}} with the {{bits}} BITS!',
    custom3: 'LUL we got a happy cheerer over here ({{username}}: {{bits}} bits)!' },
    bitsThresholds: {
      1000: '1000 BITS from {{username}} with the message {{message}}!',
      5000: '{{username}} just sent 5000 BITS our way! What an amazing person',
      10000: 'This is insane, 10000 BITS from {{username}}!',
      25000: '25000 BITS! I don\'t know what to say, {{username}}',
      50000: '50000 BITS from {{username}} and they said: {{message}}!',
      75000: '75000 BITS cheers by the gracious {{username}}!',
      100000: 'What does heaven feel like? Right, 100000 BITS from {{username}}!',
    },
},

Enable/Disable Features

There also various settings that you can enable (true) or disable (false).

Setting Description Default
enableSecureMode Connects to Twitch chat with SSL (443) true
enableMeMode Chat alerts start with /me true
enableSubAlerts Enables subscription chat notifications true
enableGiftSubAlerts Enabled gift subscription chat notifications true
enableResubAlerts Enables resubscriptions chat notifications true
enableBitAlerts Enables bits chat notifcations false
enableCustomMessages Enables custom chat alerts true

If you've configured everything correctly, you will now be able to start SubNotifier and upon a successful connection will see CONNECTED: Waiting for events.... If you are still having issues, please refer to the sample configuration file first and then open an issue (see below).


Issues

If you have any issues or questions, open an issue or tweet me @d0p3t.

For configuration file problems, please first check whether your syntax is correct and you aren't missing any commas or brackets. SubNotifier has a failsafe against missing custom messages, but will not revert to the defaults if enableCustomMessages: true and there is a problem with the configuration file.


Thank You!

Thank you to the creators and maintainers of twitch-js for providing easy access to TwitchNotify events and Twitch Chat.

Also a great thank you to Ikatzuki and dinu for discussing and coming up with new features. Without you SubNotifier wouldn't have improved as it did now.

bitmoji


Changelog

v1.0.9-1 (04 July 2019)

  • Upgraded dependencies

v1.0.9 (05 March 2019)

  • Fixes issue #38

v1.0.8 (04 March 2019)

  • Reverted back to tmi.js

v1.0.7 (01 February 2019)

  • Upgraded dependencies
  • Modified debug mode. Enable now via process.env.NODE_ENV = "development"
  • Fixed logger for winston v3
  • Changed to daily logging w/ 14 days retention
  • Automatic Deployment
  • Updated Quickstart

v1.0.6 (04 September 2018)

  • Added bitThresholds allowing for custom message for a custom bit amount. Thanks to 6mas for the suggestion in [i15] . If there are bugs, please let me know as I'm unable to test this.
  • Upgraded twitch-js to v1.2.14

v1.0.5 (10 July 2018)

  • Added message variable support to resubscriptions
  • Added reconnecting and reconnected messages for clarity
  • Fixed linting errors (1 remaining due to twitch-js constructor)

v1.0.4 (20 June 2018)

  • Fixed security vulnerabilities
  • Upgraded package.json
  • Fix gift subscription messages not populating correctly

v1.0.3 (16 March 2018)

  • Added gift subscription alerts
  • Switched to twitch-js, a more up-to-date version of tmi.js

v1.0.2 (18 September 2017)

  • Fixed custom message counter
  • Added check whether there is more than 1 custom message in a alert type
  • Fixed README.md and package.json versioning

v1.0.1 (17 September 2017)

  • Fixed - Better handling of # of custom messages
  • Added prettyPrint: true to Logger.js for better console output
  • Added more debug messages
  • Added the {{message}} variable

v1.0.0 (13 September 2017)

  • Complete rewrite of codebase (ECMASCRIPT 6)
  • Now supports bits
  • Separation of custom messages
  • Multi channel support
  • New configuration file

v0.2.0

  • Got rid of message in default subscription notify due to TwitchNotify changes
  • Fixed message sometimes displaying as null during resub
  • Added logfile creation with information about sub/resub
  • Updated tmi.js to v1.2.1
  • Added support for newest TwitchNotify events
  • Added separate announcement for Prime subscriptions
  • Disabled debug by default

v0.1.0

  • Initial release

subnotifier's People

Contributors

d0p3t avatar dependabot-support avatar dependabot[bot] avatar mja00 avatar remcotroost avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

subnotifier's Issues

At the end, it says (null)

Hello,

I got a problem. This script works fine. But at the end of every Sub/resub message, it says (null). Example:

Lyvondria has just subscribed!(null)

Am I doing something wrong? I only changed the resub message.

Better handling of custom messages

Goal: To increase the usability, consistency, simplicity and efficiency

There is some confusion with respect to handling customization of messages to the users needs. Therefore, a solution needs to be found to address this issue.

There are a couple of ways to improve the design of the script.

  1. Improve the README.md and/or write Wiki entries
  2. Separate the custom messages from app.js

It's always helpful to improve the README.md to answer any frequent questions, but to continue developing the script and allow for even more customization to the script, I will be separating the custom messages from the main file. This will allow for new features such as

  • Better multiple channel support
  • Multiple sub alert messages per channel.

It will also allow us to look further into other open issues, as well as explore new features that users may want. We do want to keep in mind that the core goal of this app is to provide Subscription and Resubscription alerts in chat. I will not be adding feature that have no benefit to those core features.

I will be outlining my ideas for these changes below. If any of you have any suggestions or improvements, I'm happy to hear it.

bitmoji

Gifted subs show name as 0

Hi,

As per title, when gifting a sub now (On latest version from #38 v1.0.9) gifting a sub now shows like:

Thanks for gifting a sub to 0 subgifter

I'm not sure if this is related to the fix per #38 regarding resubs showing as 0 months.

Resub crashes

after some time even when nothing happens it crashes.

`C:\Users\koeseb\Desktop\SubNotifier-master\src\lib\TwitchBot.js:202
var resubAlertMessages = _config.Config.customMessages[channel].resubscriptions;
^

TypeError: Cannot read property 'resubscriptions' of undefined
at client. (C:/Users/koeseb/Desktop/SubNotifier-master/src/lib/TwitchBot.js:158:36)
at client.EventEmitter.emit (C:\Users\koeseb\Desktop\SubNotifier-master\node_modules\tmi.js\lib\events.js:101:25)
at client.EventEmitter.emits (C:\Users\koeseb\Desktop\SubNotifier-master\node_modules\tmi.js\lib\events.js:64:19)
at client.handleMessage (C:\Users\koeseb\Desktop\SubNotifier-master\node_modules\tmi.js\lib\client.js:578:30)
at parts.forEach (C:\Users\koeseb\Desktop\SubNotifier-master\node_modules\tmi.js\lib\client.js:959:36)
at Array.forEach ()
at client._onMessage (C:\Users\koeseb\Desktop\SubNotifier-master\node_modules\tmi.js\lib\client.js:958:11)
at WebSocket.onMessage (C:\Users\koeseb\Desktop\SubNotifier-master\node_modules\ws\lib\WebSocket.js:418:14)
at emitTwo (events.js:125:13)
at WebSocket.emit (events.js:213:7)
[nodemon] app crashed - waiting for file changes before starting...`

Sub display

So I just notice that only the resubs shows in the log and also it shows all custom messagas.

Is it possible to show first sub and also only the message which was choosen?
Kinda hard to read everything

pic: http://prntscr.com/glq32q

its crashes for me , not sure if i done something wrong

[email protected] start C:\Users\james\Desktop\SubNotifier-master
nodemon src/index.js --exec babel-node --presets es2015,stage-2

[nodemon] 1.17.5
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting babel-node src/index.js --presets es2015,stage-2
2:14:28 PM - info: STARTING SubNotifier...
C:\Users\james\Desktop\SubNotifier-master\node_modules\private\private.js:72
for (var names = originalGetOPNs(object),
^

TypeError: Cannot convert undefined or null to object
at getOwnPropertyNames ()
at Function.getOwnPropertyNames (C:\Users\james\Desktop\SubNotifier-master\node_modules\private\private.js:72:20)
at TwitchBot.Start (C:/Users/james/Desktop/SubNotifier-master/src/lib/TwitchBot.js:82:32)
at Object. (C:/Users/james/Desktop/SubNotifier-master/src/index.js:26:5)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at loader (C:\Users\james\Desktop\SubNotifier-master\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (C:\Users\james\Desktop\SubNotifier-master\node_modules\babel-register\lib\node.js:154:7)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
[nodemon] app crashed - waiting for file changes before starting...

Bug: All resubs show incorrect number

Hi,

I'm using the latest version, but on all resubs we get 0 months despite how long it is. Is there a fix for this?

The log shows like this:

{"message":"RESUBALERT was sent to channel: #x for username: y [ 0 months ]","level":"info"}

Own Channel join

Soo I got Affiliated the other day and i wanted to run the script also on my own channel koesebTV but everytime i try to start the script with joining my/his own channel it crashes.

soo the scrip is running on my own acc koesebTV and should join my channel #koesebTV
but somehow this doesn't work?

Error Message:

`15:06:08 - info: STARTING SubNotifier...
C:\Users\KönigS\Desktop\SubNotifier\node_modules\private\private.js:72
for (var names = originalGetOPNs(object),
^

TypeError: Cannot convert undefined or null to object
at Function.getOwnPropertyNames (C:\Users\KönigS\Desktop\SubNotifier\node_mo
dules\private\private.js:72:20)
at TwitchBot.Start (C:\Users\KönigS\Desktop\SubNotifier\src\lib/TwitchBot.js
:82:32)
at Object. (C:\Users\KönigS\Desktop\SubNotifier\src/index.js:26:5
)
at Module._compile (module.js:570:32)
at loader (C:\Users\KönigS\Desktop\SubNotifier\node_modules\babel-register\l
ib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (C:\Users\KönigS
Desktop\SubNotifier\node_modules\babel-register\lib\node.js:154:7)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Function.Module.runMain (module.js:604:10)`

Adding log file if someone subscribe

Would be cool if when someone subscribed, it will create a log folder or a log file where some informations are stored like timstamps when he subscribed e.g

New Features Roadmap

I would like to extend features on SubNotifier without changing the core functionality:

Simple Subscription Notifier for Twitch Chat

I am more than willing to expand this project. The only thing I will never support is anything outside of Twitch chat. For that, another project can be started.

Post your requests in a comment below with the following format:

Title:
Description:
Reason:
Expected Behaviour:

Example:

Title: Add gift subscription support
Description: Ability to notify in chat whenever someone gifts a subscription
Reason: Gifting subs is a new feature on Twitch that is used a lot. 
It would be nice to thank those that are gifting subs and also notify those that 
have been granted a sub.
Expected Behaviour: Viewer gifts sub to another viewer. 
The bot sends a chat message to notify the chat similar to subscriptions 
and resubscriptions

bitmoji

Change `npm start`

npm start will not work if one isn't using the release version.

Should change this. Perhaps create a separate startup script for the release. The updated version created confusion with users.

// start.cmd/sh
node index.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.