Help us shape the future of Go! Take the 2026 Go Developer Survey

aiotieba

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 115 Imported by: 0

README

aiotieba-go

Go Reference Release Go Version License

一个用 Go 编写的百度贴吧 API 库,是原 Python 版 aiotieba 的全量移植。

Client 暴露与 Python 版同名(PascalCase)的方法,覆盖 HTTP、WebSocket、BLCP 私有协议、贴吧客户端签名与 AES 等加密、以及 protobuf 编解码。

安装

go get github.com/rongyuio/aiotieba-go

认证

调用前需要准备两个登录凭证:

凭证 长度 说明
BDUSS 192 字符 用户身份认证 token,必填
STOKEN 64 字符 额外的安全 token,部分 API 需要,可留空

快速开始

package main

import (
	"context"
	"fmt"

	"github.com/rongyuio/aiotieba-go"
)

func main() {
	client, err := aiotieba.New("你的BDUSS", "你的STOKEN")
	if err != nil {
		panic(err)
	}
	defer client.Close()

	threads, err := client.GetThreads(context.Background(), aiotieba.ByFName("天堂鸡汤"), aiotieba.GetThreadsArgs{Pn: 1, Rn: 30})
	if err != nil {
		panic(err)
	}
	for _, thread := range threads.Objs {
		fmt.Printf("tid=%d\n%s\n", thread.TID, thread.Text())
	}
}

API 列表

方法名与 Python 版一一对齐(PascalCase),内部统一采用 context.Context 与显式 error 返回。

Client 共覆盖 117 个贴吧接口,按类别归类如下:

类别 接口数 覆盖范围
会话与生命周期 13 账号切换、会话初始化、WebSocket 与 BLCP 容器
帖子与回复 29 帖子与回复的读取、增删、屏蔽、恢复、加精置顶、点赞点踩
用户 20 用户信息、关注与粉丝、个人主页、头像与图片、主页设置
吧(论坛) 19 贴吧信息、关注、排名、广场、分区、吧内用户
吧务管理 23 吧务团队与权限、管理日志、黑名单、封禁、申诉、统计
消息与聊天 8 私信、@ 信息、吧群与聊天室
签到 3 单个签到、一键签到、成长等级签到
搜索 2 吧内搜索、全站搜索

每个接口的用途说明见 docs/api.md,其中同时列出了包级辅助接口 (New 与 With* 选项、By* 引用构造、Default*Args 默认参数)以及 logging 包的公开接口。 完整类型与签名见 Go Reference。

日志

日志基于 zerolog,控制台输出到 stderr 并带颜色, 消息体与 Python 版 aiotieba 逐字对齐:

2026-09-15 00:00:03 WRN [sign_forums] (340011, ''). args=() kwargs={}
2026-09-15 00:00:04 INF [sign_forum] Succeeded. args=('盗墓笔记',) kwargs={}
// logging 即 github.com/rongyuio/aiotieba-go/logging
logging.SetLevel(zerolog.InfoLevel) // 默认 Debug
logging.EnableFileLog("log")        // 追加写入 log/<程序名>.log,仅首次调用生效
logging.SetLogger(&myLogger)        // 替换为自定义记录器
  • 只有写操作(返回 exception.BoolResponse 的方法)记录成功日志,读接口只记录失败
  • 失败日志的正文是异常本身:*exception.TiebaServerError{Code: 340011} 渲染为 (340011, '')
  • 文件日志无颜色、只记 INFO 及以上,按大小轮转(单文件 10MB,保留 5 份)

项目特色

  • 收录 99 个贴吧接口(api/ 目录下每个子包对应一个接口)
  • 支持 protobuf 序列化请求参数
  • 支持 WebSocket 接口与 BLCP 群聊协议
  • 与官方版本高度一致的密码学实现(签名、cuid_galaxy2、c3_aid、rc4_42、AES-ECB/CBC 等,均有逐字节测试向量)
  • 全量对照原 Python 版迁移,公开方法名对齐,内部采用 Go 惯用法(context.Context、显式 error 返回、结构体)

目录结构

aiotieba-go/
├── client.go          # Client 门面:聚合全部 API 方法
├── config/ consts/ enums/ exception/ logging/   # 配置 / 常量 / 枚举 / 异常 / 日志
├── core/              # Account / NetCore / HttpCore / WsCore / BLCPCore
├── helper/            # utils / cache / crypto / htmlutil
├── docs/              # api.md:全部公开接口与用途对照表
├── protobuf/          # 通用 protobuf 生成代码
├── api/               # 99 个 API 子包(每个含 api.go / classdef.go / protobuf)
└── tools/genproto/    # protoc-gen-go 生成脚本

许可

本项目采用 MIT 协议。

它是 Python 版 aiotieba 的全量移植,上游采用 Unlicense(公有领域), 在此致谢原作者与全部贡献者;本仓库在 v1.3.1 及更早版本同样采用 Unlicense。

  • 本库是非官方的第三方实现,与百度及贴吧官方无任何关联,未获其授权或认可
  • 使用本库可能违反贴吧平台的服务条款,并导致账号受限或封禁,请自行评估并承担风险

Documentation

Overview

Package aiotieba 是 aiotieba 库的 Go 移植版本,即百度贴吧 API 的异步客户端。

公开方法名与 Python 客户端(aiotieba.client.Client)保持一致,便于两种实现对照; 内部则使用 Go 惯用法:context.Context、显式 error 返回与结构体。

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 贴吧客户端,是库的入口。它对应 aiotieba.client.Client。

func New

func New(bduss, stoken string, opts ...Option) (*Client, error)

New 创建客户端。account 会覆盖 BDUSS 与 STOKEN;try_ws 表示尝试使用 websocket 接口。

参数:

bduss BDUSS
stoken STOKEN
opts 可选配置,见 Option:account 会覆盖前两个参数,try_ws 尝试使用 websocket 接口,proxy 代理配置,timeout 超时配置

BDUSS 必须为空或 192 个字符,STOKEN 必须为空或 64 个字符,与 Python 构造函数一致。

func (*Client) Account

func (c *Client) Account() *core.Account

Account 返回客户端的账号。

func (*Client) AddBawu

func (c *Client) AddBawu(ctx context.Context, ref ForumRef, id UserRef, bawuType enums.BawuType) (exception.BoolResponse, error)

AddBawu 添加吧务。

参数:

ref 目标贴吧名或fid 优先fid
id 用户id user_id / user_name / portrait 优先user_name
bawuType 吧务类型

对应 Client.add_bawu。

func (*Client) AddBawuBlacklist

func (c *Client) AddBawuBlacklist(ctx context.Context, ref ForumRef, id UserRef) (exception.BoolResponse, error)

AddBawuBlacklist 添加贴吧黑名单。

参数:

ref 目标贴吧的贴吧名或fid 优先贴吧名
id 用户id user_id / user_name / portrait 优先user_id

对应 Client.add_bawu_blacklist。

func (*Client) AddBlacklistOld

func (c *Client) AddBlacklistOld(ctx context.Context, id UserRef) (exception.BoolResponse, error)

AddBlacklistOld 添加旧版用户黑名单。

参数:

id 待添加黑名单的用户id user_id / user_name / portrait 优先user_id

对应 Client.add_blacklist_old。

func (*Client) AddPoll

func (c *Client) AddPoll(ctx context.Context, tid int64, options []int64) (exception.BoolResponse, error)

AddPoll 投票。

参数:

tid 投票帖的id
options 投票选项集合 (1,)对应第一个选项

对应 Client.add_poll。

func (*Client) AddPost

func (c *Client) AddPost(ctx context.Context, ref ForumRef, tid int64, content string) (exception.BoolResponse, error)

AddPost 回复主题帖,对应 Client.add_post。

发帖在贴吧平台属于高风险操作:调用过于频繁可能导致永久封禁,请谨慎使用。

func (*Client) Agree

func (c *Client) Agree(ctx context.Context, tid, pid int64, isComment bool) (exception.BoolResponse, error)

Agree 点赞主题帖或回复。

参数:

tid 待点赞的主题帖或回复所在的主题帖的tid
pid 待点赞的回复pid
isComment pid是否指向楼中楼

本接口仍处于测试阶段;高频率调用会导致<发帖秒删>! 请谨慎使用!

对应 Client.agree。

func (*Client) BLCPCore

func (c *Client) BLCPCore() *core.BLCPCore

BLCPCore 返回客户端的 BLCP 会话。

func (*Client) Block

func (c *Client) Block(ctx context.Context, ref ForumRef, id UserRef, day int64, reason string) (exception.BoolResponse, error)

Block 封禁用户。

参数:

ref 所在贴吧的贴吧名或fid 优先fid
id 用户id user_id / user_name / portrait 优先portrait
day 封禁天数
reason 封禁理由

