Socket
Socket
Sign inDemoInstall

kick_live_ws

Package Overview
Dependencies
161
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    kick_live_ws

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


Version published
Weekly downloads
5
decreased by-58.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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 NameRequiredDescription
nameYesThe unique username of the broadcaster. You can find this name in the URL.
Example: https://kick.com/xQc => xQc
chatroom_idNo(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_idNo(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

Keywords

FAQs

Last updated on 15 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc