Support a more obvious non-cached connection check

This commit is contained in:
Andrew Ferrazzutti 2022-05-16 02:07:08 -04:00
parent 47b9623446
commit 82d64b9b37
2 changed files with 4 additions and 1 deletions

View File

@ -63,7 +63,7 @@ async def ping(evt: CommandEvent) -> None:
if not await evt.sender.is_logged_in():
await evt.reply("You are **logged out** of KakaoTalk.")
else:
is_connected = evt.sender.is_connected and await evt.sender.client.is_connected()
is_connected = await evt.sender.is_connected_now()
await evt.reply(
"You are logged into KakaoTalk.\n\n"
f"You are {'connected to' if is_connected else '**disconnected** from'} KakaoTalk chats."

View File

@ -177,6 +177,9 @@ class User(DBUser, BaseUser):
self._is_connected = val
self._connection_time = time.monotonic()
async def is_connected_now(self) -> bool:
return self._client is not None and await self._client.is_connected()
@property
def connection_time(self) -> float:
return self._connection_time