Skip to content
Open
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
9 changes: 8 additions & 1 deletion octoprint_webhooks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import time
import sys

from datetime import datetime, timedelta

from io import BytesIO
from PIL import Image

Expand Down Expand Up @@ -135,6 +137,7 @@ class WebhooksPlugin(octoprint.plugin.StartupPlugin, octoprint.plugin.TemplatePl
octoprint.plugin.EventHandlerPlugin, octoprint.plugin.AssetPlugin, octoprint.plugin.SimpleApiPlugin,
octoprint.plugin.ProgressPlugin):
def __init__(self):
self.last_user_action_notification = datetime.now() - timedelta(seconds=60)
self.triggered = False
self.last_print_progress = -1
self.last_print_progress_milestones = []
Expand Down Expand Up @@ -569,8 +572,12 @@ def recv_callback(self, comm_instance, line, *args, **kwargs):
# Found keyword, fire event and block until other text is received
if "echo:busy: paused for user" in line:
if not self.triggered:
eventManager().fire(Events.PLUGIN_WEBHOOKS_NOTIFY)
self.triggered = True

if timedelta.total_seconds(datetime.now() - self.last_user_action_notification) > 60:
eventManager().fire(Events.PLUGIN_WEBHOOKS_NOTIFY)
self.last_user_action_notification = datetime.now()

# Other text, we may fire another event if we encounter "paused for user" again
else:
self.triggered = False
Expand Down