mirror of
https://github.com/paul-nameless/tg
synced 2024-11-25 13:20:25 +00:00
Make consistent tdlib API
This commit is contained in:
parent
d674c1d430
commit
98dbd21beb
2 changed files with 13 additions and 17 deletions
|
@ -615,7 +615,8 @@ class UserModel:
|
|||
if user.get("full_info"):
|
||||
return user["full_info"]
|
||||
|
||||
result = self.tg.get_user_full_info(user_id, block=True)
|
||||
result = self.tg.get_user_full_info(user_id,)
|
||||
result.wait()
|
||||
if result.error:
|
||||
log.warning(f"get user full info error: {result.error_info}")
|
||||
return {}
|
||||
|
|
27
tg/tdlib.py
27
tg/tdlib.py
|
@ -92,18 +92,15 @@ class Tdlib(Telegram):
|
|||
limit: int = 0,
|
||||
synchronous: bool = False,
|
||||
) -> None:
|
||||
result = self.call_method(
|
||||
"downloadFile",
|
||||
params=dict(
|
||||
file_id=file_id,
|
||||
priority=priority,
|
||||
offset=offset,
|
||||
limit=limit,
|
||||
synchronous=synchronous,
|
||||
),
|
||||
block=False,
|
||||
)
|
||||
result.wait()
|
||||
data = {
|
||||
"@type": "downloadFile",
|
||||
"file_id": file_id,
|
||||
"priority": priority,
|
||||
"offset": offset,
|
||||
"limit": limit,
|
||||
"synchronous": synchronous,
|
||||
}
|
||||
return self._send_data(data)
|
||||
|
||||
def reply_message(
|
||||
self, chat_id: int, reply_to_message_id: int, text: str
|
||||
|
@ -380,14 +377,12 @@ class Tdlib(Telegram):
|
|||
}
|
||||
return self._send_data(data)
|
||||
|
||||
def get_user_full_info(
|
||||
self, user_id: int, block: bool = False
|
||||
) -> AsyncResult:
|
||||
def get_user_full_info(self, user_id: int) -> AsyncResult:
|
||||
data = {
|
||||
"@type": "getUserFullInfo",
|
||||
"user_id": user_id,
|
||||
}
|
||||
return self._send_data(data, block=block)
|
||||
return self._send_data(data)
|
||||
|
||||
|
||||
def get_chat_type(chat: Dict[str, Any]) -> Optional[ChatType]:
|
||||
|
|
Loading…
Reference in a new issue