Documentation
¶
Index ¶
- Constants
- Variables
- func GetDMDeviceID() (string, error)
- func SendMsg(msg string, room *RoomInfo, sess_data, jct string) error
- func SetLogWriter(out io.Writer)
- type Client
- type ClientConf
- type CmdHandler
- type DanmakuHost
- type DanmakuInfo
- type ErrHandler
- type NullWriter
- type OpHandler
- type RawMessage
- type RoomInfo
- type SendDirectMsgRsp
- func SendDirectMsg(sender, reciever int64, content, dev_id, sess_data, jct string) (*SendDirectMsgRsp, error)
- func SendDirectMsgPicture(sender, reciever int64, pic *UploadedPic, ...) (*SendDirectMsgRsp, error)
- func SendDirectMsgRaw(sender, reciever int64, content []byte, ...) (*SendDirectMsgRsp, error)
- type ServerDisconnectHandler
- type UploadedPic
Constants ¶
View Source
const ( CMD_ANCHOR_LOT_AWARD = "ANCHOR_LOT_AWARD" CMD_ANCHOR_LOT_CHECKSTATUS = "ANCHOR_LOT_CHECKSTATUS" CMD_ANCHOR_LOT_END = "ANCHOR_LOT_END" CMD_ANCHOR_LOT_START = "ANCHOR_LOT_START" CMD_COMBO_SEND = "COMBO_SEND" CMD_DANMU_MSG = "DANMU_MSG" CMD_ENTRY_EFFECT = "ENTRY_EFFECT" CMD_GUARD_BUY = "GUARD_BUY" CMD_HOT_RANK_CHANGED = "HOT_RANK_CHANGED" CMD_HOT_RANK_SETTLEMENT = "HOT_RANK_SETTLEMENT" CMD_INTERACT_WORD = "INTERACT_WORD" CMD_LIVE_INTERACTIVE_GAME = "LIVE_INTERACTIVE_GAME" CMD_ONLINE_RANK_COUNT = "ONLINE_RANK_COUNT" CMD_ROOM_REAL_TIME_MESSAGE_UPDATE = "ROOM_REAL_TIME_MESSAGE_UPDATE" CMD_SEND_GIFT = "SEND_GIFT" CMD_STOP_LIVE_ROOM_LIST = "STOP_LIVE_ROOM_LIST" CMD_SUPER_CHAT_MESSAGE = "SUPER_CHAT_MESSAGE" CMD_SUPER_CHAT_MESSAGE_DELETE = "SUPER_CHAT_MESSAGE_DELETE" CMD_SUPER_CHAT_MESSAGE_JPN = "SUPER_CHAT_MESSAGE_JPN" CMD_USER_TOAST_MSG = "USER_TOAST_MSG" CMD_LIVE = "LIVE" CMD_PREPARING = "PREPARING" )
View Source
const ( OP_HANDSHAKE = 0 OP_HANDSHAKE_REPLY = 1 OP_HEARTBEAT = 2 OP_HEARTBEAT_REPLY = 3 OP_SEND_MSG = 4 OP_SEND_MSG_REPLY = 5 OP_AUTH = 7 OP_AUTH_REPLY = 8 VER_NORMAL = 1 VER_DEFLATE = 2 VER_BROTLI = 3 HEADER_LENGTH = 16 ROOM_INFO_API string = `https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom` DANMAKU_INFO_API string = `https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo` SEND_MSG_API string = `https://api.live.bilibili.com/msg/send` SEND_DM_API string = `https://api.vc.bilibili.com/web_im/v1/web_im/send_msg` UPLOAD_PIC_API string = `https://api.bilibili.com/x/dynamic/feed/draw/upload_bfs` USER_AGENT string = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36` )
Variables ¶
View Source
var ErrClosed error = errors.New("underlyinh websocket closed")
View Source
var ErrHeartbeatTimeout error = errors.New("heartbeat timeout")
View Source
var ErrMsgIncomplete error = errors.New("msg not complete")
View Source
var ErrMsgUnknownProtocolVersion error = errors.New("msg has an unknown version")
View Source
var ErrNotConnected error = errors.New("not connected")
View Source
var HEARTBEAT_MSG []byte = []byte(`[object Object]`)
Functions ¶
func GetDMDeviceID ¶ added in v1.0.4
func SetLogWriter ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) SendMsg ¶
func (c *Client) SendMsg(msg *RawMessage) error
type ClientConf ¶
type ClientConf struct { OpHandlerMap map[uint32][]OpHandler CmdHandlerMap map[string][]CmdHandler OnNetError ErrHandler OnServerDisconnect ServerDisconnectHandler HeartbeatInterval time.Duration HeartbeatTimeout time.Duration HandshakeTimeout time.Duration }
func (*ClientConf) AddCmdHandler ¶
func (c *ClientConf) AddCmdHandler(cmd string, cb CmdHandler) *ClientConf
func (*ClientConf) AddOpHandler ¶
func (c *ClientConf) AddOpHandler(op uint32, cb OpHandler) *ClientConf
func (*ClientConf) Clone ¶
func (c *ClientConf) Clone() *ClientConf
func (*ClientConf) PrependCmdHandler ¶
func (c *ClientConf) PrependCmdHandler(cmd string, cb CmdHandler) *ClientConf
type DanmakuHost ¶
type DanmakuInfo ¶
type DanmakuInfo struct { Token string `json:"token"` HostList []DanmakuHost `json:"host_list"` }
func GetDanmakuInfo ¶
func GetDanmakuInfo(room_id int64) (*DanmakuInfo, error)
type ErrHandler ¶
type NullWriter ¶
type NullWriter struct{}
type OpHandler ¶
type OpHandler func(*Client, *RawMessage) bool
type RawMessage ¶
func (*RawMessage) Encode ¶
func (msg *RawMessage) Encode() []byte
type RoomInfo ¶
type RoomInfo struct { Base struct { Uid int64 `json:"uid"` RoomID int64 `json:"room_id"` Title string `json:"title"` Cover string `json:"cover"` LiveStatus int `json:"live_status"` LiveStartTime int64 `json:"live_start_time"` } `json:"room_info"` Liver struct { Base struct { Name string `json:"uname"` Icon string `json:"face"` Gender string `json:"gender"` } `json:"base_info"` Medal struct { Name string `json:"medal_name"` Id int `json:"medal_id"` FanClub int `json:"fansclub"` } `json:"medal_info"` } `json:"anchor_info"` }
func GetRoomInfo ¶
type SendDirectMsgRsp ¶ added in v1.0.3
type SendDirectMsgRsp struct { Code int `json:"code"` Message string `json:"message"` TTL int `json:"ttl"` Data struct { KeyHitInfos map[string]interface{} `json:"key_hit_infos"` Content string `json:"msg_content"` MsgKey uint64 `json:"msg_key"` } `json:"data"` }
func SendDirectMsg ¶ added in v1.0.3
func SendDirectMsg(sender, reciever int64, content, dev_id, sess_data, jct string) (*SendDirectMsgRsp, error)
func SendDirectMsgPicture ¶ added in v1.0.5
func SendDirectMsgPicture(sender, reciever int64, pic *UploadedPic, image_type, dev_id, sess_data, jct string) (*SendDirectMsgRsp, error)
func SendDirectMsgRaw ¶ added in v1.0.5
func SendDirectMsgRaw(sender, reciever int64, content []byte, msg_type, dev_id, sess_data, jct string) (*SendDirectMsgRsp, error)
type ServerDisconnectHandler ¶
Click to show internal directories.
Click to hide internal directories.