Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #195 #198

Merged
merged 3 commits into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion octoprint_telegram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 5 additions & 4 deletions octoprint_telegram/telegramCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down