12345678910111213141516 |
- import socket
- from rollbot import as_command
- from rollbot.injection import Config
- @as_command
- def plex(host: Config("plex.host"), port: Config("plex.port")):
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.settimeout(5)
- try:
- s.connect((host, port))
- s.shutdown(socket.SHUT_WR)
- except (ConnectionRefusedError, socket.timeout):
- return "I couldn't reach Plex within 5 seconds!"
- return "Well, something is running on that port, so it's probably up!"
|