跳转至

客户端

如何使用

aiotieba.Client是aiotieba的核心入口点 (Entry Point),其中封装了大量操作百度贴吧核心API的简便方法,你可以把它理解成一个“客户端”

我们推荐通过异步上下文管理器来使用Client,例如:

async with aiotieba.Client() as client:
    ...

Client

贴吧客户端

Parameters:

Name Type Description Default
BDUSS str

BDUSS. Defaults to ''.

''
STOKEN str

STOKEN. Defaults to ''.

''
account Account

Account实例 该字段会覆盖前两个参数. Defaults to None.

None
try_ws bool

尝试使用websocket接口. Defaults to False.

False
proxy bool | ProxyConfig

True则使用环境变量代理 False则禁用代理 输入ProxyConfig实例以手动配置代理. Defaults to False.

False
timeout TimeoutConfig

超时配置. Defaults to None.

None

init_websocket() async

初始化websocket

Returns:

Name Type Description
BoolResponse BoolResponse

True无须执行 False失败

get_self_info(require=ReqUInfo.ALL) async

获取本账号信息

Parameters:

Name Type Description Default
require ReqUInfo

指示需要获取的字段

ALL

Returns:

Name Type Description
TypeUserInfo UserInfo

用户信息

get_forum(fname_or_fid) async

通过forum_id获取贴吧信息 此接口较get_forum_detail更强大

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required

Returns:

Name Type Description
Forum Forum

贴吧信息

get_forum_detail(fname_or_fid) async

通过forum_id获取贴吧信息

Parameters:

Name Type Description Default
fname_or_fid str | int

目标贴吧名或fid 优先fid

required

Returns:

Name Type Description
Forum_detail Forum_detail

贴吧信息

get_fid(fname) async

通过贴吧名获取forum_id

Parameters:

Name Type Description Default
fname str

贴吧名

required

Returns:

Name Type Description
IntResponse IntResponse

forum_id

get_fname(fid) async

通过forum_id获取贴吧名

Parameters:

Name Type Description Default
fid int

forum_id

required

Returns:

Name Type Description
StrResponse StrResponse

贴吧名

get_threads(fname_or_fid, /, pn=1, *, rn=13, sort=ThreadSortType.REPLY, is_good=False) async

获取首页帖子

Parameters:

Name Type Description Default
fname_or_fid str | int

贴吧名或fid 优先贴吧名

required
pn int

页码. Defaults to 1.

1
rn int

请求的条目数. Defaults to 13. Max to 13.

13
sort ThreadSortType

HOT热门排序 REPLY按回复时间 CREATE按发布时间 FOLLOW关注的人. Defaults to ThreadSortType.REPLY.

REPLY
is_good bool

True则获取精品区帖子 False则获取普通区帖子. Defaults to False.

False

Returns:

Name Type Description
Threads Threads

帖子列表

get_posts(tid, /, pn=1, *, rn=30, sort=PostSortType.ASC, only_thread_author=False, with_comments=False, comment_sort_by_agree=True, comment_rn=4) async

获取主题帖内回复

Parameters:

Name Type Description Default
tid int

所在主题帖tid

required
pn int

页码. Defaults to 1.

1
rn int

请求的条目数. Defaults to 30.

30
sort PostSortType

ASC时间顺序 DESC时间倒序 HOT热门序. Defaults to PostSortType.ASC.

ASC
only_thread_author bool

True则只看楼主 False则请求全部. Defaults to False.

False
with_comments bool

True则同时请求高赞楼中楼 False则返回的Post.comments字段为空. Defaults to False.

False
comment_sort_by_agree bool

True则楼中楼按点赞数顺序 False则楼中楼按时间顺序. Defaults to True.

True
comment_rn int

请求的楼中楼数量. Defaults to 4. Max to 50.

4

Returns:

Name Type Description
Posts Posts

回复列表

get_comments(tid, pid, /, pn=1, *, is_comment=False) async

获取楼中楼回复

Parameters:

Name Type Description Default
tid int

所在主题帖tid