对应 Client.block。

func (*Client) Close

func (c *Client) Close() error

Close 释放客户端的网络资源,对应 __aexit__。

func (*Client) DelBawu

func (c *Client) DelBawu(ctx context.Context, ref ForumRef, id UserRef, bawuType enums.BawuType) (exception.BoolResponse, error)

DelBawu 删除吧务。

参数:

ref 目标贴吧名或fid 优先fid
id 用户id user_id / user_name / portrait 优先portrait
bawuType 吧务类型

对应 Client.del_bawu。

func (*Client) DelBawuBlacklist

func (c *Client) DelBawuBlacklist(ctx context.Context, ref ForumRef, id UserRef) (exception.BoolResponse, error)

DelBawuBlacklist 移出贴吧黑名单。

参数:

ref 目标贴吧的贴吧名或fid 优先贴吧名
id 用户id user_id / user_name / portrait 优先user_id

对应 Client.del_bawu_blacklist。

func (*Client) DelBlacklistOld

func (c *Client) DelBlacklistOld(ctx context.Context, id UserRef) (exception.BoolResponse, error)

DelBlacklistOld 移除旧版用户黑名单。

参数:

id 待移除黑名单的用户id user_id / user_name / portrait 优先user_id

对应 Client.del_blacklist_old。

func (*Client) DelPost

func (c *Client) DelPost(ctx context.Context, ref ForumRef, tid, pid int64) (exception.BoolResponse, error)

DelPost 删除回复。

参数:

ref 帖子所在贴吧的贴吧名或fid 优先fid
tid 所在主题帖tid
pid 待删除的回复pid

对应 Client.del_post。

func (*Client) DelPosts

func (c *Client) DelPosts(ctx context.Context, ref ForumRef, tid int64, pids []int64, block bool) (exception.BoolResponse, error)

DelPosts 批量删除回复。

参数:

ref 帖子所在贴吧的贴吧名或fid 优先fid
tid 所在主题帖tid
pids 待删除的回复pid列表. Length Max to 30
block 是否同时封一天

对应 Client.del_posts。部分成功返回 true。

func (*Client) DelThread

func (c *Client) DelThread(ctx context.Context, ref ForumRef, tid int64) (exception.BoolResponse, error)

DelThread 删除主题帖。

参数:

ref 帖子所在贴吧的贴吧名或fid 优先fid
tid 待删除的主题帖tid

对应 Client.del_thread。

func (*Client) DelThreads

func (c *Client) DelThreads(ctx context.Context, ref ForumRef, tids []int64, block bool) (exception.BoolResponse, error)

DelThreads 批量删除主题帖。

参数:

ref 帖子所在贴吧的贴吧名或fid 优先fid
tids 待删除的主题帖tid列表. Length Max to 30
block 是否同时封一天

对应 Client.del_threads。部分成功返回 true。

func (*Client) Disagree

func (c *Client) Disagree(ctx context.Context, tid, pid int64, isComment bool) (exception.BoolResponse, error)

Disagree 点踩主题帖或回复。

参数:

tid 待点踩的主题帖或回复所在的主题帖的tid
pid 待点踩的回复pid
isComment pid是否指向楼中楼

对应 Client.disagree。

func (*Client) DislikeForum

func (c *Client) DislikeForum(ctx context.Context, ref ForumRef) (exception.BoolResponse, error)

DislikeForum 屏蔽贴吧,使其不再出现在首页推荐列表中。

参数:

ref 待屏蔽贴吧的贴吧名或fid 优先fid

对应 Client.dislike_forum。

func (*Client) FollowForum

func (c *Client) FollowForum(ctx context.Context, ref ForumRef) (exception.BoolResponse, error)

FollowForum 关注贴吧。

参数:

ref 要关注贴吧的贴吧名或fid 优先fid

对应 Client.follow_forum。

func (*Client) FollowUser

func (c *Client) FollowUser(ctx context.Context, id UserRef) (exception.BoolResponse, error)

FollowUser 关注用户。

参数:

id 用户id user_id / user_name / portrait 优先portrait

对应 Client.follow_user。

func (*Client) GetAts

func (c *Client) GetAts(ctx context.Context, pn int64) (getats.Ats, error)

GetAts 获取@信息。

参数:

pn 页码

对应 Client.get_ats。

func (*Client) GetBawuBlacklist

func (c *Client) GetBawuBlacklist(ctx context.Context, ref ForumRef, pn int64) (getbawublacklist.BawuBlacklistUsers, error)

GetBawuBlacklist 获取吧务后台黑名单列表。

参数:

ref 目标贴吧的贴吧名或fid 优先贴吧名
pn 页码

对应 Client.get_bawu_blacklist。本接口需要 STOKEN。

func (*Client) GetBawuInfo

func (c *Client) GetBawuInfo(ctx context.Context, ref ForumRef) (getbawuinfo.BawuInfo, error)

GetBawuInfo 获取吧务团队信息。

参数:

ref 目标贴吧名或fid 优先fid

对应 Client.get_bawu_info。

func (*Client) GetBawuMemberlist

func (c *Client) GetBawuMemberlist(ctx context.Context, ref ForumRef, pn int64, searchValue string) (getbawumemberlist.BawuListMemberUsers, error)

GetBawuMemberlist 获取吧务后台吧会员列表。

参数:

ref 目标贴吧名或fid 优先贴吧名
pn 页码
searchValue 搜索用户名

对应 Client.get_bawu_memberlist。本接口需要 STOKEN。

func (*Client) GetBawuPerm

func (c *Client) GetBawuPerm(ctx context.Context, ref ForumRef, id UserRef) (getbawuperm.BawuPerm, error)

GetBawuPerm 获取指定吧务已分配的权限。

参数:

ref 目标贴吧名或fid 优先fid
id 用户id user_id / user_name / portrait 优先portrait

对应 Client.get_bawu_perm。

func (*Client) GetBawuPostlogs

func (c *Client) GetBawuPostlogs(
	ctx context.Context, ref ForumRef, pn int64, searchValue string, searchType enums.BawuSearchType,
	startDT, endDT *time.Time, opType int64,
) (getbawupostlogs.BawuPostLogs, error)

GetBawuPostlogs 获取吧务后台帖子管理日志表。

参数:

ref 目标贴吧名或fid 优先贴吧名
pn 页码
searchValue 搜索关键字
searchType 搜索类型
startDT 搜索的起始时间(含)
endDT 搜索的结束时间(含)
opType 搜索操作类型

对应 Client.get_bawu_postlogs。本接口需要 STOKEN。

func (*Client) GetBawuUserlogs

func (c *Client) GetBawuUserlogs(
	ctx context.Context, ref ForumRef, pn int64, searchValue string, searchType enums.BawuSearchType,
	startDT, endDT *time.Time, opType int64,
) (getbawuuserlogs.BawuUserLogs, error)

GetBawuUserlogs 获取吧务用户管理日志表。

参数:

ref 目标贴吧名或fid 优先贴吧名
pn 页码
searchValue 搜索关键字
searchType 搜索类型
startDT 搜索的起始时间(含)
endDT 搜索的结束时间(含)
opType 搜索操作类型

对应 Client.get_bawu_userlogs。本接口需要 STOKEN。

func (*Client) GetBlacklist

func (c *Client) GetBlacklist(ctx context.Context) (getblacklist.BlacklistUsers, error)

GetBlacklist 获取完整的新版用户黑名单列表。

对应 Client.get_blacklist。

func (*Client) GetBlacklistOld

func (c *Client) GetBlacklistOld(ctx context.Context, pn, rn int32) (getblacklistold.BlacklistOldUsers, error)

GetBlacklistOld 获取旧版用户黑名单列表。

参数:

pn 页码
rn 请求的条目数 Max to Inf

对应 Client.get_blacklist_old。

func (*Client) GetBlocks

func (c *Client) GetBlocks(ctx context.Context, ref ForumRef, name string, pn int64) (getblocks.Blocks, error)

GetBlocks 获获取吧务后台待解封用户列表。

参数:

ref 目标贴吧的贴吧名或fid 优先fid
name 通过被封禁用户的用户名/昵称查询 默认为空即查询全部
pn 页码

对应 Client.get_blocks。

func (*Client) GetCID

func (c *Client) GetCID(ctx context.Context, ref ForumRef, cname string) (exception.IntResponse, error)

GetCID 通过精华分区名获取精华分区 id。

参数:

ref 帖子所在贴吧的贴吧名或fid
cname 精华分区名

对应 Client.get_cid。

func (*Client) GetComments

func (c *Client) GetComments(ctx context.Context, tid, pid int64, args GetCommentsArgs) (getcomments.Comments, error)

GetComments 获取楼中楼回复。

参数:

