diff --git a/README.md b/README.md index 84a1ba7..084c21f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This plugin integrates Telegram Messenger with Octoprint. It sends messages (with photos if available) on print start, end and failure. Also it sends messages during the print at configurable intervals. That way you don't have to remember to regularly have a look at the printing process. Also, you can control Octoprint via messages (settings, start a print and much more). Send `/status` to get the current printer status or `/abort` to abort the current print. Send `/help` for a list of all recognized commands. You may also use this bot in groups. -**Latest release: [1.6.0](https://github.com/fabianonline/OctoPrint-Telegram/releases)** +**Latest release: [1.6.1](https://github.com/fabianonline/OctoPrint-Telegram/releases)** ## Contents @@ -68,7 +68,7 @@ If you already have a bot, you only need your bot token to proceed. GOTO `4.` (o print - Lets you start a print. A confirmation is required. togglepause - Pause/Resume current Print. con - Connect/disconnect printer. - upload - You can just send me a gcode file to save it to my library. + upload - You can just send me a gcode file to save it to my library. Also accept zip file. sys - Execute Octoprint System Commands. ctrl - Use self defined controls from Octoprint. tune - Set feed- and flowrate. Control temperatures. @@ -96,6 +96,8 @@ If you already have a bot, you only need your bot token to proceed. GOTO `4.` (o 5. Hit "Save" at the bottom of the settings dialog. 6. If you want to create gif and receive them as notification we use ffmpeg like timelapse (if problem please check timelapse is configured). +you'll have to install CpuLimit to be able to create gif so please for raspberry connect to your raspberry with putty (for exemple) and execute +sudo apt-get install cpulimit Congratulations! Your printer is now connected to your Telegram bot. @@ -231,7 +233,7 @@ In this section you can configure the content of the notification messages. **`/con`** - Connect/disconnect printer. Choose between auto connect, use defaults to connect or manual connect (select port/baudrate/printer profile). You are also able to change the connection defaults and turn auto connect on/off. -**`/upload`** - You can just send a gcode file to the bot to save it in upload folder of Octoprint. If you send this command, the bot will tell you the same :) NOTE: This will NOT work in groups. +**`/upload`** - You can just send a gcode file or a zip file to the bot to save it in upload folder of Octoprint. If you send this command, the bot will tell you the same :) NOTE: This will NOT work in groups. **`/sys`** - Execute Octoprint System Comamnds you defined in *config.yaml*. If a confirmation is defined for the system command, it will be displayed before execution. See [Octoprint documentation](http://docs.octoprint.org/en/master/configuration/config_yaml.html#system) for details on setting up system commands. There is also a [plugin](http://plugins.octoprint.org/plugins/systemcommandeditor/) for doing this. @@ -243,9 +245,11 @@ In this section you can configure the content of the notification messages. **`/help`** - Displays a help message with all accepted commands and a short description. -**`/gif`** - Send a gif create from 20 images. +**`/gif`** - Send a gif create from 20 images. You'll have to install CpuLimit to be able to create gif so please for raspberry connect to your raspberry with putty (for exemple) and execute +sudo apt-get install cpulimit -**`/supergif`** - Send a gif create from 60 images. +**`/supergif`** - Send a gif create from 60 images. You'll have to install CpuLimit to be able to create gif so please for raspberry connect to your raspberry with putty (for exemple) and execute +sudo apt-get install cpulimit #### Notes: @@ -272,3 +276,4 @@ If you want to talk to other users of this plugin and maybe have some influence you can join the [Octoprint-Telegram-Users-Group](https://telegram.me/joinchat/CXFirQjl9XTp5dr4OZqH9Q). This software is licensed under [AGPLv3](http://www.gnu.org/licenses/agpl-3.0.txt) + diff --git a/octoprint_telegram/__init__.py b/octoprint_telegram/__init__.py index 509fb2f..4bea6a8 100644 --- a/octoprint_telegram/__init__.py +++ b/octoprint_telegram/__init__.py @@ -1147,6 +1147,7 @@ def _send_msg(self, message="", with_image=False,with_gif=False,responses=None, try: curr = self._settings.global_get(["plugins","multicam","multicam_profiles"]) self._logger.debug("multicam_profiles : "+ str(curr)) + ListGif = [] for li in curr: try: self._logger.debug("multicam profile : "+ str(li)) @@ -1154,13 +1155,24 @@ def _send_msg(self, message="", with_image=False,with_gif=False,responses=None, self._logger.debug("multicam URL : "+ str(url)) ret = self.create_gif_new(chatID,0,li) if ret != "": - if not sendOneInLoop: - self.send_file(chatID, ret,message) - else: - self.send_file(chatID, ret,"") - sendOneInLoop = True + ListGif.append(ret) + #if not sendOneInLoop: + # self.send_file(chatID, ret,message) + #else: + # self.send_file(chatID, ret,"") + #sendOneInLoop = True except Exception as ex: self._logger.exception("Exception loop multicam URL to create gif: "+ str(ex) ) + ret = ListGif[-1] + self._logger.debug("ListGif: "+str(ListGif)) + for x in ListGif: + try: + if x != ret: + self._logger.debug("send_file whithout message: "+str(x)) + self.send_file(chatID, x,"") + except Exception as ex: + self._logger.exception("Exception loop multicam URL to send gif: "+ str(ex) ) + except Exception as ex: self._logger.exception("Exception occured on getting multicam options: "+ str(ex) ) else: @@ -1170,6 +1182,7 @@ def _send_msg(self, message="", with_image=False,with_gif=False,responses=None, ret = self.create_gif_new(chatID,0,0) if ret != "" and not sendOneInLoop: + self._logger.debug("send_file whith message: "+str(ret)) self.send_file(chatID, ret,message) #ret = self.create_gif_new(chatID,0,0) #if ret != "": @@ -1478,7 +1491,10 @@ def create_gif_new(self,chatID,sec=7,multicam_prof=0): # saveDir = os.getcwd() # os.chdir(self.get_plugin_data_folder()+"/tmpgif") - outPath = self.get_plugin_data_folder()+"/tmpgif/gif.mp4" + if multicam_prof != 0: + outPath = self.get_plugin_data_folder()+"/tmpgif/gif_"+multicam_prof.get("name").replace(" ", "_") + ".mp4" + else: + outPath = self.get_plugin_data_folder()+"/tmpgif/gif.mp4" try: os.remove(outPath) diff --git a/octoprint_telegram/telegramCommands.py b/octoprint_telegram/telegramCommands.py index bd882e2..16b4fc8 100644 --- a/octoprint_telegram/telegramCommands.py +++ b/octoprint_telegram/telegramCommands.py @@ -354,7 +354,7 @@ def cmdFiles(self,chat_id,from_id,cmd,parameter): self.main.send_msg(self.gEmo('warning') + " Command failed with exception: %s!" % e,chatID = chat_id, msg_id = self.main.getUpdateMsgId(chat_id)) ############################################################################################ def cmdUpload(self,chat_id,from_id,cmd,parameter): - self.main.send_msg(self.gEmo('info') + " To upload a gcode file, just send it to me.\nThe file will be stored in 'TelegramPlugin' folder.",chatID=chat_id) + self.main.send_msg(self.gEmo('info') + " To upload a gcode file (also accept zip file), just send it to me.\nThe file will be stored in 'TelegramPlugin' folder.",chatID=chat_id) ############################################################################################ def cmdSys(self,chat_id,from_id,cmd,parameter): if parameter and parameter != "back": @@ -820,7 +820,7 @@ def cmdHelp(self,chat_id,from_id,cmd,parameter): "/print - Lets you start a print. A confirmation is required.\n" "/togglepause - Pause/Resume current Print.\n" "/con - Connect/disconnect printer.\n" - "/upload - You can just send me a gcode file to save it to my library.\n" + "/upload - You can just send me a gcode file or a zip file to save it to my library.\n" "/sys - Execute Octoprint System Commands.\n" "/ctrl - Use self defined controls from Octoprint.\n" "/tune - Set feed- and flowrate. Control temperatures.\n" @@ -851,7 +851,26 @@ def fileList(self,pathHash,page,cmd,chat_id,wait = 0): for key,val in sorted(iter(L.items()), key=lambda x: x[1]['date'] , reverse=True): try: self._logger.debug("should get info on item " ) - vfilename = self.main.emojis['page facing up']+" "+('.').join(key.split('.')[:-1]) + try: + #Giloser 30/10/2020 get info from history to show last state of print + if(len(val['history']) > 0): + HistList = val['history'] + HistList.sort(key=lambda x: x['timestamp'] , reverse=True) + try: + if(HistList[0]['success'] == True): + #vfilename = self.main.emojis['party face']+" "+('.').join(key.split('.')[:-1]) + vfilename = self.main.emojis['party popper']+" "+('.').join(key.split('.')[:-1]) + else: + #vfilename = self.main.emojis['disappointed but relieved face']+" "+('.').join(key.split('.')[:-1]) + vfilename = self.main.emojis['warning sign']+" "+('.').join(key.split('.')[:-1]) + except Exception as ex: + vfilename = self.main.emojis['page facing up']+" "+('.').join(key.split('.')[:-1]) + else: + vfilename = self.main.emojis['squared new']+" "+('.').join(key.split('.')[:-1]) + except Exception as ex: + vfilename = self.main.emojis['squared new']+" "+('.').join(key.split('.')[:-1]) + self._logger.debug("An Exception in fileList loop file items : " + str(ex)) + self._logger.debug("vfilename : {}".format(vfilename)) vhash = self.hashMe(pathWoDest + key) self._logger.debug("vhash : " + str(vhash) ) @@ -910,6 +929,28 @@ def fileDetails(self,pathHash,page,cmd,fileHash,chat_id,from_id,wait=0): msg += "\n"+self.main.emojis['clock face twelve oclock']+"Uploaded: " + datetime.datetime.fromtimestamp(file['date']).strftime('%Y-%m-%d %H:%M:%S') except Exception as ex: self._logger.info("An Exception in get upload time : " + str(ex) ) + + self._logger.debug("val : " + str(file) ) + self._logger.debug("meta : " + str(meta) ) + try: + #Giloser 30/10/2020 get info from history to show last state of print + if(len(file['history']) > 0): + HistList = file['history'] + HistList.sort(key=lambda x: x['timestamp'] , reverse=True) + try: + if(HistList[0]['success'] == True): + #vfilename = self.main.emojis['party face']+" "+('.').join(key.split('.')[:-1]) + msg += "\n"+ self.main.emojis['party popper']+"Number of Print: " + str(len(file['history'])) + else: + #vfilename = self.main.emojis['disappointed but relieved face']+" "+('.').join(key.split('.')[:-1]) + msg += "\n"+ self.main.emojis['warning sign']+"Number of Print: " + str(len(file['history'])) + except Exception as ex: + msg += "\n"+ self.main.emojis['page facing up']+"Number of Print: " + str(len(file['history'])) + else: + msg += "\n"+ self.main.emojis['squared new']+"Number of Print: 0" + except Exception as ex: + msg += "\n"+ self.main.emojis['squared new']+"Number of Print: 0" + msg += "\n"+self.main.emojis['flexed biceps']+"Size: " + self.formatSize(file['size']) filaLen = 0 printTime = 0 diff --git a/setup.py b/setup.py index 02aa4be..4baa47c 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "OctoPrint-Telegram" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "1.6.0" +plugin_version = "1.6.1" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module