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

kick_live_ws

v1.4.7

Published

just a small module to connect to Kick Websocket and read data

Downloads

168

Readme

Kick Live Websocket

Features

  • Bypass cloudflare API protection via puppeteer to get chatroomids.
  • also runs puppeteer in Docker, see Dockerfile to install.
  • Handle connection timeouts and errors.
  • Automatic reconnect on error and timeout.

Install

npm install --save kick_ws_live

Usage

Simple usage

import { WebSocketConnection, MessageEvents, TChatMessageEvent } from "kick_live_ws";

const kickConnection = new WebSocketConnection({name:'xQc'});
kickConnection.connect();

kickConnection.on(MessageEvents.CHATMESSAGE,(messagedata: TChatMessageEvent) => {
    console.log('message',messagedata)
})

Params and options

To create a new WebSocketConnection object the following parameters are required.

WebSocketConnection({name, chatroom_id, channel_id})

| Param Name | Required | Description | | ---------- | -------- | ----------- | | name | Yes | The unique username of the broadcaster. You can find this name in the URL.Example: https://kick.com/xQc => xQc | | chatroom_id | No(Both Yes) | The unique chatroom_id stays the same for every stream. Chat is also up and recieving messages when the streamer is offline. Fetch https://kick.com/api/v2/channels/xQc or CHANNEL + xQc => data.chatroom.id | | channel_id | No(Both Yes)| The unique chatroom_id stays the same for every stream. Chat is also up and recieving messages when the streamer is offline. Fetch https://kick.com/api/v2/channels/xQc or CHANNEL + xQc => data.chatroom.channel_id |

You can bypass the puppeteer getting Ids by setting chatroom_id and channel_id. Both have to be set, only 1 will not work.

Events

A WebSocketConnection object has the following events which can be handled via .on(eventName, eventHandler).

Message Events:

  • CHAT
  • FOLLOWERUPDATE //T missing
  • BAN
  • UNBAN
  • MESSEAGEDELETE
  • STREAMSTART
  • STOPSTREAM
  • SUBSCRIPTIONEVENT
  • CHANNELSUBSCRIPTION
  • GIFTEDSUBSCRIPTION
  • LUCKYUSERSWHOGOTGIFTSUBSCRIPTIONS
  • GIFTSLEADERBOARDUPDATED
  • CHATROOMUPDATED
  • CHANNELUPDATED
  • STREAMHOST
  • PINNEDMESSAGECREATED
  • PINNEDMESSAGEDELETED //T missing
  • ERROR
  • CONNECTED
  • DISCONNECT
  • EVERYTHING
  • UNTRACKED

Message Events

CHAT

Triggered everytime a new chat message arrives.

kickConnection.on(MessageEvents.CHATMESSAGE,(messagedata: TChatMessageEvent) => {
    console.log('message',messagedata.content)
  });

BAN

Triggered everytime a user gets banned.


  kickConnection.on(MessageEvents.BAN,(banevent:TBanEvent)=>{

    console.log(`User ${banevent.user} banned by ${banevent.banned_by}`)
  })

DISCONNECT

Triggered everytime the websocket disconnects.

You can use this to reconnect. kickConnection will handle the reconnect and add listeners again.

  kickConnection.on('disconnect', () => {
    console.log('restart after disconnect')

    setTimeout(() => {
    kickConnection.connect();
  }, 1000); // 1000 milliseconds = 1 seconds
})

Every Message event has its own type in this shema. T{STREAMSTART}Event The MessageEvents and all types can be imported

import { WebSocketConnection, MessageEvents, TChatMessageEvent, TBanEvent } from "kick_live_ws";

TFollowEvent and TPinnedMessageDeletedEvent are missing. Will be updated soon.

TODO - Coming Later

  • Adding Jest tests.
  • Ability to send messages
  • If new messages come up I will add them. You can use the UNTRACKED to look if something is not tracked and message me.

Contributing

Your improvements are welcome! Feel free to open an issue or pull request.

Discord: .wulfen