Skip to content

Commit

Permalink
Merge pull request #1 from rlogiacco/fix/201
Browse files Browse the repository at this point in the history
switches from str to unicode
  • Loading branch information
giloser authored Aug 29, 2019
2 parents 3a1d98e + cf2fce9 commit e718905
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions octoprint_telegram/telegramCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def cmdSys(self,chat_id,from_id,cmd,parameter):
command = next((d for d in actions if 'action' in d and self.hashMe(d['action']) == parameter) , False)
if command :
if 'confirm' in command and params[0] != "do":
self.main.send_msg(self.gEmo('question') + str(command['name'])+"\nExecute system command?",responses=[[[self.main.emojis['check']+gettext(" Execute"),"/sys_do_"+str(parameter)], [self.main.emojis['leftwards arrow with hook']+ gettext(" Back"),"/sys_back"]]],chatID=chat_id, msg_id = self.main.getUpdateMsgId(chat_id))
self.main.send_msg(self.gEmo('question') + unicode(command['name'])+"\nExecute system command?",responses=[[[self.main.emojis['check'] + gettext(" Execute"),"/sys_do_" + unicode(parameter)], [self.main.emojis['leftwards arrow with hook'] + gettext(" Back"),"/sys_back"]]],chatID=chat_id, msg_id = self.main.getUpdateMsgId(chat_id))
return
else:
async = command["async"] if "async" in command else False
Expand Down Expand Up @@ -351,7 +351,7 @@ def cmdSys(self,chat_id,from_id,cmd,parameter):
i = 1
for action in self.main._settings.global_get(['system','actions']):
if action['action'] != "divider":
tmpKeys.append([str(action['name']),"/sys_"+self.hashMe(action['action'])])
tmpKeys.append([unicode(action['name']),"/sys_"+self.hashMe(action['action'])])
if i%2 == 0:
keys.append(tmpKeys)
tmpKeys = []
Expand Down Expand Up @@ -405,7 +405,7 @@ def cmdCtrl(self,chat_id,from_id,cmd,parameter):
command = next((d for d in actions if d['hash'] == parameter), False)
if command:
if 'confirm' in command and params[0] != "do":
self.main.send_msg(self.gEmo('question') + str(command['name']) + "\nExecute control command?",responses=[[[self.main.emojis['check']+gettext("Execute"),"/ctrl_do_"+str(parameter)], [self.main.emojis['leftwards arrow with hook']+gettext(" Back"),"/ctrl_back"]]],chatID=chat_id, msg_id = self.main.getUpdateMsgId(chat_id))
self.main.send_msg(self.gEmo('question') + unicode(command['name']) + "\nExecute control command?",responses=[[[self.main.emojis['check']+gettext("Execute"),"/ctrl_do_" + unicode(parameter)], [self.main.emojis['leftwards arrow with hook']+gettext(" Back"),"/ctrl_back"]]],chatID=chat_id, msg_id = self.main.getUpdateMsgId(chat_id))
return
else:
if 'script' in command:
Expand All @@ -429,7 +429,7 @@ def cmdCtrl(self,chat_id,from_id,cmd,parameter):
i = 1
for action in self.get_controls_recursively():
empty=False
tmpKeys.append([str(action['name']),"/ctrl_"+str(action['hash'])])
tmpKeys.append([unicode(action['name']),"/ctrl_" + str(action['hash'])])
if i%2 == 0:
keys.append(tmpKeys)
tmpKeys = []
Expand Down Expand Up @@ -656,10 +656,10 @@ def cmdFilament(self,chat_id,from_id,cmd,parameter):
weight = spool["weight"]
used = spool["used"]
percent = int(100 - (used / weight * 100))
message += str(spool["profile"]["vendor"]) + " " + str(spool["name"]) + " " + str(spool["profile"]["material"]) + " [" + str(percent) + "%]\n"
message += unicode(spool["profile"]["vendor"]) + " " + unicode(spool["name"]) + " " + unicode(spool["profile"]["material"]) + " [" + str(percent) + "%]\n"
for selection in resp2["selections"]:
if selection["tool"] == 0:
message += "\n\nCurrently selected: " + str(selection["spool"]["profile"]["vendor"]) + " " + str(selection["spool"]["name"]) + str(selection["spool"]["profile"]["material"])
message += "\n\nCurrently selected: " + unicode(selection["spool"]["profile"]["vendor"]) + " " + unicode(selection["spool"]["name"]) + " " + unicode(selection["spool"]["profile"]["material"])
msg_id=self.main.getUpdateMsgId(chat_id)
self.main.send_msg(message,chatID=chat_id,msg_id = msg_id,inline=False)
except ValueError:
Expand All @@ -680,7 +680,7 @@ def cmdFilament(self,chat_id,from_id,cmd,parameter):
errorText = resp.text
self._logger.info("Response: %s" % resp)
resp = resp.json()
message = self.gEmo('check') + " Selected spool is now: " + str(resp["selection"]["spool"]["profile"]["vendor"]) + " " + str(resp["selection"]["spool"]["name"]) + " " + str(resp["selection"]["spool"]["profile"]["material"])
message = self.gEmo('check') + " Selected spool is now: " + unicode(resp["selection"]["spool"]["profile"]["vendor"]) + " " + unicode(resp["selection"]["spool"]["name"]) + " " + unicode(resp["selection"]["spool"]["profile"]["material"])
msg_id=self.main.getUpdateMsgId(chat_id)
self.main.send_msg(message,chatID=chat_id,msg_id = msg_id,inline=False)
except ValueError:
Expand All @@ -702,7 +702,7 @@ def cmdFilament(self,chat_id,from_id,cmd,parameter):
i = 1
for spool in resp["spools"]:
self._logger.info("Appending spool: %s" % spool)
tmpKeys.append([str(spool["profile"]["vendor"]) + " " + str(spool['name']) + " " + str(spool["profile"]["material"]) ,"/filament_changeSpool_" + str(spool['id'])])
tmpKeys.append([unicode(spool["profile"]["vendor"]) + " " + unicode(spool['name']) + " " + unicode(spool["profile"]["material"]) ,"/filament_changeSpool_" + unicode(spool['id'])])
if i%2 == 0:
keys.append(tmpKeys)
tmpKeys = []
Expand Down

0 comments on commit e718905

Please sign in to comment.