required
pid int

所在楼层的pid或楼中楼的pid

required
pn int

页码. Defaults to 1.

1
is_comment bool

pid是否指向楼中楼 若指向楼中楼则获取其附近的楼中楼列表. Defaults to False.

False

Returns:

Name Type Description
Comments Comments

楼中楼列表

search_exact(fname_or_fid, query, /, pn=1, *, rn=30, search_type=SearchType.ALL, only_thread=False) async

贴吧搜索

Parameters:

Name Type Description Default
fname_or_fid str | int

查询的贴吧名或fid 优先贴吧名

required
query str

查询文本

required
pn int

页码. Defaults to 1.

1
rn int

请求的条目数. Defaults to 30.

30
search_type SearchType

查询模式 默认查询全部. Defaults to SearchType.ALL.

ALL
only_thread bool

是否仅查询主题帖. Defaults to False.

False

Returns:

Name Type Description
ExactSearches ExactSearches

搜索结果列表

get_user_info(id_, /, require=ReqUInfo.ALL) async

获取用户信息

Parameters:

Name Type Description Default
id_ str | int

用户id user_id / portrait / user_name

required
require ReqUInfo

指示需要获取的字段

ALL

Returns:

Name Type Description
UserInfo UserInfo

用户信息

tieba_uid2user_info(tieba_uid) async

通过tieba_uid获取用户信息

Parameters:

Name Type Description Default
tieba_uid int

用户id tieba_uid

required

Returns:

Name Type Description
UserInfo_TUid UserInfo_TUid

包含较全面的用户信息

Note

请注意tieba_uid与旧版user_id的区别

get_homepage(id_, /, pn=1) async

获取用户个人页信息

Parameters:

Name Type Description Default
id_ str | int

用户id user_id / user_name / portrait 优先user_id

required
pn int

页码. Defaults to 1.

1

Returns:

Name Type Description
Homepage Homepage

用户个人页信息

get_follows(id_=None, /, pn=1) async

获取关注列表

Parameters:

Name Type Description Default
pn int

页码. Defaults to 1.

1
id_ str | int | None

用户id user_id / user_name / portrait 优先user_id 默认为None即获取本账号信息. Defaults to None.

None

Returns:

Name Type Description
Follows Follows

关注列表

get_fans(id_=None, /, pn=1) async

获取粉丝列表

Parameters:

Name Type Description Default
pn int

页码. Defaults to 1.

1
id_ str | int | None

用户id user_id / user_name / portrait 优先user_id 默认为None即获取本账号信息. Defaults to None.

None

Returns:

Name Type Description
Fans Fans

粉丝列表

get_blacklist() async

获取新版用户黑名单列表

Returns:

Name Type Description
BlacklistUsers BlacklistUsers

新版用户黑名单列表

get_blacklist_old(pn=1, /, *, rn=10) async

获取旧版用户黑名单列表

Parameters:

Name Type Description Default
pn int

页码. Defaults to 1.

1
rn int

请求的条目数. Defaults to 10. Max to Inf.

10

Returns:

Name Type Description
BlacklistOldUsers BlacklistOldUsers

旧版用户黑名单列表

get_follow_forums(id_, /, pn=1, *, rn=50) async

获取用户关注贴吧列表

Parameters:

Name Type Description Default
id_ str | int

用户id user_id / user_name / portrait 优先user_id

required
pn int

页码. Defaults to 1.

1
rn int

请求的条目数. Defaults to 50. Max to Inf.

50

Returns:

Name Type Description
FollowForums FollowForums

用户关注贴吧列表

get_self_follow_forums(pn=1, /, *, rn=100) async

获取本账号关注贴吧列表

Parameters:

Name Type Description Default
pn int

页码. Defaults to 1.

1
rn int

请求的条目数. Defaults to 100. Max to 200.

100

Returns:

Name Type Description
SelfFollowForums SelfFollowForums

本账号关注贴吧列表

get_self_follow_forums_v1(pn=1, /, *, rn=200) async

