Skip to content

Commit

Permalink
Merge pull request #127 from Starry-OvO/develop
Browse files Browse the repository at this point in the history
Update 3.4.3
  • Loading branch information
Starry-OvO committed Jun 6, 2023
2 parents 77ca7a0 + 025b2e4 commit 537a28e
Show file tree
Hide file tree
Showing 33 changed files with 145 additions and 202 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

!.github
!.github/**
!thirdparty
!thirdparty/**
!aiotieba
!aiotieba/**
!docs
Expand Down
2 changes: 1 addition & 1 deletion aiotieba/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.4.2"
__version__ = "3.4.3"
2 changes: 1 addition & 1 deletion aiotieba/api/tieba_uid2user_info/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class UserInfo_TUid(object):
'_is_god',
]

def __init__(self, data_proto: Optional[TypeMessage]) -> None:
def __init__(self, data_proto: Optional[TypeMessage] = None) -> None:
if data_proto:
self._user_id = data_proto.id
if '?' in (portrait := data_proto.portrait):
Expand Down
58 changes: 22 additions & 36 deletions aiotieba/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ async def init_websocket(self) -> bool:
except BaseException:
self._ws_core._status = WsStatus.CLOSED
raise
else:
self._ws_core._status = WsStatus.OPEN

return True

Expand All @@ -226,10 +224,12 @@ async def __upload_sec_key(self) -> None:
mid_manager.priv_gid = group._group_id
mid_manager.gid2mid = {g._group_id: MsgIDPair(g._last_msg_id, g._last_msg_id) for g in groups}

async def __init_tbs(self) -> bool:
self._ws_core._status = WsStatus.OPEN

async def __init_tbs(self) -> None:
if self._account._tbs:
return True
return await self.__login()
return
await self.__login()

async def get_self_info(self, require: ReqUInfo = ReqUInfo.ALL) -> TypeUserInfo:
"""
Expand All @@ -251,39 +251,30 @@ async def get_self_info(self, require: ReqUInfo = ReqUInfo.ALL) -> TypeUserInfo:

return self._user

@handle_exception(bool)
async def __login(self) -> bool:
async def __login(self) -> None:
user, tbs = await login.request(self._http_core)

self._user._user_id = user._user_id
self._user._portrait = user._portrait
self._user._user_name = user._user_name
self._account._tbs = tbs

return True

async def __init_client_id(self) -> bool:
async def __init_client_id(self) -> None:
if self._account._client_id:
return True
return await self.__sync()
return
await self.__sync()

@handle_exception(bool)
async def __sync(self) -> bool:
async def __sync(self) -> None:
client_id = await sync.request(self._http_core)
self._account._client_id = client_id

return True

@handle_exception(bool)
async def __init_z_id(self) -> bool:
async def __init_z_id(self) -> None:
if self._account._z_id:
return True
return

z_id = await init_z_id.request(self._http_core)
self._account._z_id = z_id

return True

@handle_exception(int)
async def get_fid(self, fname: str) -> int:
"""
Expand All @@ -304,6 +295,7 @@ async def get_fid(self, fname: str) -> int:

return fid

@handle_exception(str)
async def get_fname(self, fid: int) -> str:
"""
通过forum_id获取贴吧名
Expand Down Expand Up @@ -343,28 +335,21 @@ async def get_user_info(self, _id: Union[str, int], /, require: ReqUInfo = ReqUI
return UserInfo(_id)

if isinstance(_id, int):
if (require | ReqUInfo.BASIC) == ReqUInfo.BASIC:
# 仅有BASIC需求
return await self._get_uinfo_getUserInfo(_id)
elif require & ReqUInfo.TIEBA_UID:
# 有TIEBA_UID需求
user = await self._get_uinfo_getUserInfo(_id)
if require <= ReqUInfo.NICK_NAME:
# 仅有NICK_NAME以下的需求
return await self._get_uinfo_getuserinfo(_id)
else:
user = await self._get_uinfo_getuserinfo(_id)
user, _ = await self.get_homepage(user.portrait, with_threads=False)
return user
else:
# 有除TIEBA_UID外的其他非BASIC需求
return await self._get_uinfo_getuserinfo(_id)
elif is_portrait(_id):
if (require | ReqUInfo.BASIC) == ReqUInfo.BASIC:
# 仅有BASIC需求
if not require & ReqUInfo.USER_ID:
# 无USER_ID需求
return await self._get_uinfo_panel(_id)
else:
user, _ = await self.get_homepage(_id, with_threads=False)
return user
else:
user, _ = await self.get_homepage(_id, with_threads=False)
return user
user, _ = await self.get_homepage(_id, with_threads=False)
return user
else:
if (require | ReqUInfo.BASIC) == ReqUInfo.BASIC:
return await self._get_uinfo_user_json(_id)
Expand Down Expand Up @@ -908,6 +893,7 @@ async def del_threads(self, fname_or_fid: Union[str, int], /, tids: List[int], *

return await del_threads.request(self._http_core, fid, tids, block)

@handle_exception(bool, no_format=True)
async def del_post(self, fname_or_fid: Union[str, int], /, pid: int) -> bool:
"""
删除回复
Expand Down
2 changes: 1 addition & 1 deletion aiotieba/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MAIN_VERSION = "12.41.5.1"
MAIN_VERSION = "12.42.1.1"
POST_VERSION = "9.1.0.0"

APP_SECURE_SCHEME = "https"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@

#define BASE32_LEN(len) (((len) / 5) * 8 + ((len) % 5 ? 8 : 0))

void base32_encode(const unsigned char* src, int srcLen, unsigned char* dst);
void tbc_base32_encode(const unsigned char* src, int srcLen, unsigned char* dst);
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
#include <stddef.h> // size_t
#include <stdint.h> // uint32_t

uint32_t crc32(const unsigned char* src, size_t srcLen, uint32_t prev_val);
uint32_t tbc_crc32(const unsigned char* src, size_t srcLen, uint32_t prev_val);
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#ifndef MBEDTLS_LIBRARY_COMMON_H
#define MBEDTLS_LIBRARY_COMMON_H

#include "alignment.h"
#include "mbedtls/alignment.h"

#include <stddef.h>

Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 537a28e

Please sign in to comment.