From 60b9c659a3efa34af36e885a8bdb8293a687f4ee Mon Sep 17 00:00:00 2001
From: Someone <someone@somenet.org>
Date: Sat, 1 Apr 2023 23:42:01 +0200
Subject: [PATCH] core/AbstractPublicWS.py

---
 core/AbstractPublicWS.py | 58 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 core/AbstractPublicWS.py

diff --git a/core/AbstractPublicWS.py b/core/AbstractPublicWS.py
new file mode 100644
index 0000000..1713db3
--- /dev/null
+++ b/core/AbstractPublicWS.py
@@ -0,0 +1,58 @@
+# Mattermost Bot.
+#  Copyright (c) 2016-2022 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
+#  published under MIT-License
+
+
+import mattermost
+
+
+class AbstractPublicWS():
+    URL = None
+    TRIGGER = None
+    CONFIG = {"display_name": "somebot-command", "auto_complete": True}
+
+    bot = None
+
+
+    def __init__(self, team_id):
+        self.TEAM_ID = team_id
+
+    def __str__(self):
+        return str(self.__class__)
+
+    def __repr__(self):
+        return self.__str__()
+
+
+    # can/should be overridden by the user
+    def on_register_public(self):
+        """Consider to override. Handles the post-command-registration logic at bot startup."""
+        return
+
+    # should be overridden by the user
+    def on_public_GET(self, request, data):
+        """Override. Handles the post-command logic."""
+        return
+
+    # should be overridden by the user
+    def on_public_POST(self, request, data):
+        """Override. Handles the post-command logic."""
+        return
+
+
+    def _on_register_public(self, bot):
+        self.bot = bot
+        #self.URL = ("http://"+self.bot.local_websrv_hostname+":"+str(self.bot.local_websrv_port)+"/").strip("/")+"/"+self.TEAM_ID+"/"+self.TRIGGER
+        self.URL = ("http://"+self.bot.local_websrv_hostname+":"+str(self.bot.local_websrv_port)+"/").strip("/")+"/"+self.TRIGGER
+        self.on_register_public()
+
+
+    def _on_shutdown(self):
+        self.on_shutdown()
+
+
+    def _on_public_GET(self, request, data):
+            return self.on_public_GET(request, data)
+
+    def _on_public_POST(self, request, data):
+            return self.on_public_POST(request, data)
-- 
2.43.0