获取本账号关注贴吧列表(旧版接口/mg/o/getForumHome)

Parameters:

Name Type Description Default
pn int

页码. Defaults to 1.

1
rn int

请求的条目数. Defaults to 200. Max to 200.

200

Returns:

Name Type Description
SelfFollowForumsV1 SelfFollowForumsV1

本账号关注贴吧列表

Note

本接口需要STOKEN

get_dislike_forums(pn=1, /, *, rn=20) async

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

Parameters:

Name Type Description Default
pn int

页码. Defaults to 1.

1
rn int

请求的条目数. Defaults to 20. Max to 20.

20

Returns:

Name Type Description
DislikeForums DislikeForums

首页推荐屏蔽的贴吧列表

get_user_posts(id_=None, pn=1, *, rn=20) async

获取用户发布的回复列表

Parameters:

Name Type Description Default
id_ str | int | None

用户id user_id / user_name / portrait 优先user_id 默认为None即获取本账号信息. Defaults to None.

None
pn int

页码. Defaults to 1.

1
rn int

请求的条目数. Defaults to 20. Max to 50.

20

Returns:

Name Type Description
UserPostss UserPostss

回复列表

get_user_threads(id_=None, pn=1, *, public_only=False) async

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

Parameters:

Name Type Description Default
id_ str | int | None

用户id user_id / user_name / portrait 优先user_id 默认为None即获取本账号信息. Defaults to None.

None
pn int

页码. Defaults to 1.

1
public_only bool

是否仅获取公开主题帖 该选项在获取他人主题帖时无效. Defaults to False.

False

Returns:

Name Type Description
UserThreads UserThreads

主题帖列表

get_replys(pn=1) async

获取回复信息

Parameters:

Name Type Description Default
pn int

页码. Defaults to 1.

1

Returns:

Name Type Description
Replys Replys

回复列表

get_ats(pn=1) async

获取@信息

Parameters:

Name Type Description Default
pn int

页码. Defaults to 1.

1

Returns:

Name Type Description
Ats Ats

at列表

get_image_bytes(img_url) async

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

Parameters:

Name Type Description Default
img_url str

图像链接

required

Returns:

Name Type Description
ImageBytes ImageBytes

未解码的原始字节流

get_image(img_url) async

从链接获取静态图像

Parameters:

Name Type Description Default
img_url str

图像链接

required

Returns:

Name Type Description
Image Image

图像

hash2image(raw_hash, /, size='s') async

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

Parameters:

Name Type Description Default
raw_hash str

百度图库hash

required
size Literal['s', 'm', 'l']

获取图像的大小 s为宽720 m为宽960 l为原图. Defaults to 's'.

's'

Returns:

Name Type Description
Image Image

图像

get_portrait(id_, /, size='s') async

获取用户头像

Parameters:

Name Type Description Default
id_ str | int

用户id user_id / user_name / portrait 优先portrait

required
size Literal['s', 'm', 'l']

获取头像的大小 s为55x55 m为110x110 l为原图. Defaults to 's'.

's'

Returns:

Name Type Description
Image Image

头像

get_square_forums(cname, /, pn=1, *, rn=20) async

获取吧广场列表

Parameters:

Name Type Description Default
cname str

类别名

required
pn int

页码. Defaults to 1.

1
rn int

请求的条目数. Defaults to 20. Max to Inf.

20

Returns:

Name Type Description
SquareForums SquareForums

吧广场列表

get_bawu_info(fname_or_fid) async

获取吧务团队信息

Parameters:

Name Type Description Default
fname_or_fid str | int

目标贴吧名或fid 优先fid

required

Returns:

Name Type Description
BawuInfo BawuInfo

吧务团队信息

add_bawu(fname_or_fid, /, id_, *, bawu_type=BawuType.MANAGER) async

添加吧务

Parameters:

Name Type Description Default
fname_or_fid str | int

目标贴吧名或fid 优先fid

required
id_ str | int

用户id user_id / user_name / portrait 优先user_name

required
bawu_type BawuType

吧务类型. Defaults to BawuType.MANAGER.

MANAGER

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

del_bawu(fname_or_fid, /, id_, *, bawu_type=BawuType.MANAGER) async

删除吧务

Parameters:

Name Type Description Default
fname_or_fid str | int

目标贴吧名或fid 优先fid

required
id_ str | int

用户id user_id / user_name / portrait 优先portrait

required
bawu_type BawuType

吧务类型. Defaults to BawuType.MANAGER.

MANAGER

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

get_bawu_perm(fname_or_fid, /, id_) async

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

Parameters:

Name Type Description Default
fname_or_fid str | int

目标贴吧名或fid 优先fid

required
id_ str | int

用户id user_id / user_name / portrait 优先portrait

required

Returns:

Name Type Description
BawuPerm BawuPerm

吧务已分配的权限

set_bawu_perm(fname_or_fid, /, id_, *, perms=BawuPermType.NULL) async

为指定吧务分配权限

Parameters:

Name Type Description Default
fname_or_fid str | int

目标贴吧名或fid 优先fid

required
id_ str | int

用户id user_id / user_name / portrait 优先portrait

required
perms BawuPermType

待分配的权限. Defaults to BawuPermType.NULL.

NULL

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

get_tab_map(fname_or_fid) async

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

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required

Returns:

Name Type Description
TabMap TabMap

分区名到分区id的映射

get_rank_users(fname_or_fid, /, pn=1) async

获取pn页的等级排行榜用户列表

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required
pn int

页码. Defaults to 1.

1

Returns:

Name Type Description
RankUsers RankUsers

等级排行榜用户列表

get_member_users(fname_or_fid, /, pn=1) async

获取pn页的最新关注用户列表

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required
pn int

页码. Defaults to 1.

1

Returns:

Name Type Description
MemberUsers MemberUsers

最新关注用户列表

Note

本接口需要STOKEN

get_rank_forums(fname_or_fid, /, pn=1, *, rank_type=RankForumType.WEEKLY) async

获取pn页的吧签到排行表

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required
pn int

页码. Defaults to 1.

1
rank_type RankForumType

榜单类型 默认为周榜. Defaults to RankForumType.WEEKLY.

WEEKLY

Returns:

Name Type Description
RankForums RankForums

吧签到排行表

get_blocks(fname_or_fid, /, name='', pn=1) async

获取pn页的待解封用户列表

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required
name str

通过被封禁用户的用户名/昵称查询 默认为空即查询全部. Defaults to ''.

''
pn int

页码. Defaults to 1.

1

Returns:

Name Type Description
Blocks Blocks

待解封用户列表

get_recovers(fname_or_fid, /, pn=1, *, rn=10, id_=None) async

获取pn页的待恢复帖子列表

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required
pn int

页码. Defaults to 1.

1
rn int

请求的条目数. Defaults to 10. Max to 50.

10
id_ str | int

用于查询的被删帖用户的id user_id / user_name / portrait 优先user_id. Defaults to None.

None

Returns:

Name Type Description
Recovers Recovers

待恢复帖子列表

get_recover_info(fname_or_fid, tid) async

获取单个待恢复帖子信息

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required
tid int

主题帖id

required

Returns:

Name Type Description
RecoverThread RecoverThread

待恢复帖子信息

Note

本接口需要有目标贴吧的吧务身份

get_bawu_userlogs(fname_or_fid, /, pn=1, *, search_value='', search_type=BawuSearchType.USER, start_dt=None, end_dt=None, op_type=0) async

获取吧务用户管理日志表

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required
pn int

页码. Defaults to 1.

1
search_value str

搜索关键字. Defaults to ''.

''
search_type BawuSearchType

搜索类型. Defaults to BawuSearchType.USER.

USER
start_dt datetime

搜索的起始时间(含). Defaults to None.

None
end_dt datetime

搜索的结束时间(含). Defaults to None.

None
op_type int

搜索操作类型. Defaults to 0.

0

Returns:

Name Type Description
Userlogs Userlogs

吧务用户管理日志表

Note

本接口需要STOKEN

get_bawu_postlogs(fname_or_fid, /, pn=1, *, search_value='', search_type=BawuSearchType.USER, start_dt=None, end_dt=None, op_type=0) async

获取吧务帖子管理日志表

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required
pn int

页码. Defaults to 1.

1
search_value str

搜索关键字. Defaults to ''.

''
search_type BawuSearchType

搜索类型. Defaults to BawuSearchType.USER.

USER
start_dt datetime

搜索的起始时间(含). Defaults to None.

None
end_dt datetime

搜索的结束时间(含). Defaults to None.

None
op_type int

搜索操作类型. Defaults to 0.

0

Returns:

Name Type Description
Postlogs Postlogs

吧务帖子管理日志表

Note

本接口需要STOKEN

get_unblock_appeals(fname_or_fid, /, pn=1, *, rn=5) async

获取申诉请求列表

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required
pn int

页码. Defaults to 1.

1
rn int

请求的条目数. Defaults to 5. Max to 50.

5

Returns:

Name Type Description
Appeals Appeals

申诉请求列表

get_bawu_blacklist(fname_or_fid, /, pn=1) async

获取pn页的吧务黑名单列表

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required
pn int

页码. Defaults to 1.

1

Returns:

Name Type Description
BlacklistUsers BawuBlacklistUsers

吧务黑名单列表

Note

本接口需要STOKEN

get_statistics(fname_or_fid) async

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

Parameters:

Name Type Description Default
fname_or_fid str | int

目标贴吧名或fid 优先fid

required

Returns:

Name Type Description
Statistics Statistics

吧务后台统计信息

get_recom_status(fname_or_fid) async

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

Parameters:

Name Type Description Default
fname_or_fid str | int

目标贴吧名或fid 优先fid

required

Returns:

Name Type Description
RecomStatus RecomStatus

大吧主推荐功能的月度配额状态

block(fname_or_fid, /, id_, *, day=1, reason='') async

封禁用户

Parameters:

Name Type Description Default
fname_or_fid str | int

所在贴吧的贴吧名或fid 优先fid

required
id_ str | int

用户id user_id / user_name / portrait 优先portrait

required
day int

封禁天数. Defaults to 1.

1
reason str

封禁理由. Defaults to ''.

''

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

unblock(fname_or_fid, /, id_) async

解封用户

Parameters:

Name Type Description Default
fname_or_fid str | int

所在贴吧的贴吧名或fid 优先fid

required
id_ str | int

用户id user_id / user_name / portrait 优先user_id

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

add_bawu_blacklist(fname_or_fid, /, id_) async

添加贴吧黑名单

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required
id_ str | int

用户id user_id / user_name / portrait 优先user_id

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

del_bawu_blacklist(fname_or_fid, /, id_) async

移出贴吧黑名单

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required
id_ str | int

用户id user_id / user_name / portrait 优先user_id

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

hide_thread(fname_or_fid, /, tid) async

屏蔽主题帖

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid 优先fid

required
tid int

待屏蔽的主题帖tid

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

del_thread(fname_or_fid, /, tid) async

删除主题帖

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid 优先fid

required
tid int

待删除的主题帖tid

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

del_threads(fname_or_fid, /, tids, *, block=False) async

批量删除主题帖

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid 优先fid

required
tids list[int]

待删除的主题帖tid列表. Length Max to 30.

required
block bool

是否同时封一天. Defaults to False.

False

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败 部分成功返回True

del_post(fname_or_fid, /, tid, pid) async

删除回复

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid 优先fid

required
tid int

所在主题帖tid

required
pid int

待删除的回复pid

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

del_posts(fname_or_fid, /, tid, pids, *, block=False) async

批量删除回复

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid 优先fid

required
tid int

所在主题帖tid

required
pids list[int]

待删除的回复pid列表. Length Max to 30.

required
block bool

是否同时封一天. Defaults to False.

False

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败 部分成功返回True

unhide_thread(fname_or_fid, /, tid) async

解除主题帖屏蔽

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid 优先fid

required
tid int

待解除屏蔽的主题帖tid

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

recover_thread(fname_or_fid, /, tid) async

恢复主题帖

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid 优先fid

required
tid int

待恢复的主题帖tid

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

recover_post(fname_or_fid, /, pid) async

恢复主题帖

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid 优先fid

required
pid int

待恢复的回复pid

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

recover(fname_or_fid, /, tid=0, pid=0, *, is_hide=False) async

帖子恢复相关操作

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid 优先fid

required
tid int

待恢复的主题帖tid. Defaults to 0.

0
pid int

待恢复的回复pid. Defaults to 0.

0
is_hide bool

True则取消屏蔽主题帖 False则恢复删帖. Defaults to False.

False

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

good(fname_or_fid, /, tid, *, cname='') async

加精主题帖

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid

required
tid int

待加精的主题帖tid

required
cname str

待添加的精华分区名称 默认为''即不分区. Defaults to ''.

''

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

ungood(fname_or_fid, /, tid) async

撤精主题帖

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid

required
tid int

待撤精的主题帖tid

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

get_cid(fname_or_fid, /, cname='') async

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

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid

required
cname str

精华分区名. Defaults to ''.

''

Returns:

Name Type Description
IntResponse IntResponse

精华分区id

top(fname_or_fid, /, tid, *, is_vip=False) async

置顶主题帖

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid

required
tid int

待置顶的主题帖tid

required
is_vip bool

是否会员置顶. Defaults to False.

False

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

untop(fname_or_fid, /, tid, *, is_vip=False) async

撤销置顶主题帖

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid

required
tid int

待撤销置顶的主题帖tid

required
is_vip bool

是否会员置顶. Defaults to False.

False

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

move(fname_or_fid, /, tid, *, to_tab_id, from_tab_id=0) async

将主题帖移动至另一分区

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid 优先fid

required
tid int

待移动的主题帖tid

required
to_tab_id int

目标分区id

required
from_tab_id int

来源分区id 默认为0即无分区. Defaults to 0.

0

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

recommend(fname_or_fid, /, tid) async

大吧主首页推荐

Parameters:

Name Type Description Default
fname_or_fid str | int

帖子所在贴吧的贴吧名或fid 优先fid

required
tid int

待推荐的主题帖tid

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

handle_unblock_appeals(fname_or_fid, /, appeal_ids, *, refuse=True) async

拒绝或通过解封申诉

Parameters:

Name Type Description Default
fname_or_fid str | int

申诉所在贴吧的贴吧名或fid 优先fid

required
appeal_ids list[int]

申诉请求的appeal_id列表. Length Max to 30.

required
refuse bool

True则拒绝申诉 False则接受申诉. Defaults to True.

True

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

agree(tid, pid=0, is_comment=False) async

点赞主题帖或回复

Parameters:

Name Type Description Default
tid int

待点赞的主题帖或回复所在的主题帖的tid

required
pid int

待点赞的回复pid. Defaults to 0.

0
is_comment bool

pid是否指向楼中楼. Defaults to False.

False

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

Note

本接口仍处于测试阶段

高频率调用会导致<发帖秒删>! 请谨慎使用!

unagree(tid, pid=0, is_comment=False) async

取消点赞主题帖或回复

Parameters:

Name Type Description Default
tid int

待取消点赞的主题帖或回复所在的主题帖的tid

required
pid int

待取消点赞的回复pid. Defaults to 0.

0
is_comment bool

pid是否指向楼中楼. Defaults to False.

False

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

disagree(tid, pid=0, is_comment=False) async

点踩主题帖或回复

Parameters:

Name Type Description Default
tid int

待点踩的主题帖或回复所在的主题帖的tid

required
pid int

待点踩的回复pid. Defaults to 0.

0
is_comment bool

pid是否指向楼中楼. Defaults to False.

False

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

undisagree(tid, pid=0, is_comment=False) async

取消点踩主题帖或回复

Parameters:

Name Type Description Default
tid int

待取消点踩的主题帖或回复所在的主题帖的tid

required
pid int

待取消点踩的回复pid. Defaults to 0.

0
is_comment bool

pid是否指向楼中楼. Defaults to False.

False

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

agree_vimage(id_) async

虚拟形象点赞

Parameters:

Name Type Description Default
id_ str | int

点赞对象的用户id user_id / user_name / portrait 优先user_id

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

follow_user(id_) async

关注用户

Parameters:

Name Type Description Default
id_ str | int

用户id user_id / user_name / portrait 优先portrait

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

unfollow_user(id_) async

取关用户

Parameters:

Name Type Description Default
id_ str | int

用户id user_id / user_name / portrait 优先portrait

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

remove_fan(id_) async

移除粉丝

Parameters:

Name Type Description Default
id_ str | int

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

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

set_blacklist(id_, *, btype=BlacklistType.ALL) async

设置新版用户黑名单

Parameters:

Name Type Description Default
id_ str | int

待设置黑名单的用户id user_id / user_name / portrait 优先user_id

required
btype BlacklistType

黑名单类型. 默认全屏蔽. Defaults to BlacklistType.ALL.

ALL

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

add_blacklist_old(id_) async

添加旧版用户黑名单

Parameters:

Name Type Description Default
id_ str | int

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

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

del_blacklist_old(id_) async

移除旧版用户黑名单

Parameters:

Name Type Description Default
id_ str | int

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

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

follow_forum(fname_or_fid) async

关注贴吧

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

unfollow_forum(fname_or_fid) async

取关贴吧

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

dislike_forum(fname_or_fid) async

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

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

undislike_forum(fname_or_fid) async

解除贴吧的首页推荐屏蔽

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

set_thread_private(fname_or_fid, /, tid, pid) async

隐藏主题帖

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required
tid int

主题帖tid

required
tid int

主题帖pid

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

set_thread_public(fname_or_fid, /, tid, pid) async

公开主题帖

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required
tid int

主题帖tid

required
tid int

主题帖pid

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

set_profile(nick_name, sign='', gender=Gender.UNKNOWN) async

设置主页信息

Parameters:

Name Type Description Default
nick_name str

昵称

required
sign str

个性签名. Defaults to ''.

''
gender Gender

性别. Defaults to Gender.UNKNOWN.

UNKNOWN

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

set_nickname_old(nick_name) async

设置旧版昵称

Parameters:

Name Type Description Default
nick_name str

昵称

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

sign_forum(fname_or_fid) async

单个贴吧签到

Parameters:

Name Type Description Default
fname_or_fid str | int

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

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

sign_growth() async

用户成长等级任务: 签到

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

sign_growth_share() async

用户成长等级任务: 分享主题帖

Returns:

Name Type Description
bool BoolResponse

True成功 False失败

add_post(fname_or_fid, /, tid, content) async

回复主题帖

Parameters:

Name Type Description Default
fname_or_fid str | int

要回复的主题帖所在贴吧的贴吧名或fid

required
tid int

要回复的主题帖的tid

required
content str

回复内容

required

Returns:

Name Type Description
BoolResponse BoolResponse

回帖是否成功

Note

本接口仍处于测试阶段

高频率调用会导致<永久封禁屏蔽>! 请谨慎使用!

send_msg(id_, content) async

发送私信

Parameters:

Name Type Description Default
id_ str | int

用户id user_id / user_name / portrait 优先user_id

required
content str

发送内容

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

set_msg_readed(message) async

将一条私信设为已读

Parameters:

Name Type Description Default
message WsMessage

websocket私信消息

required

Returns:

Name Type Description
BoolResponse BoolResponse

True成功 False失败

get_group_msg(group_ids, *, get_type=1) async

获取分组信息

Parameters:

Name Type Description Default
group_ids list[int]

待获取分组的group_id

required
get_type int

获取类型. Defaults to 1.

1

Returns:

Name Type Description
WsMsgGroups WsMsgGroups

websocket消息组列表