Browse Source

Implementing the plex status check plugin

Kirk Trombley 5 years ago
parent
commit
0c29867b0c
3 changed files with 19 additions and 1 deletions
  1. 1 1
      mkplugin.sh
  2. 1 0
      src/plugins/__init__.py
  3. 17 0
      src/plugins/plex.py

+ 1 - 1
mkplugin.sh

@@ -24,7 +24,7 @@ fi
 
 echo "Populating $PLUGIN_FILE with basic plugin called $1"
 
-echo "from command_system import as_plugin" >> $PLUGIN_FILE
+echo "from rollbot import as_plugin" >> $PLUGIN_FILE
 echo "" >> $PLUGIN_FILE
 echo "" >> $PLUGIN_FILE
 echo "@as_plugin" >> $PLUGIN_FILE

+ 1 - 0
src/plugins/__init__.py

@@ -12,3 +12,4 @@ import plugins.hangguy
 import plugins.finchat
 import plugins.yell
 import plugins.watchlist
+import plugins.plex

+ 17 - 0
src/plugins/plex.py

@@ -0,0 +1,17 @@
+import socket
+
+from rollbot import as_plugin
+
+from config import get_secret
+
+PLEX_HOST = get_secret("plex.host")
+
+@as_plugin
+def plex():
+    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    try:
+        s.connect((PLEX_HOST, 32400))
+        s.shutdown(socket.SHUT_WR)
+        return "Well, something is running on that port so, it's probably up!"
+    except ConnectionRefusedError:
+        return "I couldn't reach plex!"