plex.py 500 B

12345678910111213141516
  1. import socket
  2. from rollbot import as_command
  3. from rollbot.injection import Config
  4. @as_command
  5. def plex(host: Config("plex.host"), port: Config("plex.port")):
  6. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  7. s.settimeout(5)
  8. try:
  9. s.connect((host, port))
  10. s.shutdown(socket.SHUT_WR)
  11. except (ConnectionRefusedError, socket.timeout):
  12. return "I couldn't reach Plex within 5 seconds!"
  13. return "Well, something is running on that port, so it's probably up!"