From ea4ec8f4b531f45117c4eb4d66d2fa6b7ed9964f Mon Sep 17 00:00:00 2001 From: lumina37 Date: Thu, 19 Dec 2024 10:04:56 +0800 Subject: [PATCH] feat: remove the deprecated virtual image --- aiotieba/api/_classdef/__init__.py | 1 - aiotieba/api/_classdef/user.py | 3 --- aiotieba/api/_protobuf/User.proto | 8 ------ aiotieba/api/_protobuf/User_pb2.py | 36 ++++++++++++--------------- aiotieba/api/agree_vimage/__init__.py | 1 - aiotieba/api/agree_vimage/_api.py | 30 ---------------------- aiotieba/api/get_posts/_classdef.py | 7 +----- aiotieba/api/get_threads/_classdef.py | 7 +----- aiotieba/api/profile/_classdef.py | 29 --------------------- 9 files changed, 18 insertions(+), 104 deletions(-) delete mode 100644 aiotieba/api/agree_vimage/__init__.py delete mode 100644 aiotieba/api/agree_vimage/_api.py diff --git a/aiotieba/api/_classdef/__init__.py b/aiotieba/api/_classdef/__init__.py index 006c9bfd..a55c31e0 100644 --- a/aiotieba/api/_classdef/__init__.py +++ b/aiotieba/api/_classdef/__init__.py @@ -19,5 +19,4 @@ TypeFragTiebaPlus, ) from .user import UserInfo -from .vimage import VirtualImage from .vote import VoteInfo diff --git a/aiotieba/api/_classdef/user.py b/aiotieba/api/_classdef/user.py index a341fe15..4d6ac385 100644 --- a/aiotieba/api/_classdef/user.py +++ b/aiotieba/api/_classdef/user.py @@ -3,7 +3,6 @@ import dataclasses as dcs from ...enums import Gender, PrivLike, PrivReply -from .vimage import VirtualImage @dcs.dataclass @@ -30,7 +29,6 @@ class UserInfo: sign (str): 个性签名 ip (str): ip归属地 icons (list[str]): 印记信息 - vimage (VirtualImage_pf): 虚拟形象信息 is_vip (bool): 是否超级会员 is_god (bool): 是否大神 @@ -61,7 +59,6 @@ class UserInfo: sign: str = "" ip: str = '' icons: list[str] = dcs.field(default_factory=list) - vimage: VirtualImage = dcs.field(default_factory=VirtualImage) is_vip: bool = False is_god: bool = False diff --git a/aiotieba/api/_protobuf/User.proto b/aiotieba/api/_protobuf/User.proto index 98977e59..b3ab68dc 100644 --- a/aiotieba/api/_protobuf/User.proto +++ b/aiotieba/api/_protobuf/User.proto @@ -61,14 +61,6 @@ message User { int32 is_default_avatar = 106; string tieba_uid = 120; string ip_address = 127; - message VirtualImageInfo { - int32 isset_virtual_image = 1; - message StateInfo { - string text = 2; - } - StateInfo personal_state = 9; - } - VirtualImageInfo virtual_image_info = 136; message UserGrowth { uint32 level_id = 1; } diff --git a/aiotieba/api/_protobuf/User_pb2.py b/aiotieba/api/_protobuf/User_pb2.py index 41d975f1..78b8bc7e 100644 --- a/aiotieba/api/_protobuf/User_pb2.py +++ b/aiotieba/api/_protobuf/User_pb2.py @@ -9,7 +9,7 @@ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n\nUser.proto"\x92\n\n\x04User\x12\n\n\x02id\x18\x02 \x01(\x03\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x11\n\tname_show\x18\x04 \x01(\t\x12\x10\n\x08portrait\x18\x05 \x01(\t\x12\x1c\n\x08iconinfo\x18\x11 \x03(\x0b\x32\n.User.Icon\x12\x13\n\x0bis_coreuser\x18\x14 \x01(\x05\x12\x10\n\x08level_id\x18\x17 \x01(\x05\x12\x0f\n\x07is_bawu\x18\x19 \x01(\x05\x12\x11\n\tbawu_type\x18\x1a \x01(\t\x12\r\n\x05\x42\x44USS\x18\x1d \x01(\t\x12\x10\n\x08\x66\x61ns_num\x18\x1e \x01(\x05\x12\x13\n\x0b\x63oncern_num\x18\x1f \x01(\x05\x12\x0b\n\x03sex\x18 \x01(\x05\x12\x13\n\x0bmy_like_num\x18! \x01(\x05\x12\r\n\x05intro\x18" \x01(\t\x12\x10\n\x08post_num\x18% \x01(\x05\x12\x0e\n\x06tb_age\x18& \x01(\t\x12\x0e\n\x06gender\x18* \x01(\x05\x12!\n\tpriv_sets\x18- \x01(\x0b\x32\x0e.User.PrivSets\x12\x11\n\tis_friend\x18. \x01(\x05\x12&\n\tlikeForum\x18/ \x03(\x0b\x32\x13.User.LikeForumInfo\x12\x13\n\x0bis_guanfang\x18\x34 \x01(\x05\x12"\n\x07vipInfo\x18= \x01(\x0b\x32\x11.User.UserVipInfo\x12\'\n\x0enew_tshow_icon\x18\x41 \x03(\x0b\x32\x0f.User.TshowInfo\x12\x0f\n\x07is_fans\x18[ \x01(\x05\x12&\n\x0cnew_god_data\x18\x65 \x01(\x0b\x32\x10.User.NewGodInfo\x12\x19\n\x11is_default_avatar\x18j \x01(\x05\x12\x11\n\ttieba_uid\x18x \x01(\t\x12\x12\n\nip_address\x18\x7f \x01(\t\x12\x33\n\x12virtual_image_info\x18\x88\x01 \x01(\x0b\x32\x16.User.VirtualImageInfo\x12&\n\x0buser_growth\x18\x89\x01 \x01(\x0b\x32\x10.User.UserGrowth\x1a\x14\n\x04Icon\x12\x0c\n\x04name\x18\x01 \x01(\t\x1a\xab\x01\n\x08PrivSets\x12\x10\n\x08location\x18\x01 \x01(\x05\x12\x0c\n\x04like\x18\x02 \x01(\x05\x12\r\n\x05group\x18\x03 \x01(\x05\x12\x0c\n\x04post\x18\x04 \x01(\x05\x12\x0e\n\x06\x66riend\x18\x05 \x01(\x05\x12\x0c\n\x04live\x18\x06 \x01(\x05\x12\r\n\x05reply\x18\x07 \x01(\x05\x12\x19\n\x11\x62\x61zhu_show_inside\x18\x08 \x01(\x05\x12\x1a\n\x12\x62\x61zhu_show_outside\x18\t \x01(\x05\x1a\x35\n\rLikeForumInfo\x12\x12\n\nforum_name\x18\x01 \x01(\t\x12\x10\n\x08\x66orum_id\x18\x02 \x01(\x04\x1a\x30\n\x0bUserVipInfo\x12\x10\n\x08v_status\x18\x01 \x01(\r\x12\x0f\n\x07v_level\x18\x05 \x01(\r\x1a\x19\n\tTshowInfo\x12\x0c\n\x04name\x18\x02 \x01(\t\x1a\x42\n\nNewGodInfo\x12\x0e\n\x06status\x18\x01 \x01(\x05\x12\x10\n\x08\x66ield_id\x18\x02 \x01(\r\x12\x12\n\nfield_name\x18\x03 \x01(\t\x1a\x84\x01\n\x10VirtualImageInfo\x12\x1b\n\x13isset_virtual_image\x18\x01 \x01(\x05\x12\x38\n\x0epersonal_state\x18\t \x01(\x0b\x32 .User.VirtualImageInfo.StateInfo\x1a\x19\n\tStateInfo\x12\x0c\n\x04text\x18\x02 \x01(\t\x1a\x1e\n\nUserGrowth\x12\x10\n\x08level_id\x18\x01 \x01(\rb\x06proto3' + b'\n\nUser.proto"\xd6\x08\n\x04User\x12\n\n\x02id\x18\x02 \x01(\x03\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x11\n\tname_show\x18\x04 \x01(\t\x12\x10\n\x08portrait\x18\x05 \x01(\t\x12\x1c\n\x08iconinfo\x18\x11 \x03(\x0b\x32\n.User.Icon\x12\x13\n\x0bis_coreuser\x18\x14 \x01(\x05\x12\x10\n\x08level_id\x18\x17 \x01(\x05\x12\x0f\n\x07is_bawu\x18\x19 \x01(\x05\x12\x11\n\tbawu_type\x18\x1a \x01(\t\x12\r\n\x05\x42\x44USS\x18\x1d \x01(\t\x12\x10\n\x08\x66\x61ns_num\x18\x1e \x01(\x05\x12\x13\n\x0b\x63oncern_num\x18\x1f \x01(\x05\x12\x0b\n\x03sex\x18 \x01(\x05\x12\x13\n\x0bmy_like_num\x18! \x01(\x05\x12\r\n\x05intro\x18" \x01(\t\x12\x10\n\x08post_num\x18% \x01(\x05\x12\x0e\n\x06tb_age\x18& \x01(\t\x12\x0e\n\x06gender\x18* \x01(\x05\x12!\n\tpriv_sets\x18- \x01(\x0b\x32\x0e.User.PrivSets\x12\x11\n\tis_friend\x18. \x01(\x05\x12&\n\tlikeForum\x18/ \x03(\x0b\x32\x13.User.LikeForumInfo\x12\x13\n\x0bis_guanfang\x18\x34 \x01(\x05\x12"\n\x07vipInfo\x18= \x01(\x0b\x32\x11.User.UserVipInfo\x12\'\n\x0enew_tshow_icon\x18\x41 \x03(\x0b\x32\x0f.User.TshowInfo\x12\x0f\n\x07is_fans\x18[ \x01(\x05\x12&\n\x0cnew_god_data\x18\x65 \x01(\x0b\x32\x10.User.NewGodInfo\x12\x19\n\x11is_default_avatar\x18j \x01(\x05\x12\x11\n\ttieba_uid\x18x \x01(\t\x12\x12\n\nip_address\x18\x7f \x01(\t\x12&\n\x0buser_growth\x18\x89\x01 \x01(\x0b\x32\x10.User.UserGrowth\x1a\x14\n\x04Icon\x12\x0c\n\x04name\x18\x01 \x01(\t\x1a\xab\x01\n\x08PrivSets\x12\x10\n\x08location\x18\x01 \x01(\x05\x12\x0c\n\x04like\x18\x02 \x01(\x05\x12\r\n\x05group\x18\x03 \x01(\x05\x12\x0c\n\x04post\x18\x04 \x01(\x05\x12\x0e\n\x06\x66riend\x18\x05 \x01(\x05\x12\x0c\n\x04live\x18\x06 \x01(\x05\x12\r\n\x05reply\x18\x07 \x01(\x05\x12\x19\n\x11\x62\x61zhu_show_inside\x18\x08 \x01(\x05\x12\x1a\n\x12\x62\x61zhu_show_outside\x18\t \x01(\x05\x1a\x35\n\rLikeForumInfo\x12\x12\n\nforum_name\x18\x01 \x01(\t\x12\x10\n\x08\x66orum_id\x18\x02 \x01(\x04\x1a\x30\n\x0bUserVipInfo\x12\x10\n\x08v_status\x18\x01 \x01(\r\x12\x0f\n\x07v_level\x18\x05 \x01(\r\x1a\x19\n\tTshowInfo\x12\x0c\n\x04name\x18\x02 \x01(\t\x1a\x42\n\nNewGodInfo\x12\x0e\n\x06status\x18\x01 \x01(\x05\x12\x10\n\x08\x66ield_id\x18\x02 \x01(\r\x12\x12\n\nfield_name\x18\x03 \x01(\t\x1a\x1e\n\nUserGrowth\x12\x10\n\x08level_id\x18\x01 \x01(\rb\x06proto3' ) _globals = globals() @@ -18,22 +18,18 @@ if not _descriptor._USE_C_DESCRIPTORS: DESCRIPTOR._loaded_options = None _globals['_USER']._serialized_start = 15 - _globals['_USER']._serialized_end = 1313 - _globals['_USER_ICON']._serialized_start = 752 - _globals['_USER_ICON']._serialized_end = 772 - _globals['_USER_PRIVSETS']._serialized_start = 775 - _globals['_USER_PRIVSETS']._serialized_end = 946 - _globals['_USER_LIKEFORUMINFO']._serialized_start = 948 - _globals['_USER_LIKEFORUMINFO']._serialized_end = 1001 - _globals['_USER_USERVIPINFO']._serialized_start = 1003 - _globals['_USER_USERVIPINFO']._serialized_end = 1051 - _globals['_USER_TSHOWINFO']._serialized_start = 1053 - _globals['_USER_TSHOWINFO']._serialized_end = 1078 - _globals['_USER_NEWGODINFO']._serialized_start = 1080 - _globals['_USER_NEWGODINFO']._serialized_end = 1146 - _globals['_USER_VIRTUALIMAGEINFO']._serialized_start = 1149 - _globals['_USER_VIRTUALIMAGEINFO']._serialized_end = 1281 - _globals['_USER_VIRTUALIMAGEINFO_STATEINFO']._serialized_start = 1256 - _globals['_USER_VIRTUALIMAGEINFO_STATEINFO']._serialized_end = 1281 - _globals['_USER_USERGROWTH']._serialized_start = 1283 - _globals['_USER_USERGROWTH']._serialized_end = 1313 + _globals['_USER']._serialized_end = 1125 + _globals['_USER_ICON']._serialized_start = 699 + _globals['_USER_ICON']._serialized_end = 719 + _globals['_USER_PRIVSETS']._serialized_start = 722 + _globals['_USER_PRIVSETS']._serialized_end = 893 + _globals['_USER_LIKEFORUMINFO']._serialized_start = 895 + _globals['_USER_LIKEFORUMINFO']._serialized_end = 948 + _globals['_USER_USERVIPINFO']._serialized_start = 950 + _globals['_USER_USERVIPINFO']._serialized_end = 998 + _globals['_USER_TSHOWINFO']._serialized_start = 1000 + _globals['_USER_TSHOWINFO']._serialized_end = 1025 + _globals['_USER_NEWGODINFO']._serialized_start = 1027 + _globals['_USER_NEWGODINFO']._serialized_end = 1093 + _globals['_USER_USERGROWTH']._serialized_start = 1095 + _globals['_USER_USERGROWTH']._serialized_end = 1125 diff --git a/aiotieba/api/agree_vimage/__init__.py b/aiotieba/api/agree_vimage/__init__.py deleted file mode 100644 index 41972566..00000000 --- a/aiotieba/api/agree_vimage/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from ._api import parse_body, request diff --git a/aiotieba/api/agree_vimage/_api.py b/aiotieba/api/agree_vimage/_api.py deleted file mode 100644 index c09b8efa..00000000 --- a/aiotieba/api/agree_vimage/_api.py +++ /dev/null @@ -1,30 +0,0 @@ -import yarl - -from ...const import APP_BASE_HOST, APP_SECURE_SCHEME, MAIN_VERSION -from ...core import HttpCore -from ...exception import BoolResponse, TiebaServerError -from ...helper import parse_json - - -def parse_body(body: bytes) -> None: - res_json = parse_json(body) - if code := int(res_json['error_code']): - raise TiebaServerError(code, res_json['error_msg']) - - -async def request(http_core: HttpCore, user_id: int) -> BoolResponse: - data = [ - ('BDUSS', http_core.account.BDUSS), - ('_client_version', MAIN_VERSION), - ('agreed_user_id', user_id), - ('interactive_id', 1), - ] - - request = http_core.pack_form_request( - yarl.URL.build(scheme=APP_SECURE_SCHEME, host=APP_BASE_HOST, path="/c/c/agree/agreeVirtualImage"), data - ) - - body = await http_core.net_core.send_request(request, read_bufsize=1024) - parse_body(body) - - return BoolResponse() diff --git a/aiotieba/api/get_posts/_classdef.py b/aiotieba/api/get_posts/_classdef.py index 6d4bdb22..8e7d36d3 100644 --- a/aiotieba/api/get_posts/_classdef.py +++ b/aiotieba/api/get_posts/_classdef.py @@ -5,7 +5,7 @@ from ...enums import Gender, PrivLike, PrivReply from ...exception import TbErrorExt -from .._classdef import Containers, TypeMessage, VirtualImage, VoteInfo +from .._classdef import Containers, TypeMessage, VoteInfo from .._classdef.contents import ( _IMAGEHASH_EXP, FragAt, @@ -19,8 +19,6 @@ TypeFragText, ) -VirtualImage_p = VirtualImage - FragText_p = FragText_pt = FragText_pc = FragText FragEmoji_p = FragEmoji_pt = FragEmoji_pc = FragEmoji FragAt_p = FragAt_pt = FragAt_pc = FragAt @@ -513,7 +511,6 @@ class Post: pid (int): 回复id user (UserInfo_p): 发布者的用户信息 author_id (int): 发布者的user_id - vimage (VirtualImage_p): 虚拟形象信息 floor (int): 楼层数 reply_num (int): 楼中楼数 @@ -534,7 +531,6 @@ class Post: pid: int = 0 user: UserInfo_p = dcs.field(default_factory=UserInfo_p) author_id: int = 0 - vimage: VirtualImage_p = dcs.field(default_factory=VirtualImage_p) floor: int = 0 reply_num: int = 0 @@ -551,7 +547,6 @@ def from_tbdata(data_proto: TypeMessage) -> Post: is_aimeme = bool(data_proto.sprite_meme_info.meme_id) pid = data_proto.id author_id = data_proto.author_id - vimage = VirtualImage_p.from_tbdata(data_proto) floor = data_proto.floor reply_num = data_proto.sub_post_number agree = data_proto.agree.agree_num diff --git a/aiotieba/api/get_threads/_classdef.py b/aiotieba/api/get_threads/_classdef.py index f3abdfb6..6882e523 100644 --- a/aiotieba/api/get_threads/_classdef.py +++ b/aiotieba/api/get_threads/_classdef.py @@ -5,7 +5,7 @@ from ...enums import Gender, PrivLike, PrivReply from ...exception import TbErrorExt -from .._classdef import Containers, TypeMessage, VirtualImage, VoteInfo +from .._classdef import Containers, TypeMessage, VoteInfo from .._classdef.contents import ( _IMAGEHASH_EXP, FragAt, @@ -19,8 +19,6 @@ TypeFragText, ) -VirtualImage_t = VirtualImage - FragText_t = FragText_st = FragText FragEmoji_t = FragEmoji_st = FragEmoji FragAt_t = FragAt_st = FragAt @@ -538,7 +536,6 @@ class Thread: pid (int): 首楼回复pid user (UserInfo_t): 发布者的用户信息 author_id (int): 发布者的user_id - vimage (VirtualImage_t): 虚拟形象信息 type (int): 帖子类型 tab_id (int): 帖子所在分区id @@ -569,7 +566,6 @@ class Thread: pid: int = 0 user: UserInfo_t = dcs.field(default_factory=UserInfo_t) author_id: int = 0 - vimage: VirtualImage_t = dcs.field(default_factory=VirtualImage_t) type: int = 0 tab_id: int = 0 @@ -596,7 +592,6 @@ def from_tbdata(data_proto: TypeMessage) -> None: tid = data_proto.id pid = data_proto.first_post_id author_id = data_proto.author_id - vimage = VirtualImage_t.from_tbdata(data_proto) type_ = data_proto.thread_type tab_id = data_proto.tab_id is_good = bool(data_proto.is_good) diff --git a/aiotieba/api/profile/_classdef.py b/aiotieba/api/profile/_classdef.py index 3156bd17..22004162 100644 --- a/aiotieba/api/profile/_classdef.py +++ b/aiotieba/api/profile/_classdef.py @@ -26,32 +26,6 @@ FragVoice_pf = FragVoice -@dcs.dataclass -class VirtualImage_pf: - """ - 虚拟形象信息 - - Attributes: - enabled (bool): 是否启用虚拟形象 - state (str): 虚拟形象状态签名 - """ - - enabled: bool = False - state: str = "" - - @staticmethod - def from_tbdata(data_proto: TypeMessage) -> VirtualImage_pf: - enabled = bool(data_proto.isset_virtual_image) - state = data_proto.personal_state.text - return VirtualImage_pf(enabled, state) - - def __str__(self) -> str: - return self.state - - def __bool__(self) -> bool: - return self.enabled - - @dcs.dataclass class UserInfo_pf(TbErrorExt): """ @@ -77,7 +51,6 @@ class UserInfo_pf(TbErrorExt): sign (str): 个性签名 ip (str): ip归属地 icons (list[str]): 印记信息 - vimage (VirtualImage_pf): 虚拟形象信息 is_vip (bool): 是否超级会员 is_god (bool): 是否大神 @@ -107,7 +80,6 @@ class UserInfo_pf(TbErrorExt): sign: str = "" ip: str = '' icons: list[str] = dcs.field(default_factory=list) - vimage: VirtualImage_pf = dcs.field(default_factory=VirtualImage_pf) is_vip: bool = False is_god: bool = False @@ -136,7 +108,6 @@ def from_tbdata(data_proto: TypeMessage) -> UserInfo_pf: sign = user_proto.intro ip = user_proto.ip_address icons = [name for i in user_proto.iconinfo if (name := i.name)] - vimage = VirtualImage_pf.from_tbdata(user_proto.virtual_image_info) is_vip = bool(user_proto.new_tshow_icon) is_god = bool(user_proto.new_god_data.status) anti_proto = data_proto.anti_stat