ping.py 639 B

12345678910111213141516171819
  1. import requests
  2. from pyrogram.types import Message
  3. from wbb import app
  4. from wbb.utils import cust_filter
  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: Message):
  9. app.set_parse_mode("markdown")
  10. j = await message.reply_text("Wait, Pinging all Datacenters`")
  11. result = ""
  12. for i in range(1, 6):
  13. datacenter = (f"https://cdn{i}.telesco.pe")
  14. ping1 = round(requests.head(datacenter).elapsed.total_seconds() * 1000)
  15. result += f'```DC{i} - {ping1}ms```'
  16. await j.edit(result)