Skip to content

Commit

Permalink
re-write ping command
Browse files Browse the repository at this point in the history
  • Loading branch information
rking32 committed Jan 22, 2022
1 parent a23aefb commit 948babf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 1 addition & 3 deletions userge/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ async def stop(self) -> None: # pylint: disable=arguments-differ
_LOG.info(_LOG_STR, "Stopping Userge")
await super().stop()
await _set_running(False)
pool._stop() # pylint: disable=protected-access

def begin(self, coro: Optional[Awaitable[Any]] = None) -> None:
""" start userge """
Expand All @@ -255,8 +254,6 @@ async def _finalize() -> None:
t.cancel()
if self.is_initialized:
await self.stop()
else:
pool._stop() # pylint: disable=protected-access
# pylint: disable=expression-not-assigned
[t.cancel() for t in asyncio.all_tasks() if t is not asyncio.current_task()]
await self.loop.shutdown_asyncgens()
Expand All @@ -282,6 +279,7 @@ def _close_loop() -> None:
pass
self.loop.close()
_LOG.info(_LOG_STR, "Loop Closed !")
pool._stop() # pylint: disable=protected-access

try:
self.loop.run_until_complete(self.start())
Expand Down
4 changes: 3 additions & 1 deletion userge/plugins/tools/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from datetime import datetime

from pyrogram.raw.functions import Ping

from userge import userge, Message


Expand All @@ -16,7 +18,7 @@
'flags': {'-a': "average ping"}}, group=-1)
async def pingme(message: Message):
start = datetime.now()
await message.edit('`Pong!`')
await message.client.send(Ping(ping_id=0))
end = datetime.now()
m_s = (end - start).microseconds / 1000
await message.edit(f"**Pong!**\n`{m_s} ms`")

0 comments on commit 948babf

Please sign in to comment.