From ece11c8be9054e5dd8c4fea82b57f358b726d480 Mon Sep 17 00:00:00 2001 From: Damien Degois Date: Mon, 20 Apr 2020 02:49:23 +0200 Subject: [PATCH] Add silent message option (no active notification for choosen events) --- octoprint_telegram/__init__.py | 3 +- octoprint_telegram/static/js/telegram.js | 35 ++++++++++++++++++- octoprint_telegram/telegramNotifications.py | 11 ++++++ .../templates/telegram_settings.jinja2 | 11 ++++++ 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/octoprint_telegram/__init__.py b/octoprint_telegram/__init__.py index d4c02a8..10d5fbe 100644 --- a/octoprint_telegram/__init__.py +++ b/octoprint_telegram/__init__.py @@ -1083,7 +1083,7 @@ def _send_edit_msg(self,message="",msg_id="",chatID="", responses= None, inline= except Exception as ex: self._logger.debug("Caught an exception in _send_edit_msg(): " + str(ex)) - def _send_msg(self, message="", with_image=False,with_gif=False,responses=None, delay=0, inline = True, chatID = "", markup=None, showWeb=False, **kwargs): + def _send_msg(self, message="", with_image=False,with_gif=False,responses=None, delay=0, inline = True, chatID = "", markup=None, showWeb=False, silent=False, **kwargs): if not self.send_messages: return @@ -1121,6 +1121,7 @@ def _send_msg(self, message="", with_image=False,with_gif=False,responses=None, image_data = None data['chat_id'] = chatID + data['disable_notification'] = silent if with_gif : #giloser 05/05/19 try: self._logger.info("Will try to create a gif ") diff --git a/octoprint_telegram/static/js/telegram.js b/octoprint_telegram/static/js/telegram.js index e5a01e5..3de6196 100644 --- a/octoprint_telegram/static/js/telegram.js +++ b/octoprint_telegram/static/js/telegram.js @@ -134,6 +134,20 @@ $(function() { hideMup = ""; hideComb = "display:none" } + + if(self.settings.settings.plugins.telegram.messages[keys[id]].silent()) { + imgSilent = "volume-off"; + bSilent = "warning"; + txtSilent = "Silent"; + hideMup = ""; + hideComb = ""; + } else{ + imgSilent = "volume-up"; + bSilent = "success"; + txtSilent = "Notification"; + hideMup = ""; + hideComb = "" + } if(self.settings.settings.plugins.telegram.messages[keys[id]].gif()){ imgGif = "camera"; bGif = "success"; @@ -200,6 +214,12 @@ $(function() { btnImg += ' '; btnImg += ''+txt+'
'; + var btnSilent = 'Send silently?
'; + btnSilent += '
'; + var btnGif = 'Send with gif?
'; btnGif += '