npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chat-parser

v6.1.1

Published

Parse chat from streaming platforms into a a single format.

Downloads

5

Readme

Chat Parser

Build Status Coverage Status

An issue we're running to at StreamJar is everybody handles their chats completely different. Which when you want to support lots of different services in the same way, it can cause less than ideal situations.

Quick Note.

Smashcast has some interesting quirks.. in order to parse user ids, you must set a function sc.setUserIdentifier() which takes a function from username to id.

Installation

To install, simply install it via NPM.

npm install --save chat-parser

Getting Started

Getting started is simple. Require the module, create a new instance.. and parse.

import { MixerParser } from 'chat-parser';

const parser = new MixerParser({ developers: ['1'], bots: ['2'] });

parser.parse({
	// raw message
}, 'bot-username'),them(msg => { /* */ });

Expected object

This module expects slightly different things depending on the platform (look in /examples for example objects).

  • For Mixer, pass the data portion of the ChatMessage packet.
  • For Twitch, pass the PRIVMSG as a string.
  • For Smashcast, pass the "params" part of the chat packet.

Parsed Message

The parsed message contains basic user information and the message itself.

{
	"user": {
		"userId": 373,
		"username": "Luke",
		"roles": [ Role{ role: 'Owner', level: 50 }],
		"primaryRole": Role{ role: 'Owner', level: 50 },
	},
	'metadata": {
		"command": false,
		"commandName": "give",
		"description": '@Luke 100',
	},
	"message": [
		{
			"type": 'text',
			"text": "hello",
		}
	]
}

Types of message

Currently there are 4 types of message. Text, link, mention and emoticon.

Text:

{
	"type": "text",
	"text": "hello"
}

Link:

{
	"type": "link",
	"text": "https://google.com",
	identifier: "https://google.com",
}

Mention:

{
	"type": "mention",
	"text": "@StreamJar",
	identifier: "StreamJar",
}

Emoticon

Emoticons are handled differently between Twitch/Smashcast and Mixer, we call this 'sprite' and 'direct'.

Sprite:
{
	"type":"emoticon",
	"text":":D",
	"identifier":{
	"type":"sprite",
	"pack":"https://mixer.com/_latest/emoticons/default.png",
	"coords":{
		"x":72,
		"y":0,
		"width":24,
		"height":24
	}
}
Direct:
{
	"type":"emoticon",
	"text":":D",
	"identifier":{
	"type":"direct",
	"url":"https://smashcast.tv/static/img/chat/default/lol1.png"
}

Discord

Discord is slightly special since we have no clue how you're getting the data. We assume all other platforms are the raw wire format, but we expect you to provide an implementation of IDiscordRawPacket.