Documentation ¶
Overview ¶
generated by buildtools/browser-get-err-code.js. DO NOT EDIT
Index ¶
Constants ¶
View Source
const ( HeaderBiliCommPrefix = "X-Bili-" HeaderBiliContentMD5 = HeaderBiliCommPrefix + "Content-MD5" HeaderBiliTimestamp = HeaderBiliCommPrefix + "Timestamp" HeaderBiliSignatureMethod = HeaderBiliCommPrefix + "Signature-Method" HeaderBiliSignatureNonce = HeaderBiliCommPrefix + "Signature-Nonce" HeaderBiliAccessKeyId = HeaderBiliCommPrefix + "AccessKeyId" HeaderBiliSignatureVersion = HeaderBiliCommPrefix + "Signature-Version" )
View Source
const (
ApiHostRelease = "https://live-open.biliapi.com"
)
View Source
const (
// CmdLiveOpenPlatformDm 在 Websocket 协议中接收到的消息类型:开放平台弹幕,目前只实现了这个类型
CmdLiveOpenPlatformDm = "LIVE_OPEN_PLATFORM_DM"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApiTransport ¶
type ApiTransport struct { AppKey string AppSecret string Transport http.RoundTripper }
ApiTransport implements bili open api http transport with auto signature
these request headers will be generated in RoundTrip method: - X-Bili-Timestamp - X-Bili-Signature-Method - X-Bili-Content-MD5 - Authorization
type CommonError ¶
type CommonError struct { Code CommonErrorCode Message string RequestID string }
CommonError 公共错误
func (CommonError) Error ¶
func (e CommonError) Error() string
type CommonErrorCode ¶
type CommonErrorCode int
CommonErrorCode 公共错误码
func (CommonErrorCode) Desc ¶
func (c CommonErrorCode) Desc() string
func (CommonErrorCode) String ¶
func (c CommonErrorCode) String() string
type CommonResponse ¶
type CommonResponse[T any] struct { Code CommonErrorCode `json:"code"` Message string `json:"message"` RequestID string `json:"request_id"` Data T `json:"data"` }
func (CommonResponse[T]) Err ¶
func (r CommonResponse[T]) Err() error
func (CommonResponse[T]) String ¶
func (r CommonResponse[T]) String() string
type Danmaku ¶
type Danmaku struct { // Timestamp 时间戳 Timestamp int `json:"timestamp"` // RoomID 直播间 ID RoomID int `json:"room_id"` // UID 用户 UID UID int `json:"uid"` // Username 用户名 Username string `json:"uname"` // UserFace 用户头像 UserFace string `json:"uface"` // Admin 是否房管 Admin int `json:"admin"` // Vip 是否月费会员 Vip int `json:"vip"` // SVip 是否年费会员 SVip int `json:"svip"` // MsgType 是否礼物弹幕(节奏风暴) MsgType int `json:"msg_type"` // DMType 弹幕类型,枚举值参考 DanmakuType 类型常量 DMType DanmakuType `json:"dm_type"` // Message 弹幕内容 Message string `json:"msg"` // MessageID 弹幕 ID,猜测用于去重 MessageID string `json:"msg_id"` // EmojiImgUrl 表情地址 EmojiImgUrl string `json:"emoji_img_url"` // FansMedalLevel 粉丝牌等级 FansMedalLevel int `json:"fans_medal_level"` // FansMedalName 粉丝牌名称 FansMedalName string `json:"fans_medal_name"` // FansMedalWearingStatus 粉丝牌是否穿戴 FansMedalWearingStatus bool `json:"fans_medal_wearing_status"` }
Danmaku 弹幕信息
type DanmakuType ¶
type DanmakuType int
DanmakuType 弹幕类型
const ( // DanmakuTypeText 文字 DanmakuTypeText DanmakuType = 0 // DanmakuTypeSticker 表情 DanmakuTypeSticker DanmakuType = 1 // DanmakuTypeVoice 语音 DanmakuTypeVoice DanmakuType = 2 )
type LiveClient ¶
type LiveClient struct { ApiHost string AppKey string AppSecret string ProjectID int64 OnDanmaku func(Danmaku) OnClose func(error) // contains filtered or unexported fields }
LiveClient 直播 API 客户端实现
协议根据官方开发文档实现:https://open-live.bilibili.com/document/74eec767-e594-7ddd-6aba-257e8317c05d
func (*LiveClient) Connect ¶
func (c *LiveClient) Connect(ctx context.Context, liveCode string) error
Connect 建立直播间连接
需要传入主播自己的身份码,而不是直播间 ID,遂不支持监听其他人的直播间
func (*LiveClient) Disconnect ¶
func (c *LiveClient) Disconnect(ctx context.Context) error
Disconnect 断开连接
Click to show internal directories.
Click to hide internal directories.