comment

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package comment contains validated parameters and response models for the Bilibili comment domain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides comment-domain operations.

func NewClient

func NewClient(client *core.Client) Client

NewClient binds the comment module to a shared client.

func (Client) Count

func (c Client) Count(ctx context.Context, params CountParams) (Count, error)

Count gets the target's total comment count.

func (Client) Hot

func (c Client) Hot(ctx context.Context, params HotParams) (*Hot, error)

Hot gets hot replies when the API returns a payload. A successful null or missing data field returns (nil, nil).

func (Client) List

func (c Client) List(ctx context.Context, params ListParams) (List, error)

List gets the target's main-comment page.

func (Client) Replies

func (c Client) Replies(ctx context.Context, params RepliesParams) (List, error)

Replies gets one page of replies below a root comment.

type Content

type Content struct {
	Message string `json:"message"`
}

type Count

type Count struct {
	Count int64 `json:"count"`
}

type CountParams

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

func NewCountParams

func NewCountParams(target Target) CountParams

func (CountParams) EncodeQuery

func (p CountParams) EncodeQuery() (url.Values, error)

type Hot

type Hot struct {
	Page    HotPage           `json:"page"`
	Replies []json.RawMessage `json:"replies"`
}

Hot is a hot-comment payload when the endpoint returns one. Individual reply bodies remain raw until promoted fixtures establish a stable subset.

type HotPage

type HotPage struct {
	AllCount int64 `json:"acount"`
	Count    int64 `json:"count"`
	Page     int32 `json:"num"`
	Size     int32 `json:"size"`
}

HotPage contains hot-comment pagination counters.

type HotParams

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

HotParams configures comment.read.hot.

func NewHotParams

func NewHotParams(target Target, root int64) (HotParams, error)

NewHotParams creates hot-comment parameters for a positive root reply ID.

func (HotParams) EncodeQuery

func (p HotParams) EncodeQuery() (url.Values, error)

EncodeQuery returns a new URL query containing the request parameters.

func (HotParams) WithPage

func (p HotParams) WithPage(page uint32) (HotParams, error)

WithPage returns a copy with a non-zero page.

func (HotParams) WithPageSize

func (p HotParams) WithPageSize(size uint32) (HotParams, error)

WithPageSize returns a copy with a non-zero page size.

type List

type List struct {
	Page       *Page           `json:"page"`
	Replies    []Reply         `json:"replies"`
	TopReplies []Reply         `json:"top_replies"`
	Root       *Reply          `json:"root"`
	Config     json.RawMessage `json:"config"`
	Control    json.RawMessage `json:"control"`
	Cursor     json.RawMessage `json:"cursor"`
	Top        json.RawMessage `json:"top"`
	Upper      json.RawMessage `json:"upper"`
}

type ListParams

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

func NewListParams

func NewListParams(target Target) ListParams

func (ListParams) EncodeQuery

func (p ListParams) EncodeQuery() (url.Values, error)

func (ListParams) WithPage

func (p ListParams) WithPage(page uint32) (ListParams, error)

func (ListParams) WithPageSize

func (p ListParams) WithPageSize(size uint32) (ListParams, error)

func (ListParams) WithSort

func (p ListParams) WithSort(sort Sort) (ListParams, error)

func (ListParams) WithoutHot

func (p ListParams) WithoutHot(noHot bool) ListParams

type Member

type Member struct {
	MID    string `json:"mid"`
	Name   string `json:"uname"`
	Sex    string `json:"sex"`
	Sign   string `json:"sign"`
	Avatar string `json:"avatar"`
}

type Page

type Page struct {
	Page     uint64  `json:"num"`
	Size     uint64  `json:"size"`
	Count    uint64  `json:"count"`
	AllCount *uint64 `json:"acount"`
}

type RepliesParams

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

func NewRepliesParams

func NewRepliesParams(target Target, root int64) (RepliesParams, error)

func (RepliesParams) EncodeQuery

func (p RepliesParams) EncodeQuery() (url.Values, error)

func (RepliesParams) WithPage

func (p RepliesParams) WithPage(page uint32) (RepliesParams, error)

func (RepliesParams) WithPageSize

func (p RepliesParams) WithPageSize(size uint32) (RepliesParams, error)

type Reply

type Reply struct {
	RPID       int64   `json:"rpid"`
	OID        int64   `json:"oid"`
	Type       int64   `json:"type"`
	MID        int64   `json:"mid"`
	Root       int64   `json:"root"`
	Parent     int64   `json:"parent"`
	Count      int64   `json:"count"`
	ReplyCount int64   `json:"rcount"`
	CreatedAt  int64   `json:"ctime"`
	Likes      int64   `json:"like"`
	Member     Member  `json:"member"`
	Content    Content `json:"content"`
	Replies    []Reply `json:"replies"`
}

type Sort

type Sort uint8
const (
	SortByTime Sort = iota
	SortByLike
	SortByReplies
)

type Target

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

Target identifies one Bilibili comment area.

func NewTarget

func NewTarget(typeID int32, oid int64) (Target, error)

NewTarget creates a positive comment type/object pair.

Jump to

Keyboard shortcuts

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