tid 所在主题帖tid
pid 所在楼层的pid或楼中楼的pid
args 可选参数,详见 GetCommentsArgs

对应 Client.get_comments。

注意 args.Sort 目前不被服务端采纳:三种取值返回的顺序完全相同,HTTP 与 WebSocket 均如此。

func (*Client) GetDislikeForums

func (c *Client) GetDislikeForums(ctx context.Context, pn, rn int32) (getdislikeforums.DislikeForums, error)

GetDislikeForums 获取首页推荐屏蔽的贴吧列表。

参数:

pn 页码
rn 请求的条目数 Max to 20

对应 Client.get_dislike_forums。

func (*Client) GetFID

func (c *Client) GetFID(ctx context.Context, fname string) (int64, error)

GetFID 通过贴吧名获取 forum_id。

参数:

fname 贴吧名

优先使用吧信息缓存,对应 Client.get_fid。

func (*Client) GetFName

func (c *Client) GetFName(ctx context.Context, fid int64) (string, error)

GetFName 通过 forum_id 获取贴吧名。

参数:

fid forum_id

优先使用吧信息缓存,对应 Client.get_fname。

func (*Client) GetFans

func (c *Client) GetFans(ctx context.Context, id UserRef, pn int64) (getfans.Fans, error)

GetFans 获取粉丝列表。

参数:

id 用户id user_id / user_name / portrait 优先user_id 为空表示本账号
pn 页码

对应 Client.get_fans。

func (*Client) GetFollowForums

func (c *Client) GetFollowForums(ctx context.Context, id UserRef, pn, rn int64) (getfollowforums.FollowForums, error)

GetFollowForums 获取用户关注贴吧列表。

参数:

id 用户id user_id / user_name / portrait 优先user_id
pn 页码
rn 请求的条目数 Max to Inf

对应 Client.get_follow_forums。

func (*Client) GetFollowForumsPc

func (c *Client) GetFollowForumsPc(ctx context.Context, id UserRef, pn, rn int64) (getfollowforumspc.PcFollowForums, error)

GetFollowForumsPc 获取用户关注贴吧列表。

参数:

id 用户id user_id / user_name / portrait 优先portrait
pn 页码
rn 请求的条目数 Max to Inf

对应 Client.get_follow_forums_pc。

func (*Client) GetFollows

func (c *Client) GetFollows(ctx context.Context, id UserRef, pn int64) (getfollows.Follows, error)

GetFollows 获取关注列表。

参数:

id 用户id user_id / user_name / portrait 优先user_id 为空表示本账号
pn 页码

对应 Client.get_follows。

func (*Client) GetForum

func (c *Client) GetForum(ctx context.Context, ref ForumRef) (getforum.Forum, error)

GetForum 获取贴吧信息。 此接口较 GetForumDetail 更强大。

参数:

ref 目标贴吧名或fid 优先贴吧名

对应 Client.get_forum。

func (*Client) GetForumDetail

func (c *Client) GetForumDetail(ctx context.Context, ref ForumRef) (getforumdetail.ForumDetail, error)

GetForumDetail 获取贴吧信息。

参数:

ref 目标贴吧名或fid 优先fid

对应 Client.get_forum_detail。

func (*Client) GetGroupMsg

func (c *Client) GetGroupMsg(ctx context.Context, groupIDs []int64, getType int64) (getgroupmsg.WsMsgGroups, error)

GetGroupMsg 获取分组信息。

参数:

groupIDs 待获取分组的group_id
getType 获取类型

对应 Client.get_group_msg。该接口仅支持 websocket 传输,因此会无条件建立连接 (对应 Python 客户端的 _force_websocket 装饰器),失败会直接返回给调用方。

func (*Client) GetHomepage

func (c *Client) GetHomepage(ctx context.Context, id UserRef, pn int32) (profile.Homepage, error)

GetHomepage 获取用户个人页信息。

参数:

id 用户id user_id / user_name / portrait 优先user_id
pn 页码

对应 Client.get_homepage。

func (*Client) GetImage

func (c *Client) GetImage(ctx context.Context, imgURL string) (getimages.Image, error)

GetImage 从链接获取静态图像。

参数:

imgURL 图像链接

对应 Client.get_image。

func (*Client) GetImageBytes

func (c *Client) GetImageBytes(ctx context.Context, imgURL string) (getimages.ImageBytes, error)

GetImageBytes 从链接获取静态图像的原始字节流。

参数:

imgURL 图像链接

对应 Client.get_image_bytes。

func (*Client) GetLastReplyers

func (c *Client) GetLastReplyers(ctx context.Context, ref ForumRef, pn, rn int32, sort enums.ThreadSortType, isGood bool) (getlastreplyers.ThreadsLP, error)

GetLastReplyers 通过旧版接口获取带最后回复人的首页帖子。

参数:

ref 贴吧名或fid 优先贴吧名
pn 页码
rn 请求的条目数 Max to 100
sort HOT热门排序 REPLY按回复时间 CREATE按发布时间 FOLLOW关注的人
isGood True则获取精品区帖子 False则获取普通区帖子

对应 Client.get_last_replyers。该接口主要用于反挖坟,不暴露完整的帖子信息,目前未封装完整的返回信息。

func (*Client) GetMemberUsers

func (c *Client) GetMemberUsers(ctx context.Context, ref ForumRef, pn int64) (getmemberusers.MemberUsers, error)

GetMemberUsers 获取最新关注用户列表。

参数:

ref 目标贴吧名或fid 优先贴吧名
pn 页码

对应 Client.get_member_users。本接口需要 STOKEN。

func (*Client) GetPortrait

func (c *Client) GetPortrait(ctx context.Context, id UserRef, size string) (getimages.Image, error)

GetPortrait 获取用户头像。

参数:

id 用户id user_id / user_name / portrait 优先portrait
size 获取头像的大小 s为55x55 m为110x110 l为原图

对应 Client.get_portrait。

func (*Client) GetPosts

func (c *Client) GetPosts(ctx context.Context, tid int64, args GetPostsArgs) (getposts.Posts, error)

GetPosts 获取主题帖内回复。

参数:

tid 所在主题帖 tid
args 可选参数,详见 GetPostsArgs

对应 Client.get_posts。

func (*Client) GetRankForums

func (c *Client) GetRankForums(ctx context.Context, ref ForumRef, pn int64, rankType enums.RankForumType) (getrankforums.RankForums, error)

GetRankForums 获取吧签到排行表。

参数:

ref 目标贴吧名或fid 优先贴吧名
pn 页码
rankType 榜单类型 默认为周榜

对应 Client.get_rank_forums。

func (*Client) GetRankUsers

func (c *Client) GetRankUsers(ctx context.Context, ref ForumRef, pn int64) (getrankusers.RankUsers, error)

GetRankUsers 获取等级排行榜用户列表。

参数:

ref 目标贴吧名或fid 优先贴吧名
pn 页码

对应 Client.get_rank_users。

func (*Client) GetRecomStatus

func (c *Client) GetRecomStatus(ctx context.Context, ref ForumRef) (getrecomstatus.RecomStatus, error)

GetRecomStatus 获取大吧主推荐功能的月度配额状态。

参数:

ref 目标贴吧名或fid 优先fid

对应 Client.get_recom_status。

func (*Client) GetRecovers

func (c *Client) GetRecovers(ctx context.Context, ref ForumRef, pn, rn int64, id UserRef) (getrecovers.Recovers, error)

GetRecovers 获取吧务后台待恢复帖子列表。

参数:

ref 目标贴吧的贴吧名或fid 优先fid
pn 页码
rn 请求的条目数 Max to 50
id 用于查询的被删帖用户的id user_id / user_name / portrait 优先user_id

对应 Client.get_recovers。

func (*Client) GetReplys

func (c *Client) GetReplys(ctx context.Context, pn int32) (getreplys.Replys, error)

GetReplys 获取回复信息。

参数:

pn 页码

对应 Client.get_replys。

func (*Client) GetRoomlistByFID

func (c *Client) GetRoomlistByFID(ctx context.Context, fid int64) (getroomlistbyfid.RoomList, error)

GetRoomlistByFID 获取某吧所有群聊。

参数:

fid 吧id

对应 Client.get_roomlist_by_fid。

func (*Client) GetSelfFollowForums

func (c *Client) GetSelfFollowForums(ctx context.Context, pn, rn int64) (getselffollowforums.SelfFollowForums, error)

GetSelfFollowForums 获取本账号关注贴吧列表。

参数:

pn 页码
rn 请求的条目数 Max to 200

对应 Client.get_self_follow_forums。本接口需要 STOKEN。

func (*Client) GetSelfInfo

func (c *Client) GetSelfInfo(ctx context.Context, require enums.ReqUInfo) (classdef.UserInfo, error)

GetSelfInfo 获取本账号信息。

参数:

require 指示需要获取的字段

返回账号的缓存信息,缺失字段按需补齐,对应 Client.get_self_info。

func (*Client) GetSelfPosts

func (c *Client) GetSelfPosts(ctx context.Context, pn, rn int32) (getusercontents.UserPostss, error)

GetSelfPosts 获取当前用户发布的回复列表。

参数:

pn 页码
rn 请求的条目数 Max to 74

对应 Client.get_self_posts。

func (*Client) GetSelfThreads

func (c *Client) GetSelfThreads(ctx context.Context, pn int32, publicOnly bool) (getusercontents.UserThreads, error)

GetSelfThreads 获取当前用户发布的主题帖列表。

参数:

pn 页码
publicOnly 是否仅获取公开主题帖 该选项在获取他人主题帖时无效

对应 Client.get_self_threads。

func (*Client) GetSquareForums

func (c *Client) GetSquareForums(ctx context.Context, cname string, pn, rn int32) (getsquareforums.SquareForums, error)

GetSquareForums 获取吧广场列表。

参数:

cname 类别名
pn 页码
rn 请求的条目数 Max to Inf

对应 Client.get_square_forums。

func (*Client) GetStatistics

func (c *Client) GetStatistics(ctx context.Context, ref ForumRef) (getstatistics.Statistics, error)

GetStatistics 获取吧务后台中最近 24 天的统计数据。

参数:

ref 目标贴吧名或fid 优先fid

对应 Client.get_statistics。

func (*Client) GetTabMap

func (c *Client) GetTabMap(ctx context.Context, ref ForumRef) (gettabmap.TabMap, error)

GetTabMap 获取分区名到分区 id 的映射。

参数:

ref 目标贴吧名或fid 优先贴吧名

对应 Client.get_tab_map。

func (*Client) GetThreads

func (c *Client) GetThreads(ctx context.Context, ref ForumRef, args GetThreadsArgs) (getthreads.Threads, error)

GetThreads 获取首页帖子。

参数:

ref 目标贴吧名或fid 优先贴吧名
args 可选参数,详见 GetThreadsArgs

对应 Client.get_threads。会话打开时使用 websocket 传输,否则回退到 app HTTP API。

func (*Client) GetUnblockAppeals

func (c *Client) GetUnblockAppeals(ctx context.Context, ref ForumRef, pn, rn int64) (getunblockappeals.Appeals, error)

GetUnblockAppeals 获取吧务后台申诉请求列表。

参数:

ref 目标贴吧的贴吧名或fid 优先fid
pn 页码
rn 请求的条目数 Max to 50

对应 Client.get_unblock_appeals。

func (*Client) GetUserForumInfo

func (c *Client) GetUserForumInfo(ctx context.Context, ref ForumRef, id UserRef) (getuserforuminfo.UserForumInfo, error)

GetUserForumInfo 获取用户在某吧内的信息。

参数:

ref 目标贴吧名或fid 优先fid
id 用户id user_id / user_name / portrait 优先portrait

对应 Client.get_user_forum_info。

func (*Client) GetUserInfo

func (c *Client) GetUserInfo(ctx context.Context, ref UserRef, require enums.ReqUInfo) (classdef.UserInfo, error)

GetUserInfo 获取用户信息。

参数:

ref 用户id user_id / portrait / user_name
require 指示需要获取的字段

对应 Client.get_user_info。

Python 客户端每个端点返回不同的专用类型;本移植版把所有分支统一为 classdef.UserInfo, 使调用方看到稳定类型而请求本身保持不变。端点尚未迁移的分支会返回 exception.ErrNotMigrated。

func (*Client) GetUserPosts

func (c *Client) GetUserPosts(ctx context.Context, id UserRef, pn, rn int32) (getusercontents.UserPostss, error)

GetUserPosts 获取用户发布的回复列表。

参数:

id 用户id user_id / user_name / portrait 优先user_id
pn 页码
rn 请求的条目数 Max to 74

对应 Client.get_user_posts。

func (*Client) GetUserPostsPc

func (c *Client) GetUserPostsPc(ctx context.Context, id UserRef, pn, rn int64) (getusercontentpc.PcUserPosts, error)

GetUserPostsPc 获取用户发布的回复列表。

参数:

id 用户id user_id / user_name / portrait 优先portrait
pn 页码
rn 请求的条目数 Max to 74

对应 Client.get_user_posts_pc。

func (*Client) GetUserThreads

func (c *Client) GetUserThreads(ctx context.Context, id UserRef, pn int32) (getusercontents.UserThreads, error)

GetUserThreads 获取用户发布的主题帖列表。

参数:

id 用户id user_id / user_name / portrait 优先user_id
pn 页码

对应 Client.get_user_threads。

func (*Client) Good

func (c *Client) Good(ctx context.Context, ref ForumRef, tid int64, cname string) (exception.BoolResponse, error)

Good 加精主题帖。

参数:

ref 帖子所在贴吧的贴吧名或fid
tid 待加精的主题帖tid
cname 待添加的精华分区名称 默认为''即不分区

对应 Client.good。

func (*Client) HTTPCore

func (c *Client) HTTPCore() *core.HttpCore

HTTPCore 返回客户端的 HTTP 会话。

func (*Client) HandleUnblockAppeals

func (c *Client) HandleUnblockAppeals(ctx context.Context, ref ForumRef, appealIDs []int64, refuse bool) (exception.BoolResponse, error)

HandleUnblockAppeals 拒绝或通过解封申诉。

参数:

ref 申诉所在贴吧的贴吧名或fid 优先fid
appealIDs 申诉请求的appeal_id列表. Length Max to 30
refuse True则拒绝申诉 False则接受申诉

对应 Client.handle_unblock_appeals。

func (*Client) Hash2Image

func (c *Client) Hash2Image(ctx context.Context, rawHash, size string) (getimages.Image, error)

Hash2Image 通过百度图库 hash 获取静态图像。

参数:

rawHash 百度图库hash
size 获取图像的大小 s为宽720 m为宽960 l为原图

对应 Client.hash2image。

func (*Client) HideThread

func (c *Client) HideThread(ctx context.Context, ref ForumRef, tid int64) (exception.BoolResponse, error)

HideThread 屏蔽主题帖。

参数:

ref 帖子所在贴吧的贴吧名或fid 优先fid
tid 待屏蔽的主题帖tid

对应 Client.hide_thread。

func (*Client) InitClientID

func (c *Client) InitClientID(ctx context.Context) error

InitClientID 在账号缺少 client id 时加载它,对应私有方法 Client.__init_client_id。

func (*Client) InitSampleID

func (c *Client) InitSampleID(ctx context.Context) error

InitSampleID 在账号缺少 sample id 时加载它,对应私有方法 Client.__init_sample_id。

func (*Client) InitTbs

func (c *Client) InitTbs(ctx context.Context) error

InitTbs 在账号缺少 tbs token 时加载它,对应私有方法 Client.__init_tbs。

func (*Client) InitWebsocket

func (c *Client) InitWebsocket(ctx context.Context) (bool, error)

InitWebsocket 初始化 websocket。返回 true 表示无须执行,false 表示失败。

连接 websocket 会话并上传密钥,对应 Client.init_websocket。会话未关闭时不执行任何操作。

func (*Client) InitZID

func (c *Client) InitZID(ctx context.Context) error

InitZID 在账号缺少 z_id 时加载它,对应私有方法 Client.__init_z_id。

func (*Client) JoinChatroom

func (c *Client) JoinChatroom(ctx context.Context, roomID int64) (exception.BoolResponse, error)

JoinChatroom 加入聊天室。

参数:

roomID 房间id

对应 Client.join_chatroom。

func (*Client) Login

func (c *Client) Login(ctx context.Context) error

Login 刷新缓存的用户信息与 tbs token,对应私有方法 Client.__login。

func (*Client) Move

func (c *Client) Move(ctx context.Context, ref ForumRef, tid, toTabID, fromTabID int64) (exception.BoolResponse, error)

Move 将主题帖移动至另一分区。

参数:

ref 帖子所在贴吧的贴吧名或fid 优先fid
tid 待移动的主题帖tid
toTabID 目标分区id
fromTabID 来源分区id 默认为0即无分区

对应 Client.move。

func (*Client) Recommend

func (c *Client) Recommend(ctx context.Context, ref ForumRef, tid int64) (exception.BoolResponse, error)

Recommend 大吧主首页推荐。

参数:

ref 帖子所在贴吧的贴吧名或fid 优先fid
tid 待推荐的主题帖tid

对应 Client.recommend。

func (*Client) Recover

func (c *Client) Recover(ctx context.Context, ref ForumRef, tid, pid int64, isHide bool) (exception.BoolResponse, error)

