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

fix status with image problem #430

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ dist
*.*~
*.yaml
dev_utils/NOTES.txt
dev_utils/NOTES.txt
dev_utils/NOTES.txt
octoprint_telegram/__init__.py.bak
octoprint_telegram/telegramCommands.py.bak
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.5](https://github.com/fabianonline/OctoPrint-Telegram/releases)**
**Latest release: [1.6.8](https://github.com/fabianonline/OctoPrint-Telegram/releases)**

<!-- omit in toc -->
## Contents
Expand Down Expand Up @@ -262,7 +262,7 @@ sudo apt-get install cpulimit
- the TuyaSmartplug plugin API. Requires the [TuyaSmartplug plugin](https://github.com/ziirish/OctoPrint-TuyaSmartplug/)
sadly for now wait on accept the push request to get the list of plug

**`/gcode`** - Send the gcode to the printer where XXX is the gcode command (/gcode_M117 HelloWorld for exemple)
**`/gcode_XXX`** - Send the gcode to the printer where XXX is the gcode command (/gcode_M117 HelloWorld for exemple)

<!-- omit in toc -->
#### Notes:
Expand Down
679 changes: 426 additions & 253 deletions octoprint_telegram/__init__.py

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion octoprint_telegram/static/js/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,9 @@ $(function() {
var settings_to_check_number = [
settings.notification_height,
settings.notification_time,
settings.message_at_print_done_delay
settings.message_at_print_done_delay,
setting.precommand_delay,
setting.postcommand_delay
];
for (var i = 0; i < settings_to_check_number.length; i++) {
if (!self.isNumber(settings_to_check_number[i]())) {
Expand Down
19 changes: 19 additions & 0 deletions octoprint_telegram/telegramCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(self, main):
"/dontshutup": {"cmd": self.cmdNShutup},
"/print": {"cmd": self.cmdPrint, "param": True},
"/files": {"cmd": self.cmdFiles, "param": True},
"/again": {"cmd": self.cmdAgain, "param": True}, #giloser 16-10-2021
"/upload": {"cmd": self.cmdUpload},
"/filament": {"cmd": self.cmdFilament, "param": True},
"/sys": {"cmd": self.cmdSys, "param": True},
Expand Down Expand Up @@ -780,6 +781,24 @@ def cmdUpload(self, chat_id, from_id, cmd, parameter, user = ""):
chatID=chat_id,
)

############################################################################################
def cmdAgain(self,chat_id,from_id,cmd,parameter, user=""):
try:
data = self.main._printer.get_current_data()
if self.main._printer.is_printing():
self.main.send_msg(self.gEmo("warning") + " A print job is already running. You can't print two thing at the same time. Maybe you want to use /abort? ",chatID=chat_id)#, msg_id = self.main.getUpdateMsgId(chat_id))
elif not self.main._printer.is_operational():
self.main.send_msg(self.gEmo("warning") + gettext(" Can't start printing: I'm not connected to a printer."),chatID=chat_id)#, msg_id = self.main.getUpdateMsgId(chat_id))
elif data["job"]["file"]["name"] is not None:
file = data["job"]["file"]["name"]
msg = self.gEmo("info") + gettext(" The file " +str(file)+" is loaded.\n\n"+self.gEmo("question")+" Do you want me to start printing it now?", file=data["job"]["file"]["name"])
self.main.send_msg(msg,noMarkup=True, responses=[[[self.main.emojis["check"]+gettext("Print"),"/print_s"], [self.main.emojis["cross mark"]+gettext(" Cancel"),"/print_x"]]],chatID=chat_id)#, msg_id = self.main.getUpdateMsgId(chat_id))
else:
self.main.send_msg(self.gEmo("warning") + gettext(" File not loaded. Please use this after another print."),chatID=chat_id)#, msg_id = self.main.getUpdateMsgId(chat_id))
except Exception as e:
self._logger.warn("Command failed: %s" % e)
self.main.send_msg(self.gEmo("warning") + " Command failed with exception: %s!" % e,chatID = chat_id)#, msg_id = self.main.getUpdateMsgId(chat_id))

############################################################################################
def cmdSys(self, chat_id, from_id, cmd, parameter, user = ""):
if parameter and parameter != "back":
Expand Down
8 changes: 8 additions & 0 deletions octoprint_telegram/templates/telegram_settings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@
</select>
<span class="help-block"><small>Action pre image could be none, a gcode or a system command (script name with full path)</small></span>
<input type="text" class="input-block-level" id="settings_plugin_telegram_PreImgCommand" data-bind="value: settings.settings.plugins.telegram.PreImgCommand"/>

<input type="number" step="any" min="0.0" class="input-mini text-right" data-bind="value: settings.settings.plugins.telegram.precommand_delay" />
<span class="add-on">s</span>
<span class="help-block"><small>Wait this many seconds after pre image action. Set to 0 to disable.</small></span>
</div>
</div>

Expand All @@ -263,6 +267,10 @@
</select>
<span class="help-block"><small>Action post image could be none, a gcode or a system command (script name with full path)</small></span>
<input type="text" class="input-block-level" id="settings_plugin_telegram_PostImgCommand" data-bind="value: settings.settings.plugins.telegram.PostImgCommand" />

<input type="number" step="any" min="0.0" class="input-mini text-right" data-bind="value: settings.settings.plugins.telegram.postcommand_delay" />
<span class="add-on">s</span>
<span class="help-block"><small>Wait this many seconds before post image action. Set to 0 to disable.</small></span>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.7"
plugin_version = "1.6.8"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down
Loading