main.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from pyrogram import Client, filters
  2. import random
  3. import time
  4. import shutil, psutil
  5. app = Client("WilliamButcher")
  6. def random_line(fname):
  7. lines = open(fname).read().splitlines()
  8. return random.choice(lines)
  9. @app.on_message(filters.command(commands = (["start"])))
  10. async def start(client, message):
  11. await message.reply_text(random_line('start.txt'))
  12. @app.on_message(filters.command(commands = (["commit"])))
  13. async def commit(client, message):
  14. await message.reply_text(random_line('commit.txt'))
  15. @app.on_message(filters.command(commands = (["ping"])))
  16. def ping(client, message):
  17. start_time = int(round(time.time() * 1000))
  18. message.reply_text("Starting Ping")
  19. end_time = int(round(time.time() * 1000))
  20. message.reply_text(f'{end_time - start_time} ms') #Need to edit the above message instead of sending another
  21. @app.on_message(filters.command(commands =(["stats"])))
  22. def stats(client, message):
  23. cpu = psutil.cpu_percent(interval=0.5)
  24. mem = psutil.virtual_memory().percent
  25. disk = psutil.disk_usage('/').percent
  26. stats = f'<b>CPU:</b> {cpu}% ' \
  27. f'<b>RAM:</b> {mem}% ' \
  28. f'<b>Disk:</b> {disk}%'
  29. message.reply_text(stats)
  30. app.run()