Skip to content

Commit

Permalink
Merge pull request #102 from yorambi/master
Browse files Browse the repository at this point in the history
server: System Commands some or all are empty
  • Loading branch information
rlogiacco authored Jul 16, 2019
2 parents 2aa530f + 134a84f commit bd77f24
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions octoprint_telegram/telegramCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def cmdSys(self,chat_id,from_id,cmd,parameter):
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))
return
return
else:
async = command["async"] if "async" in command else False
self._logger.info("Performing command: %s" % command["command"])
Expand All @@ -287,7 +287,6 @@ def cmdSys(self,chat_id,from_id,cmd,parameter):
self.main.send_msg(self.gEmo('warning') + " Sorry, i don't know this System Command.",chatID=chat_id, msg_id = self.main.getUpdateMsgId(chat_id))
return
else:
message = self.gEmo('info') + " The following System Commands are known."
keys = []
tmpKeys = []
i = 1
Expand All @@ -300,8 +299,30 @@ def cmdSys(self,chat_id,from_id,cmd,parameter):
i += 1
if len(tmpKeys) > 0:
keys.append(tmpKeys)
keys.append([["Restart OctoPrint","/sys_sys_Restart OctoPrint"]])
keys.append([["Reboot System","/sys_sys_Reboot System"],["Shutdown System","/sys_sys_Shutdown System"]])

tmpKeys = []
i = 1
serverCommands = { 'serverRestartCommand': ["Restart OctoPrint", "/sys_sys_Restart OctoPrint"],
'systemRestartCommand': ["Reboot System", "/sys_sys_Reboot System"],
'systemShutdownCommand': ["Shutdown System","/sys_sys_Shutdown System"]
}
for index in serverCommands:
commandText = self.main._settings.global_get(['server', 'commands', index])
if commandText is not None:
tmpKeys.append(serverCommands[index])
if i % 2 == 0:
keys.append(tmpKeys)
tmpKeys = []
i += 1
if len(tmpKeys) > 0:
keys.append(tmpKeys)

if len(keys) > 0 :
message_text = " The following System Commands are known."
else:
message_text = " No known System Commands."
message = self.gEmo('info') + message_text

keys.append([[self.main.emojis['cross mark']+gettext(" Close"),"No"]])
msg_id=self.main.getUpdateMsgId(chat_id) if parameter == "back" else ""
self.main.send_msg(message,chatID=chat_id,responses=keys,msg_id=msg_id)
Expand Down

0 comments on commit bd77f24

Please sign in to comment.