kickchatwrapper

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 6 Imported by: 0

README

Introduction

kickchatwrapper is a Go package that provides a wrapper for interacting with the Kick websocket. It allows you to subscribe to chat channels and receive chat messages.

Installation

go get github.com/your-username/kickchatwrapper

Usage

client, err := kickchatwrapper.NewClient()
if err != nil {
    // handle error
}

client.JoinChannelByID(231221)

messageChan := client.ListenForMessages()

go func() {
  for message := range messageChan {
    fmt.Printf("Received chat message: %+v\n", message)
  }
}()

// To close connection you can call
// client.Close()

Notes

Right now it is only possible to join chat room using user ID because to be able to join it by username we would need to call their API but its protected by CloudFlare.

Documentation

Index

Constants

View Source
const (
	APIURL = "wss://ws-us2.pusher.com/app/eb1d5f283081a78b932c?protocol=7&client=js&version=7.6.0&flash=false"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Badge

type Badge struct {
	Type  string `json:"type"`
	Text  string `json:"text"`
	Count int    `json:"count"`
}

type ChatMessage

type ChatMessage struct {
	ID         string    `json:"id"`
	ChatroomID int       `json:"chatroom_id"`
	Content    string    `json:"content"`
	Type       string    `json:"type"`
	CreatedAt  time.Time `json:"created_at"`
	Sender     Sender    `json:"sender"`
}

type ChatMessageEvent

type ChatMessageEvent struct {
	Event   string `json:"event"`
	Data    string `json:"data"`
	Channel string `json:"channel"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient() (*Client, error)

func (*Client) Close

func (client *Client) Close()

func (*Client) JoinChannelByID

func (client *Client) JoinChannelByID(id int) error

func (*Client) ListenForMessages

func (client *Client) ListenForMessages() <-chan ChatMessage

func (*Client) SetDebug added in v0.0.3

func (client *Client) SetDebug(debug bool)

type Identity

type Identity struct {
	Color  string  `json:"color"`
	Badges []Badge `json:"badges"`
}

type PusherSubscribe

type PusherSubscribe struct {
	Event string `json:"event"`
	Data  struct {
		Channel string `json:"channel"`
		Auth    string `json:"auth"`
	} `json:"data"`
}

type Sender

type Sender struct {
	ID       int      `json:"id"`
	Username string   `json:"username"`
	Slug     string   `json:"slug"`
	Identity Identity `json:"identity"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL