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.
logger.js
requires Node.js >=10.0.0 and tmi.js. After configuration, logger.js can be launched by running node logger.js
.
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",
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
.
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.
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).
If there are any encountered issues, log it on the issues page along with an error message and used configuration.