Skip to content

Chanka0/twitch-chat-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

This is a simple scalable Twitch IRC logger. It utilizes tmi.js to listen to an IRC channel with full configuration in config.json, including regex filtering and file streaming capable of handling multiple 50-100k viewer streams.

Installation

logger.js requires Node.js >=10.0.0 and tmi.js. After configuration, logger.js can be launched by running node logger.js.

Configuration

Example configuration is as follows.

{
    "identity": {},
    "options": {
        "debug": "true"
    },
    "channels": ["channel"],
    "filterRegex": "^[a-zA-Z]{3,7}$",
    "filterFlags": "",
    "prefix": "prefix ",
    "suffix": " suffix"
}

tmi.js client options can be found here and added/edited in the config.json. Regex expressions can be added by pruning the forward slashes from the start and ending, and adding flags to the filterFlags field. For more reference on use, check the Javascript RegExp documentation.

Normal regex: /^[a-zA-Z]{3,7}$/g
Formatted regex: 
"filterRegex": "^[a-zA-Z]{3,7}$",
"filterFlags": "g",

Technical Explanation

This script is rather simple. From config.json it grabs all listed channels and creates fs.writeStreams and IRC connections to each. The files are created in the same directory as logger.js.

Why writeStream instead of a normal fs.writeFile connection?

fs.writeStream has the benefit of queueing write operations rather than multiple individual writes. On small streams with low message counts this change wouldn't be noticable, but on streams with +10k viewership it would quickly lag behind.

Tested limits

The largest workload placed on this script was 4 channels (xcqow, forsen, moonmoon, jerma985). It ran in the background for 2 days, logging 500k messages total. No memory leaks or performance issues were encountered, nor any interference with normal PC operation (including CPU/GPU intensive workloads).

Issues

If there are any encountered issues, log it on the issues page along with an error message and used configuration.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published