Make consistent tdlib API

This commit is contained in:
Paul Nameless 2020-07-24 16:00:38 +08:00
parent d674c1d430
commit 98dbd21beb
2 changed files with 13 additions and 17 deletions

View file

@ -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 {}

View file

@ -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]: