ping.py 610 B

12345678910111213141516171819
  1. from wbb import app, Command
  2. from wbb.utils import cust_filter
  3. import requests
  4. import time
  5. __MODULE__ = "Ping"
  6. __HELP__ = " /ping - To Get Response Time From All TG Datacenters"
  7. @app.on_message(cust_filter.command(commands=(["ping"])))
  8. async def ping(client, message):
  9. app.set_parse_mode("markdown")
  10. m = await message.reply_text("```Wait, Pinging all Datacenters```")
  11. result = ""
  12. for i in range(1, 6):
  13. dc = (f"https://cdn{i}.telesco.pe")
  14. ping1 = round(requests.head(dc).elapsed.total_seconds() * 1000)
  15. result += f'```DC{i} - {ping1}ms```'
  16. await m.edit(result)