client

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCmd

func ParseCmd(d []byte) string

ParseCmd 获取 JSON 报文的 CMD

Types

type Client

type Client struct {
	RoomID int
	Uid    int
	Buvid  string
	Cookie string

	Config *Config
	// contains filtered or unexported fields
}

func NewClient

func NewClient(roomID int, config *Config) *Client

NewClient 创建一个新的弹幕 client

func (*Client) Handle

func (c *Client) Handle(p packet.Packet)

Handle 处理一个包

func (*Client) OnDanmaku

func (c *Client) OnDanmaku(f func(*message.Danmaku))

OnDanmaku 添加 弹幕事件 的处理器

func (*Client) OnGift

func (c *Client) OnGift(f func(gift *message.Gift))

OnGift 添加 礼物事件 的处理器

func (*Client) OnGuardBuy

func (c *Client) OnGuardBuy(f func(*message.GuardBuy))

OnGuardBuy 添加 开通大航海事件 的处理器

func (*Client) OnLive

func (c *Client) OnLive(f func(*message.Live))

OnLive 添加 开播事件 的处理器

func (*Client) OnPacket

func (c *Client) OnPacket(f func(*packet.Packet))

func (*Client) OnRawPackage added in v0.0.5

func (c *Client) OnRawPackage(f func(*[]byte))

func (*Client) OnSuperChat

func (c *Client) OnSuperChat(f func(*message.SuperChat))

OnSuperChat 添加 醒目留言事件 的处理器

func (*Client) OnUserToast

func (c *Client) OnUserToast(f func(*message.UserToast))

OnUserToast 添加 UserToast 的处理器

func (*Client) RegisterCustomEventHandler

func (c *Client) RegisterCustomEventHandler(cmd string, handler func(s string))

RegisterCustomEventHandler 注册 自定义事件 的处理器

需要提供事件名,可参考 knownCMD

func (*Client) SetCookie

func (c *Client) SetCookie(cookie string)

func (*Client) SetHost

func (c *Client) SetHost(host string)

func (*Client) Start

func (c *Client) Start() error

Start 启动弹幕 Client 初始化并连接 ws、发送心跳包

func (*Client) Stop

func (c *Client) Stop()

Stop 停止弹幕 Client

func (*Client) UseDefaultHost

func (c *Client) UseDefaultHost()

UseDefaultHost 使用默认 host broadcastlv.chat.bilibili.com

type Config

type Config struct {
	UserAgent string
	Logger    logrus.FieldLogger
}

Jump to

Keyboard shortcuts

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