Recover 帖子恢复相关操作。

参数:

ref 帖子所在贴吧的贴吧名或fid 优先fid
tid 待恢复的主题帖tid
pid 待恢复的回复pid
isHide True则取消屏蔽主题帖 False则恢复删帖

对应 Client.recover。

func (*Client) RecoverPost

func (c *Client) RecoverPost(ctx context.Context, ref ForumRef, pid int64) (exception.BoolResponse, error)

RecoverPost 恢复回复。

参数:

ref 帖子所在贴吧的贴吧名或fid 优先fid
pid 待恢复的回复pid

对应 Client.recover_post。

func (*Client) RecoverThread

func (c *Client) RecoverThread(ctx context.Context, ref ForumRef, tid int64) (exception.BoolResponse, error)

RecoverThread 恢复主题帖。

参数:

ref 帖子所在贴吧的贴吧名或fid 优先fid
tid 待恢复的主题帖tid

对应 Client.recover_thread。

func (*Client) RemoveFan

func (c *Client) RemoveFan(ctx context.Context, id UserRef) (exception.BoolResponse, error)

RemoveFan 移除粉丝。

参数:

id 待移除粉丝的id user_id / user_name / portrait 优先user_id

对应 Client.remove_fan。

func (*Client) SearchExact

func (c *Client) SearchExact(ctx context.Context, ref ForumRef, query string, pn, rn int64, searchType enums.SearchType, onlyThread bool) (searchexact.ExactSearches, error)

SearchExact 贴吧搜索。

参数:

ref 查询的贴吧名或fid 优先贴吧名
query 查询文本
pn 页码
rn 请求的条目数
searchType 查询模式 默认查询全部
onlyThread 是否仅查询主题帖

对应 Client.search_exact。

func (*Client) SearchGlobal

func (c *Client) SearchGlobal(ctx context.Context, word string, pn, rn, sort int64) (searchglobal.GlobalSearches, error)

SearchGlobal 全吧搜索,不限定贴吧的全站主题帖关键词搜索。

参数:

word 查询文本
pn 页码
rn 请求的条目数
sort 排序方式

该接口为 PC 网页端搜索接口(逆向所得 非官方开放 API),走 `subapp_type=pc` 网页端签名通道,复用当前账号的 Cookie(BDUSS) 鉴权。 不同于 `search_exact` 所用的 App 表单签名协议,其稳定性与频控策略未经长期验证,请自行控制调用频率。 该接口存在与请求参数无关的服务端间歇性错误(如 `TiebaServerError` 300003),失败会体现在返回值 `.err`,建议调用方按需重试。 仅支持搜索主题帖,实测该接口的评论/楼中楼搜索(tt=3)不会生效,服务端会原样返回主题帖结果。 若需要某个主题帖下的评论,请在拿到 `tid` 后使用 `GetPosts` 单独查询。

对应 Client.search_global。

func (*Client) SendChatroomMsg

func (c *Client) SendChatroomMsg(ctx context.Context, chatroomID, fid int64, text string, atUserIDs []int64, robotc int64) (exception.BoolResponse, error)

SendChatroomMsg 向吧群发送信息,仅限简单文本。如需要@他人需要指定 atUserIDs,如需与 bot 交互需要指定 atUserIDs 和 robotc。

参数:

chatroomID 聊天室id
fid 吧id
text 待发送内容
atUserIDs 需要@的人的user_id列表
robotc 机器人指令id。机器人靠此分辨指令,而非text内容。

对应 Client.send_chatroom_msg。缓存的自身信息(c.user)必须包含 user_id 与 portrait, Python 客户端通过 get_self_info 填充这两项。

func (*Client) SendMsg

func (c *Client) SendMsg(ctx context.Context, id UserRef, content string) (exception.BoolResponse, error)

SendMsg 发送私信。

参数:

id 用户id user_id / user_name / portrait 优先user_id
content 发送内容

对应 Client.send_msg。该接口仅支持 websocket;返回的 msg id 会记录到消息 id 管理器中, 后续读取从该位置继续。

func (*Client) SetAccount

func (c *Client) SetAccount(newAccount *core.Account) error

SetAccount 替换所有会话的账号,对应 Python 的 account setter。

func (*Client) SetBawuPerm

func (c *Client) SetBawuPerm(ctx context.Context, ref ForumRef, id UserRef, perms enums.BawuPermType) (exception.BoolResponse, error)

SetBawuPerm 为指定吧务分配权限。

参数:

ref 目标贴吧名或fid 优先fid
id 用户id user_id / user_name / portrait 优先portrait
perms 待分配的权限

对应 Client.set_bawu_perm。

func (*Client) SetBlacklist

func (c *Client) SetBlacklist(ctx context.Context, id UserRef, btype enums.BlacklistType) (exception.BoolResponse, error)

SetBlacklist 设置新版用户黑名单。

参数:

id 待设置黑名单的用户id user_id / user_name / portrait 优先user_id
btype 黑名单类型 默认全屏蔽

对应 Client.set_blacklist。

func (*Client) SetMsgReaded

func (c *Client) SetMsgReaded(ctx context.Context, message getgroupmsg.WsMessage) (exception.BoolResponse, error)

SetMsgReaded 将一条私信设为已读。

参数:

message websocket私信消息

对应 Client.set_msg_readed。

func (*Client) SetNicknameOld

func (c *Client) SetNicknameOld(ctx context.Context, nickName string) (exception.BoolResponse, error)

SetNicknameOld 设置旧版昵称。

参数:

nickName 昵称

对应 Client.set_nickname_old。

func (*Client) SetProfile

func (c *Client) SetProfile(ctx context.Context, nickName, sign string, gender enums.Gender) (exception.BoolResponse, error)

SetProfile 设置主页信息。

参数:

nickName 昵称
sign 个性签名
gender 性别

对应 Client.set_profile。

func (*Client) SetThreadPrivacy

func (c *Client) SetThreadPrivacy(ctx context.Context, ref ForumRef, tid, pid int64, isHide bool) (exception.BoolResponse, error)

SetThreadPrivacy 隐藏或公开主题帖或回复。isHide 为 true 则隐藏,为 false 则公开。

本方法是 Go 版提供的合并入口,Python 客户端只有 set_thread_private 与 set_thread_public 两个独立 API,因此它的日志名 "set_thread_privacy" 在 Python 侧 并不存在。除日志名不同外,其余行为(含成功日志)与那两个方法一致。

func (*Client) SetThreadPrivate

func (c *Client) SetThreadPrivate(ctx context.Context, ref ForumRef, tid, pid int64) (exception.BoolResponse, error)

SetThreadPrivate 隐藏主题帖。

参数:

ref 主题帖所在贴吧的贴吧名或fid 优先fid
tid 主题帖tid
pid 主题帖pid

对应 Client.set_thread_private。

func (*Client) SetThreadPublic

func (c *Client) SetThreadPublic(ctx context.Context, ref ForumRef, tid, pid int64) (exception.BoolResponse, error)

SetThreadPublic 公开主题帖。

参数:

ref 主题帖所在贴吧的贴吧名或fid 优先fid
tid 主题帖tid
pid 主题帖pid

对应 Client.set_thread_public。

func (*Client) Share added in v1.6.0

func (c *Client) Share(ctx context.Context, tid, fid int64, shareChannel int32) (exception.BoolResponse, error)

Share 上报一次主题帖分享行为。

参数:

tid 被分享的主题帖id
fid 该帖所在吧的 fid。分享前必须先调 getShareInfo,而它需要 forum_id;
  真实客户端的分享链路就是 getShareInfo → thread/share,
  后者的 m_* 四元组申报的正是前者那一次调用
shareChannel 分享渠道,语义尚未确认,传 0 表示不设置该字段

本接口只向服务端上报分享行为,不返回分享链接或文案, 并且没有 WebSocket 通路,仅走 HTTP。

对应 Client.share。

func (*Client) SignForum

func (c *Client) SignForum(ctx context.Context, ref ForumRef) (exception.BoolResponse, error)

SignForum 单个贴吧签到。

参数:

ref 要签到贴吧的贴吧名或fid 优先贴吧名

对应 Client.sign_forum。

func (*Client) SignForums

func (c *Client) SignForums(ctx context.Context) (exception.BoolResponse, error)

SignForums 一键签到,对应 Client.sign_forums。

func (*Client) SignGrowth

func (c *Client) SignGrowth(ctx context.Context) (exception.BoolResponse, error)

SignGrowth 用户成长等级任务: 签到,对应 Client.sign_growth。

func (*Client) TiebaUID2UserInfo

func (c *Client) TiebaUID2UserInfo(ctx context.Context, tiebaUID int64) (tiebauid2userinfo.UserInfoTUid, error)

