1.4.7 • Published 3 months ago

kick_live_ws v1.4.7

Weekly downloads
-
License
ISC
Repository
-
Last release
3 months ago

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

1.4.6

3 months ago

1.4.5

3 months ago

1.4.4

3 months ago

1.4.3

3 months ago

1.4.2

3 months ago

1.4.7

3 months ago

1.4.1

4 months ago

1.3.10

4 months ago

1.4.0

7 months ago

1.3.9

7 months ago

1.3.8

7 months ago

1.3.7

8 months ago

1.3.6

9 months ago

1.3.5

9 months ago

1.3.4

9 months ago

1.3.3

9 months ago

1.3.2

9 months ago

1.3.1

9 months ago

1.3.0

9 months ago

1.2.7

9 months ago

1.2.6

9 months ago

1.2.5

9 months ago

1.2.4

9 months ago

1.2.3

9 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago

1.1.13

10 months ago

1.1.12

10 months ago

1.1.11

10 months ago

1.1.10

10 months ago

1.1.9

10 months ago

1.1.8

10 months ago

1.1.7

10 months ago

1.1.6

10 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago