Support a more obvious non-cached connection check
This commit is contained in:
parent
47b9623446
commit
82d64b9b37
|
@ -63,7 +63,7 @@ async def ping(evt: CommandEvent) -> None:
|
||||||
if not await evt.sender.is_logged_in():
|
if not await evt.sender.is_logged_in():
|
||||||
await evt.reply("You are **logged out** of KakaoTalk.")
|
await evt.reply("You are **logged out** of KakaoTalk.")
|
||||||
else:
|
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(
|
await evt.reply(
|
||||||
"You are logged into KakaoTalk.\n\n"
|
"You are logged into KakaoTalk.\n\n"
|
||||||
f"You are {'connected to' if is_connected else '**disconnected** from'} KakaoTalk chats."
|
f"You are {'connected to' if is_connected else '**disconnected** from'} KakaoTalk chats."
|
||||||
|
|
|
@ -177,6 +177,9 @@ class User(DBUser, BaseUser):
|
||||||
self._is_connected = val
|
self._is_connected = val
|
||||||
self._connection_time = time.monotonic()
|
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
|
@property
|
||||||
def connection_time(self) -> float:
|
def connection_time(self) -> float:
|
||||||
return self._connection_time
|
return self._connection_time
|
||||||
|
|
Loading…
Reference in New Issue