TiebaUID2UserInfo 通过 tieba_uid 获取用户信息。

参数:

tiebaUID 用户id tieba_uid

对应 Client.tieba_uid2user_info。请注意 tieba_uid 与旧版 user_id 的区别。

func (*Client) Top

func (c *Client) Top(ctx context.Context, ref ForumRef, tid int64, isVIP bool) (exception.BoolResponse, error)

Top 置顶主题帖。

参数:

ref 帖子所在贴吧的贴吧名或fid
tid 待置顶的主题帖tid
isVIP 是否会员置顶

对应 Client.top。

func (*Client) Unagree

func (c *Client) Unagree(ctx context.Context, tid, pid int64, isComment bool) (exception.BoolResponse, error)

Unagree 取消点赞主题帖或回复。

参数:

tid 待取消点赞的主题帖或回复所在的主题帖的tid
pid 待取消点赞的回复pid
isComment pid是否指向楼中楼

对应 Client.unagree。

func (*Client) Unblock

func (c *Client) Unblock(ctx context.Context, ref ForumRef, id UserRef) (exception.BoolResponse, error)

Unblock 解封用户。

参数:

ref 所在贴吧的贴吧名或fid 优先fid
id 用户id user_id / user_name / portrait 优先user_id

对应 Client.unblock。

func (*Client) Undisagree

func (c *Client) Undisagree(ctx context.Context, tid, pid int64, isComment bool) (exception.BoolResponse, error)

Undisagree 取消点踩主题帖或回复。

参数:

tid 待取消点踩的主题帖或回复所在的主题帖的tid
pid 待取消点踩的回复pid
isComment pid是否指向楼中楼

对应 Client.undisagree。

func (*Client) UndislikeForum

func (c *Client) UndislikeForum(ctx context.Context, ref ForumRef) (exception.BoolResponse, error)

UndislikeForum 解除贴吧的首页推荐屏蔽。

参数:

ref 待屏蔽贴吧的贴吧名或fid 优先fid

对应 Client.undislike_forum。

func (*Client) UnfollowForum

func (c *Client) UnfollowForum(ctx context.Context, ref ForumRef) (exception.BoolResponse, error)

UnfollowForum 取关贴吧。

参数:

ref 要取关贴吧的贴吧名或fid 优先fid

对应 Client.unfollow_forum。

func (*Client) UnfollowUser

func (c *Client) UnfollowUser(ctx context.Context, id UserRef) (exception.BoolResponse, error)

UnfollowUser 取关用户。

参数:

id 用户id user_id / user_name / portrait 优先portrait

对应 Client.unfollow_user。

func (*Client) Ungood

func (c *Client) Ungood(ctx context.Context, ref ForumRef, tid int64) (exception.BoolResponse, error)

Ungood 撤精主题帖。

参数:

ref 帖子所在贴吧的贴吧名或fid
tid 待撤精的主题帖tid

对应 Client.ungood。

func (*Client) UnhideThread

func (c *Client) UnhideThread(ctx context.Context, ref ForumRef, tid int64) (exception.BoolResponse, error)

UnhideThread 解除主题帖屏蔽。

参数:

ref 帖子所在贴吧的贴吧名或fid 优先fid
tid 待解除屏蔽的主题帖tid

对应 Client.unhide_thread。

func (*Client) Untop

func (c *Client) Untop(ctx context.Context, ref ForumRef, tid int64, isVIP bool) (exception.BoolResponse, error)

Untop 撤销置顶主题帖。

参数:

ref 帖子所在贴吧的贴吧名或fid
tid 待撤销置顶的主题帖tid
isVIP 是否会员置顶

对应 Client.untop。

func (*Client) User

func (c *Client) User() classdef.UserInfo

User 返回账号的缓存用户信息,对应 self_info 属性。

func (*Client) WSCore

func (c *Client) WSCore() *core.WsCore

WSCore 返回客户端的 websocket 会话。

type ForumRef

type ForumRef struct {
	FName string
	FID   int64
}

ForumRef 通过贴吧名或 fid 标识一个贴吧,对应 Python 客户端的 `fname_or_fid: str | int` 参数:GetForum 优先使用贴吧名,GetForumDetail 优先使用 fid。

func ByFID

func ByFID(fid int64) ForumRef

ByFID 通过 fid 引用一个贴吧。

func ByFName

func ByFName(fname string) ForumRef

ByFName 通过贴吧名引用一个贴吧。

func (ForumRef) PyRepr added in v1.3.0

func (r ForumRef) PyRepr() string

PyRepr 让日志输出贴吧名(优先)或 fid,而不是 Go 结构体的 %+v 形式。

type GetCommentsArgs

type GetCommentsArgs struct {
	Pn        int                // 页码
	IsComment bool               // pid 是否指向楼中楼 若指向楼中楼则获取其附近的楼中楼列表
	Sort      enums.PostSortType // ASC时间顺序 DESC时间倒序 HOT热门序(服务端当前忽略)
}

GetCommentsArgs 是 GetComments 的可选参数。

func DefaultGetCommentsArgs

func DefaultGetCommentsArgs() GetCommentsArgs

DefaultGetCommentsArgs 返回 GetComments 的 Python 默认值。

type GetPostsArgs

type GetPostsArgs struct {
	Pn                 int                // 页码
	Rn                 int                // 请求的条目数
	Sort               enums.PostSortType // ASC时间顺序 DESC时间倒序 HOT热门序
	OnlyThreadAuthor   bool               // True则只看楼主 False则请求全部
	WithComments       bool               // True则同时请求高赞楼中楼 False则返回的 Post.comments 字段为空
	CommentSortByAgree bool               // True则楼中楼按点赞数顺序 False则楼中楼按时间顺序
	CommentRn          int                // 请求的楼中楼数量 Max to 50
}

GetPostsArgs 是 GetPosts 的可选参数。

func DefaultGetPostsArgs

func DefaultGetPostsArgs() GetPostsArgs

DefaultGetPostsArgs 返回 GetPosts 的 Python 默认值。

type GetThreadsArgs

type GetThreadsArgs struct {
	Pn     int                  // 页码
	Rn     int                  // 请求的条目数 Max to 100
	Sort   enums.ThreadSortType // HOT热门排序 REPLY按回复时间 CREATE按发布时间 FOLLOW关注的人
	IsGood bool                 // True则获取精品区帖子 False则获取普通区帖子
}

GetThreadsArgs 是 GetThreads 的可选参数。

func DefaultGetThreadsArgs

func DefaultGetThreadsArgs() GetThreadsArgs

DefaultGetThreadsArgs 返回 GetThreads 的 Python 默认值。

type Option

type Option func(*clientOptions)

Option 用于配置 Client。

func WithAccount

func WithAccount(account *core.Account) Option

WithAccount 设置客户端账号,会覆盖 BDUSS 与 STOKEN。

func WithProxy

func WithProxy(proxy *config.ProxyConfig) Option

WithProxy 设置代理配置。

func WithProxyFromEnv

func WithProxyFromEnv() Option

WithProxyFromEnv 使用环境变量描述的代理。

func WithTimeout

func WithTimeout(timeout config.TimeoutConfig) Option

WithTimeout 设置超时配置。

func WithTryWebsocket

func WithTryWebsocket(try bool) Option

WithTryWebsocket 启用 websocket 传输,失败时回退到 HTTP。

type UserRef

type UserRef struct {
	UserID   int64
	Portrait string
	UserName string
}

UserRef 通过数字 id、portrait 或用户名标识一个用户,对应 Python 客户端的 `id_: str | int` 参数:字符串要么是 portrait("tb.1.xxx"),要么是用户名。

func ByPortrait

func ByPortrait(portrait string) UserRef

ByPortrait 通过 portrait 引用一个用户。

func ByUserID

func ByUserID(id int64) UserRef

ByUserID 通过数字 id 引用一个用户。

func ByUserName

func ByUserName(userName string) UserRef

ByUserName 通过用户名引用一个用户。

func (UserRef) IsZero

func (r UserRef) IsZero() bool

IsZero 报告该引用是否不含任何标识。

func (UserRef) PyRepr added in v1.3.0

func (r UserRef) PyRepr() string

PyRepr 让日志输出用户名/portrait/user_id,而不是 Go 结构体的 %+v 形式。

Directories

Path Synopsis
api
add_bawu
Package addbawu 实现 aiotieba 的 add_bawu API。
Package addbawu 实现 aiotieba 的 add_bawu API。
add_bawu_blacklist
Package addbawublacklist 实现 aiotieba 的 add_bawu_blacklist API。
Package addbawublacklist 实现 aiotieba 的 add_bawu_blacklist API。
add_blacklist_old
Package addblacklistold 实现 aiotieba 的 add_blacklist_old API。
Package addblacklistold 实现 aiotieba 的 add_blacklist_old API。
add_poll
Package addpoll 实现 aiotieba 的 add_poll API。
Package addpoll 实现 aiotieba 的 add_poll API。
add_post
Package addpost 实现 aiotieba 的 add_post API。
Package addpost 实现 aiotieba 的 add_post API。
agree
Package agree 实现 aiotieba 的 agree API。
Package agree 实现 aiotieba 的 agree API。
block
Package block 实现 aiotieba 的 block API。
Package block 实现 aiotieba 的 block API。
classdef
Package classdef 存放各 API 响应共用的数据模型。
Package classdef 存放各 API 响应共用的数据模型。
del_bawu
Package delbawu 实现 aiotieba 的 del_bawu API。
Package delbawu 实现 aiotieba 的 del_bawu API。
del_bawu_blacklist
Package delbawublacklist 实现 aiotieba 的 del_bawu_blacklist API。
Package delbawublacklist 实现 aiotieba 的 del_bawu_blacklist API。
del_blacklist_old
Package delblacklistold 实现 aiotieba 的 del_blacklist_old API。
Package delblacklistold 实现 aiotieba 的 del_blacklist_old API。
del_post
Package delpost 实现 aiotieba 的 del_post API。
Package delpost 实现 aiotieba 的 del_post API。
del_posts
Package delposts 实现 aiotieba 的 del_posts API。
Package delposts 实现 aiotieba 的 del_posts API。
del_thread
Package delthread 实现 aiotieba 的 del_thread API。
Package delthread 实现 aiotieba 的 del_thread API。
del_threads
Package delthreads 实现 aiotieba 的 del_threads API。
Package delthreads 实现 aiotieba 的 del_threads API。
dislike_forum
Package dislikeforum 实现 aiotieba 的 dislike_forum API。
Package dislikeforum 实现 aiotieba 的 dislike_forum API。
follow_forum
Package followforum 实现 aiotieba 的 follow_forum API。
Package followforum 实现 aiotieba 的 follow_forum API。
follow_user
Package followuser 实现 aiotieba 的 follow_user API。
Package followuser 实现 aiotieba 的 follow_user API。
get_ats
Package getats 实现 aiotieba 的 get_ats API。
Package getats 实现 aiotieba 的 get_ats API。
get_bawu_blacklist
Package getbawublacklist 实现 aiotieba 的 get_bawu_blacklist API。
Package getbawublacklist 实现 aiotieba 的 get_bawu_blacklist API。
get_bawu_info
Package getbawuinfo 实现 aiotieba 的 get_bawu_info API。
Package getbawuinfo 实现 aiotieba 的 get_bawu_info API。
get_bawu_memberlist
Package getbawumemberlist 实现 aiotieba 的 get_bawu_memberlist API。
Package getbawumemberlist 实现 aiotieba 的 get_bawu_memberlist API。
get_bawu_perm
Package getbawuperm 实现 aiotieba 的 get_bawu_perm API。
Package getbawuperm 实现 aiotieba 的 get_bawu_perm API。
get_bawu_postlogs
Package getbawupostlogs 实现 aiotieba 的 get_bawu_postlogs API。
Package getbawupostlogs 实现 aiotieba 的 get_bawu_postlogs API。
get_bawu_userlogs
Package getbawuuserlogs 实现 aiotieba 的 get_bawu_userlogs API。
Package getbawuuserlogs 实现 aiotieba 的 get_bawu_userlogs API。
get_blacklist
Package getblacklist 实现 aiotieba 的 get_blacklist API。
Package getblacklist 实现 aiotieba 的 get_blacklist API。
get_blacklist_old
Package getblacklistold 实现 aiotieba 的 get_blacklist_old API。
Package getblacklistold 实现 aiotieba 的 get_blacklist_old API。
get_blocks
Package getblocks 实现 aiotieba 的 get_blocks API。
Package getblocks 实现 aiotieba 的 get_blocks API。
get_cid
Package getcid 实现 aiotieba 的 get_cid API。
Package getcid 实现 aiotieba 的 get_cid API。
get_comments
Package getcomments 实现 aiotieba 的 get_comments API。
Package getcomments 实现 aiotieba 的 get_comments API。
get_dislike_forums
Package getdislikeforums 实现 aiotieba 的 get_dislike_forums API。
Package getdislikeforums 实现 aiotieba 的 get_dislike_forums API。
get_fans
Package getfans 实现 aiotieba 的 get_fans API。
Package getfans 实现 aiotieba 的 get_fans API。
get_fid
Package getfid 实现 aiotieba 的 get_fid API。
Package getfid 实现 aiotieba 的 get_fid API。
get_follow_forums
Package getfollowforums 实现 aiotieba 的 get_follow_forums API。
Package getfollowforums 实现 aiotieba 的 get_follow_forums API。
get_follow_forums_pc
Package getfollowforumspc 实现 aiotieba 的 get_follow_forums_pc API。
Package getfollowforumspc 实现 aiotieba 的 get_follow_forums_pc API。
get_follows
Package getfollows 实现 aiotieba 的 get_follows API。
Package getfollows 实现 aiotieba 的 get_follows API。
get_forum
Package getforum 实现 aiotieba 的 get_forum API。
Package getforum 实现 aiotieba 的 get_forum API。
get_forum_detail
Package getforumdetail 实现 aiotieba 的 get_forum_detail API。
Package getforumdetail 实现 aiotieba 的 get_forum_detail API。
get_forum_level
Package getforumlevel 实现 aiotieba 的 get_forum_level API。
Package getforumlevel 实现 aiotieba 的 get_forum_level API。
get_group_msg
Package getgroupmsg 实现 aiotieba 的 get_group_msg API。
Package getgroupmsg 实现 aiotieba 的 get_group_msg API。
get_images
Package getimages 实现 aiotieba 的 get_images API。
Package getimages 实现 aiotieba 的 get_images API。
get_last_replyers
Package getlastreplyers 实现 aiotieba 的 get_last_replyers API。
Package getlastreplyers 实现 aiotieba 的 get_last_replyers API。
get_member_users
Package getmemberusers 实现 aiotieba 的 get_member_users API。
Package getmemberusers 实现 aiotieba 的 get_member_users API。
get_posts
Package getposts 实现 aiotieba 的 get_posts API。
Package getposts 实现 aiotieba 的 get_posts API。
get_rank_forums
Package getrankforums 实现 aiotieba 的 get_rank_forums API。
Package getrankforums 实现 aiotieba 的 get_rank_forums API。
get_rank_users
Package getrankusers 实现 aiotieba 的 get_rank_users API。
Package getrankusers 实现 aiotieba 的 get_rank_users API。
get_recom_status
Package getrecomstatus 实现 aiotieba 的 get_recom_status API。
Package getrecomstatus 实现 aiotieba 的 get_recom_status API。
get_recover_info
Package getrecoverinfo 实现 aiotieba 的 get_recover_info API。
Package getrecoverinfo 实现 aiotieba 的 get_recover_info API。
get_recovers
Package getrecovers 实现 aiotieba 的 get_recovers API。
Package getrecovers 实现 aiotieba 的 get_recovers API。
get_replys
Package getreplys 实现 aiotieba 的 get_replys API。
Package getreplys 实现 aiotieba 的 get_replys API。
get_roomlist_by_fid
Package getroomlistbyfid 实现 aiotieba 的 get_roomlist_by_fid API。
Package getroomlistbyfid 实现 aiotieba 的 get_roomlist_by_fid API。
get_self_follow_forums
Package getselffollowforums 实现 aiotieba 的 get_self_follow_forums API。
Package getselffollowforums 实现 aiotieba 的 get_self_follow_forums API。
get_selfinfo_initNickname
Package getselfinfoinitnickname 实现 aiotieba 的 get_selfinfo_initNickname API。
Package getselfinfoinitnickname 实现 aiotieba 的 get_selfinfo_initNickname API。
get_selfinfo_moindex
Package getselfinfomoindex 实现 aiotieba 的 get_selfinfo_moindex API。
Package getselfinfomoindex 实现 aiotieba 的 get_selfinfo_moindex API。
get_square_forums
Package getsquareforums 实现 aiotieba 的 get_square_forums API。
Package getsquareforums 实现 aiotieba 的 get_square_forums API。
get_statistics
Package getstatistics 实现 aiotieba 的 get_statistics API。
Package getstatistics 实现 aiotieba 的 get_statistics API。
get_tab_map
Package gettabmap 实现 aiotieba 的 get_tab_map API。
Package gettabmap 实现 aiotieba 的 get_tab_map API。
get_threads
Package getthreads 实现 aiotieba 的 get_threads API。
Package getthreads 实现 aiotieba 的 get_threads API。
get_uinfo_getUserInfo_web
Package getuserinfoweb 实现 aiotieba 的 get_uinfo_getUserInfo_web API。
Package getuserinfoweb 实现 aiotieba 的 get_uinfo_getUserInfo_web API。
get_uinfo_getuserinfo_app
Package getuserinfoapp 实现 aiotieba 的 get_uinfo_getuserinfo_app API。
Package getuserinfoapp 实现 aiotieba 的 get_uinfo_getuserinfo_app API。
get_uinfo_panel
Package getuinfopanel 实现 aiotieba 的 get_uinfo_panel API。
Package getuinfopanel 实现 aiotieba 的 get_uinfo_panel API。
get_uinfo_userCard
Package getuserinfousercard 实现 aiotieba 的 get_uinfo_userCard API。
Package getuserinfousercard 实现 aiotieba 的 get_uinfo_userCard API。
get_uinfo_user_json
Package getuserjson 实现 aiotieba 的 get_uinfo_user_json API。
Package getuserjson 实现 aiotieba 的 get_uinfo_user_json API。
get_unblock_appeals
Package getunblockappeals 实现 aiotieba 的 get_unblock_appeals API。
Package getunblockappeals 实现 aiotieba 的 get_unblock_appeals API。
get_user_contents
Package getusercontents 实现 aiotieba 的 get_user_contents API。
Package getusercontents 实现 aiotieba 的 get_user_contents API。
get_user_contents/get_posts
Package getusercontentsposts 实现 get_user_contents 的 get_posts 子 API。
Package getusercontentsposts 实现 get_user_contents 的 get_posts 子 API。
get_user_contents/get_threads
Package getusercontentsthreads 实现 get_user_contents 的 get_threads 子 API。
Package getusercontentsthreads 实现 get_user_contents 的 get_threads 子 API。
get_user_contents_pc
Package getusercontentpc 实现 aiotieba 的 get_user_contents_pc API。
Package getusercontentpc 实现 aiotieba 的 get_user_contents_pc API。
get_user_forum_info
Package getuserforuminfo 实现 aiotieba 的 get_user_forum_info API。
Package getuserforuminfo 实现 aiotieba 的 get_user_forum_info API。
good
Package good 实现 aiotieba 的 good API。
Package good 实现 aiotieba 的 good API。
handle_unblock_appeals
Package handleunblockappeals 实现 aiotieba 的 handle_unblock_appeals API。
Package handleunblockappeals 实现 aiotieba 的 handle_unblock_appeals API。
init_websocket
Package initwebsocket 实现 aiotieba 的 init_websocket API。
Package initwebsocket 实现 aiotieba 的 init_websocket API。
init_z_id
Package initzid 实现 aiotieba 的 init_z_id API。
Package initzid 实现 aiotieba 的 init_z_id API。
login
Package login 实现 aiotieba 的 login API。
Package login 实现 aiotieba 的 login API。
move
Package move 实现 aiotieba 的 move API。
Package move 实现 aiotieba 的 move API。
profile
Package profile 保存用户主页各接口共享的数据模型。
Package profile 保存用户主页各接口共享的数据模型。
profile/get_homepage
Package gethomepage 实现 aiotieba 的 profile.get_homepage API。
Package gethomepage 实现 aiotieba 的 profile.get_homepage API。
profile/get_uinfo_profile
Package getuinfoprofile 实现 aiotieba 的 profile.get_uinfo_profile API。
Package getuinfoprofile 实现 aiotieba 的 profile.get_uinfo_profile API。
push_notify
Package pushnotify 实现 aiotieba 的 push_notify API。
Package pushnotify 实现 aiotieba 的 push_notify API。
recommend
Package recommend 实现 aiotieba 的 recommend API。
Package recommend 实现 aiotieba 的 recommend API。
recover
Package recover 实现 aiotieba 的 recover API。
Package recover 实现 aiotieba 的 recover API。
remove_fan
Package removefan 实现 aiotieba 的 remove_fan API。
Package removefan 实现 aiotieba 的 remove_fan API。
search_exact
Package searchexact 实现 aiotieba 的 search_exact API。
Package searchexact 实现 aiotieba 的 search_exact API。
search_global
Package searchglobal 实现 aiotieba 的 search_global API。
Package searchglobal 实现 aiotieba 的 search_global API。
send_chatroom_msg
Package sendchatroommsg 实现 aiotieba 的 send_chatroom_msg API。
Package sendchatroommsg 实现 aiotieba 的 send_chatroom_msg API。
send_msg
Package sendmsg 实现 aiotieba 的 send_msg API。
Package sendmsg 实现 aiotieba 的 send_msg API。
set_bawu_perm
Package setbawuperm 实现 aiotieba 的 set_bawu_perm API。
Package setbawuperm 实现 aiotieba 的 set_bawu_perm API。
set_blacklist
Package setblacklist 实现 aiotieba 的 set_blacklist API。
Package setblacklist 实现 aiotieba 的 set_blacklist API。
set_msg_readed
Package setmsgreaded 实现 aiotieba 的 set_msg_readed API。
Package setmsgreaded 实现 aiotieba 的 set_msg_readed API。
set_nickname_old
Package setnicknameold 实现 aiotieba 的 set_nickname_old API。
Package setnicknameold 实现 aiotieba 的 set_nickname_old API。
set_profile
Package setprofile 实现 aiotieba 的 set_profile API。
Package setprofile 实现 aiotieba 的 set_profile API。
set_thread_privacy
Package setthreadprivacy 实现 aiotieba 的 set_thread_privacy API。
Package setthreadprivacy 实现 aiotieba 的 set_thread_privacy API。
share
Package share 实现 aiotieba 的 share API。
Package share 实现 aiotieba 的 share API。
sign_forum
Package signforum 实现 aiotieba 的 sign_forum API。
Package signforum 实现 aiotieba 的 sign_forum API。
sign_forums
Package signforums 实现 aiotieba 的 sign_forums API。
Package signforums 实现 aiotieba 的 sign_forums API。
sign_growth
Package signgrowth 实现 aiotieba 的 sign_growth API。
Package signgrowth 实现 aiotieba 的 sign_growth API。
sync
Package sync 实现 aiotieba 的 sync API。
Package sync 实现 aiotieba 的 sync API。
tieba_uid2user_info
Package tiebauid2userinfo 实现 aiotieba 的 tieba_uid2user_info API。
Package tiebauid2userinfo 实现 aiotieba 的 tieba_uid2user_info API。
top
Package top 实现 aiotieba 的 top API。
Package top 实现 aiotieba 的 top API。
unblock
Package unblock 实现 aiotieba 的 unblock API。
Package unblock 实现 aiotieba 的 unblock API。
undislike_forum
Package undislikeforum 实现 aiotieba 的 undislike_forum API。
Package undislikeforum 实现 aiotieba 的 undislike_forum API。
unfollow_forum
Package unfollowforum 实现 aiotieba 的 unfollow_forum API。
Package unfollowforum 实现 aiotieba 的 unfollow_forum API。
unfollow_user
Package unfollowuser 实现 aiotieba 的 unfollow_user API。
Package unfollowuser 实现 aiotieba 的 unfollow_user API。
ungood
Package ungood 实现 aiotieba 的 ungood API。
Package ungood 实现 aiotieba 的 ungood API。
Package config 定义客户端使用的代理与超时配置。
Package config 定义客户端使用的代理与超时配置。
Package consts 存放各贴吧 API 共用的版本号与基础域名。
Package consts 存放各贴吧 API 共用的版本号与基础域名。
Package core 实现客户端的网络层:账号状态容器、HTTP 会话、websocket 会话与 BLCP 会话。
Package core 实现客户端的网络层:账号状态容器、HTTP 会话、websocket 会话与 BLCP 会话。
Package enums 定义库中使用的枚举类型。
Package enums 定义库中使用的枚举类型。
Package exception 定义库中的异常与响应类型。
Package exception 定义库中的异常与响应类型。
Package helper 提供各 API 模块共用的内部工具。
Package helper 提供各 API 模块共用的内部工具。
crypto
Package crypto 实现百度贴吧客户端的密码学算法。
Package crypto 实现百度贴吧客户端的密码学算法。
htmlutil
Package htmlutil 提供论坛后端 HTML 抓取 API 所用 BeautifulSoup DOM 辅助函数的一个小子集。
Package htmlutil 提供论坛后端 HTML 抓取 API 所用 BeautifulSoup DOM 辅助函数的一个小子集。
Package logging 提供库的日志记录器。
Package logging 提供库的日志记录器。
tools
genproto command
Command genproto 为项目中每个 .proto 文件生成 Go protobuf 绑定。
Command genproto 为项目中每个 .proto 文件生成 Go protobuf 绑定。

Jump to

Keyboard shortcuts

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