diff --git a/octoprint_telegram/__init__.py b/octoprint_telegram/__init__.py index 34cf4c3..3272020 100644 --- a/octoprint_telegram/__init__.py +++ b/octoprint_telegram/__init__.py @@ -604,7 +604,10 @@ def on_after_startup(self): t.run() except Exception: pass - + + def on_startup(self, host, port): + self.main.tcmd.port = port + def on_shutdown(self): self.on_event("PrinterShutdown",{}) self.stop_listening() diff --git a/octoprint_telegram/telegramCommands.py b/octoprint_telegram/telegramCommands.py index 8c86d0e..e80a42d 100644 --- a/octoprint_telegram/telegramCommands.py +++ b/octoprint_telegram/telegramCommands.py @@ -22,6 +22,7 @@ def __init__(self, main): self.conSettingsTemp = [] self.dirHashDict = {} self.tmpFileHash = "" + self.port = 80 self.commandDict = { "Yes": {'cmd': self.cmdYes, 'bind_none': True}, "No": {'cmd': self.cmdNo, 'bind_none': True}, @@ -630,8 +631,8 @@ def cmdFilament(self,chat_id,from_id,cmd,parameter): errorText = "" if params[0] == "spools": try: - resp = requests.get("http://localhost/plugin/filamentmanager/spools?apikey="+apikey) - resp2 = requests.get("http://localhost/plugin/filamentmanager/selections?apikey="+apikey) + resp = requests.get("http://localhost:" + str(self.port) + "/plugin/filamentmanager/spools?apikey="+apikey) + resp2 = requests.get("http://localhost:" + str(self.port) + "/plugin/filamentmanager/selections?apikey="+apikey) if (resp.status_code != 200): errorText = resp.text resp = resp.json() @@ -661,7 +662,7 @@ def cmdFilament(self,chat_id,from_id,cmd,parameter): try: payload = {"selection": {"spool": {"id": params[1]},"tool": 0}} self._logger.info("Payload: %s" % payload) - resp = requests.patch("http://localhost/plugin/filamentmanager/selections/0?apikey="+apikey, json=payload, headers={'Content-Type': 'application/json'}) + resp = requests.patch("http://localhost:" + str(self.port) + "/plugin/filamentmanager/selections/0?apikey="+apikey, json=payload, headers={'Content-Type': 'application/json'}) if (resp.status_code != 200): errorText = resp.text self._logger.info("Response: %s" % resp) @@ -678,7 +679,7 @@ def cmdFilament(self,chat_id,from_id,cmd,parameter): else: self._logger.info("Asking for spool") try: - resp = requests.get("http://localhost/plugin/filamentmanager/spools?apikey="+apikey) + resp = requests.get("http://localhost:" + str(self.port) + "/plugin/filamentmanager/spools?apikey="+apikey) if (resp.status_code != 200): errorText = resp.text resp = resp.json()