bili

package
v0.0.0-...-ebf75f1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2022 License: AGPL-3.0, AGPL-3.0-or-later Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StartLive int = iota
	StopLive
	NewDanmu
)
View Source
const (
	GetUserInfoApi     = "https://api.bilibili.com/x/space/acc/info"
	GetLiveRoomInfoApi = "https://api.live.bilibili.com/room/v1/Room/room_init"

	DefaultTimeout = 5 * time.Second
)
View Source
const (
	BiliLiveMsgApi    = "wss://broadcastlv.chat.bilibili.com:2245/sub"
	HeartBeatInterval = 30 * time.Second
	MaxReconnection   = 10

	// ReadTimeout equals to HeartBeatInterval plus the time (10s) after which we consider a
	// read timeout since no heartbeat reply is received from server.
	ReadTimeout  = HeartBeatInterval + 10*time.Second
	WriteTimeout = 10 * time.Second
)
View Source
const (
	HeaderLen  = 16
	MinJsonLen = 4

	HeartBeatOp      uint32 = 2
	HeartBeatReplyOp uint32 = 3
	NotificationOp   uint32 = 5 // danmaku, broadcast, gift, etc.
	JoinOp           uint32 = 7
	JoinReplyOp      uint32 = 8

	JsonProcVer   uint16 = 0
	Uint32ProcVer uint16 = 1
	ZippedProcVer uint16 = 2

	NotificationDanmuCmd string = "DANMU_MSG"
)
View Source
const (
	// LiveRoom.LiveStatus
	NotStreaming = 0
	Streaming    = 1
)
View Source
const ModuleName = "bili"

Variables

This section is empty.

Functions

func NewBili

func NewBili() *bili

Types

type Config

type Config struct {
	Subscription         map[int64][]int64 `yaml:"subscription"`
	PollingInterval      uint              `yaml:"polling_interval"`
	DanmuForwardKeywords []string          `yaml:"danmu_forward_keywords"`
}

type DanmuEventData

type DanmuEventData struct {
	FromUserName     string
	Content          string
	StreamerUserInfo *UserInfo
}

type DecodedLiveMsg

type DecodedLiveMsg struct {
	Op   uint32
	Data interface{}
}

type Event

type Event struct {
	Type int
	Data interface{}
}

func NewEvent

func NewEvent(eventType int, eventData interface{}) *Event

type JoinRequestBody

type JoinRequestBody struct {
	ClientVer string `json:"clientver,omitempty"`
	Platform  string `json:"platform,omitempty"`
	ProtoVer  int    `json:"protover,omitempty"`
	RoomID    int64  `json:"roomid"`
	UID       int64  `json:"uid,omitempty"`
	Type      int    `json:"type,omitempty"`
}

type LiveMsgFetcher

type LiveMsgFetcher struct {
	UserInfo *UserInfo
	RoomID   int64
	// contains filtered or unexported fields
}

func NewLiveMsgFetcher

func NewLiveMsgFetcher(userInfo *UserInfo, eventChan chan *Event) *LiveMsgFetcher

func (*LiveMsgFetcher) Init

func (f *LiveMsgFetcher) Init() error

func (*LiveMsgFetcher) Run

func (f *LiveMsgFetcher) Run()

func (*LiveMsgFetcher) Stop

func (f *LiveMsgFetcher) Stop()

type LiveMsgPacket

type LiveMsgPacket struct {
	PacketLen uint32
	HeaderLen uint16
	ProcVer   uint16
	Op        uint32
	SeqID     uint32
	Body      []byte
}

func (*LiveMsgPacket) DecodeBodyAsNotificationRawJson

func (p *LiveMsgPacket) DecodeBodyAsNotificationRawJson() ([]string, error)

func (*LiveMsgPacket) DecodeBodyAsViewCnt

func (p *LiveMsgPacket) DecodeBodyAsViewCnt() (uint32, error)

func (*LiveMsgPacket) FromBytes

func (p *LiveMsgPacket) FromBytes(buffer []byte) error

func (*LiveMsgPacket) ToBytes

func (p *LiveMsgPacket) ToBytes() []byte

type LiveRoom

type LiveRoom struct {
	RoomStatus  int
	LiveStatus  int
	Url         string
	Title       string
	Cover       string
	Online      int
	RoomId      int
	RoundStatus int
}

type NotificationBody

type NotificationBody struct {
	Cmd  string
	Data json.RawMessage
	Info []json.RawMessage // for DANMU_MSG
}

func (*NotificationBody) ParseAsDanmu

func (b *NotificationBody) ParseAsDanmu() (uname, content string, err error)

type UserInfo

type UserInfo struct {
	Mid      int
	Name     string
	Sex      string
	Face     string
	Sign     string
	Rank     int
	Level    int
	TopPhoto string   `json:"top_photo"`
	LiveRoom LiveRoom `json:"live_room"`
}

func GetSubscriptionByGroupId

func GetSubscriptionByGroupId(gid int64) []UserInfo

func GetUserInfo

func GetUserInfo(bid int64) (*UserInfo, error)

type UserInfoRsp

type UserInfoRsp struct {
	Code    int
	Message string
	Ttl     int
	Data    UserInfo
}

Jump to

Keyboard shortcuts

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