mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Create delayed ping
This commit is contained in:
parent
a01402d383
commit
23594fc4ac
1 changed files with 10 additions and 2 deletions
|
@ -1,11 +1,19 @@
|
||||||
from ..utils import Command, CommandArgs, Call
|
import asyncio
|
||||||
|
from ..utils import Command, CommandArgs, Call, InvalidInputError
|
||||||
|
|
||||||
|
|
||||||
class PingCommand(Command):
|
class PingCommand(Command):
|
||||||
|
|
||||||
command_name = "ping"
|
command_name = "ping"
|
||||||
command_description = "Ping pong!"
|
command_description = "Ping pong!"
|
||||||
command_syntax = ""
|
command_syntax = "[time_to_wait]"
|
||||||
|
|
||||||
async def common(self, call: Call):
|
async def common(self, call: Call):
|
||||||
|
try:
|
||||||
|
time = int(call.args[0])
|
||||||
|
except InvalidInputError:
|
||||||
|
time = 0
|
||||||
|
except ValueError:
|
||||||
|
raise InvalidInputError("time_to_wait is not a number")
|
||||||
|
await asyncio.sleep(time)
|
||||||
await call.reply("🏓 Pong!")
|
await call.reply("🏓 Pong!")
|
||||||
|
|
Loading…
Reference in a new issue