diff --git a/pixinsight_update_bundle/doc/docs/Notification Event Script for WBPP/Notification Event Script for WBPP.html b/pixinsight_update_bundle/doc/docs/Notification Event Script for WBPP/Notification Event Script for WBPP.html new file mode 100644 index 0000000..21c6976 --- /dev/null +++ b/pixinsight_update_bundle/doc/docs/Notification Event Script for WBPP/Notification Event Script for WBPP.html @@ -0,0 +1,201 @@ + + +
+ +A PixInsight script for sending notifications at key events in the WBPP pipeline. [more]
Keywords: WBPP, Telegram, iMessage, Pushover, Notifications, PixInsight, Pipeline, Automation
+[hide]
+[hide]
+The Notification Event Script provides a way to receive real-time notifications during the execution of the Weighted Batch Preprocessing (WBPP) pipeline in PixInsight. This script supports multiple messaging platforms, including Telegram, iMessage, and Pushover, to send updates, error messages, and image notifications.
+Support for Telegram text-only notifications was originally implemented by Marco Manenti. See his project at https://github.com/verbavolant/eventSendMessageToTelegram.
+Support for Pushover notifications with images was contributed by Brian Weber, whose guide can be found at https://blog.briangweber.com/pushover-setup/.
+[hide]
+In order to use the Notification Event Script with WBPP (Weighted Batch Preprocessing), you first need to configure the notification system you want to use. This is done through the SendMessageToPhone script, which currently allows you to select either Telegram, iMessage, or Pushover as the platform to receive notifications.
+Follow the steps below to configure the notification system:
+Step 1: Open the SendMessageToPhone script in PixInsight's Script Explorer.
+Step 2: Select the messaging platform you want to use: Telegram, iMessage, or Pushover. You will see three radio buttons: one for Telegram, one for iMessage, and one for Pushover. Click the radio button next to the platform you want to use.
+Step 3a: If you selected Telegram, you will have to enter the Telegram Bot Token and Chat ID. To send notifications via Telegram, you'll need to Set up your Telegram Bot first. This feature was originally implemented by Marco Manenti, and a standalone version of his script can be found at https://github.com/verbavolant/eventSendMessageToTelegram.
+Step 3b: If you selected iMessage, enter the Phone Number of the recipient in international format. For iMessage, enter the recipient of the person who will receive the notifications. This is likely your own Apple ID if you'd like to receive the notifications yourself, but technically you could insert any AppleID here. Ensure PixInsight has the rights to execute AppleScript: Run the script standalone once, at which point it will ask for the necessary permissions. Accept.
+Step 3c: If you selected Pushover, enter your User Key and App Token. To use Pushover, you must create an account at https://pushover.net and register a new application. Copy the credentials and paste them into the appropriate fields. Pushover works across all operating systems and does not rely on a specific platform. Setup instructions and examples are available in Brian Weber’s guide at https://blog.briangweber.com/pushover-setup/.
+Step 4: Save the configuration by clicking the Save Parameters button. Once you've filled out the necessary fields, click the Save Parameters button to save your settings. This will store the Bot Token, Chat ID, recipient phone number, and other options so that the script can send notifications during the WBPP process.
+
+An example of a Telegram Bot Configuration
+[hide]
+Notifications typically include:
+ +Example messages:
+ +WBPP started+ + +
ImageIntegration starting: processing 48/62 active frames+ + +
LocalNormalization failed, Cannot open reference image+ + +
WBPP terminated+ + +
ImageIntegration successfully executed+ +
[hide]
+Setting Up a Telegram Bot
+ +Finding Your Telegram Chat ID
+ + "ok": true,
+ "result": [
+ {
+ "update_id": 83xxxxx35,
+ "message": {
+ "message_id": 2643,
+ "from": {...},
+ "chat": {
+ "id": 123456789,
+ "first_name": "...",
+ "last_name": "...",
+ "username": "@username",
+ "type": "private"
+ },
+ "date": 1703062972,
+ "text": "/start"
+ } } ]}
+
+
+
+
[hide]
+[hide]
+Copyright © (c) 2025 Luca Bartek. Telegram contribution by Marco Manenti. Pushover contribution by Brian Weber.
+An extension for WBPP that enables fully customizable pipeline execution using a ProcessContainer object. [more]
Keywords: WBPP, ProcessContainer, Automation, Script Execution, PixInsight, Pipeline Builder
+[hide]
+[hide]
+This extension allows users to define the complete WBPP pipeline through a standard PixInsight ProcessContainer, which acts as a programmable execution list. Each process inside the container is dynamically assigned to a WBPP pipeline stage.
+The WBPP No Code Pipeline Builder is designed for users who want to extend WBPP without coding. It leverages a hierarchy of key=value metadata tags to define when and on which groups a process should run, without editing the WBPP core logic.
+This method offers full control over the execution order and group targeting while making the pipeline fully visible and editable using PixInsight's graphical tools.
+[hide]
+The user creates a ProcessContainer instance. Inside this process container, any number of processes can be added, including other nested ProcessContainer elements.
+Processes will only be executed if at least the step tag is present either on the process level or at a parent level (e.g. on the main process container).
+Each element must declare its intent through a step tag and optional filtering metadata like cam, filter, binning, etc. - any of the user defined keywords from the WBPP instance.
+Once happy with the process, the user saves the ProcessContainer instance as a process icon (by dragging the triangle of the ProcessContainer to the PixInsight desktop. This icon must then be renamed tp WBPP - either by clicking the letter N in the top right corner of the process icon, or by right-clicking the process icon and selecting Set Icon Identifier.
+Please note that once the icon is created for the Process Container instance, its content may not be modified. If a modification is needed, double-click the Process Icon, do the required changes and save it as a new process icon by dragging the blue triangle to the desktop.
+Only one process icon may be present with the identifier WBPP - the old one must be renamed or deleted.
+To find out more about ProcessContainers, click here: Legacy ProcessContainer documentation.
+Key concepts of the No Code Pipeline Builder:
+ +Processes are applied to each matching group and master variant (regular, drizzle, autocrop) in sequence.
+[hide]
+Metadata placed on a container will be inherited by all its children, unless a child overrides it.
+
+Keyword hierarchy/inheritance rules
+[hide]
+These are the valid step values:
+ +Wherever it is not specified that the step is always executed, steps are conditional based on whether the related step is enabled in WBPP.
+[hide]
+In addition to step, any number of custom keys can be added to filter matching groups. Examples include:
+ +A process will be applied only to groups that satisfy all specified conditions. Please note that the above examples are referring to keywords defined by the user in the WBPP Keywords section.
+[hide]
+This makes it easy to apply the same filter to multiple operations while retaining flexibility for exceptions.
+[hide]
+
+An example of a WBPP ProcessContainer defining multiple steps with filtering tags.
+A container with multiple elements:
+ +This will apply resampling on every single sub after the calibration step has finished. It will then apply BlurXTerminator, NoiseXTerminator and an autostretch on every master frame generated.
+[hide]
+Examples of practical applications:
+ +[hide]
+Copyright © (c) 2025 Luca Bartek, Roberto Sartori
+Adds Telegram bot integration to WBPP pipelines, sending real-time status messages and images at key execution points. [more]
Keywords: WBPP, Telegram, Notifications, PixInsight, Pipeline, Automation
+[hide]
+ + +[hide]
+This extension adds Telegram notification support to the Weighted Batch Preprocessing (WBPP) process. Notifications inform the user about pipeline progress, completion, and errors in real time via Telegram messages. This is particularly helpful for long unattended processing tasks or remote system operation.
+[hide]
+To use Telegram notifications, follow these steps:
+ +NotificationEventScript.js+ +, available in the TheSpaceKoala PixInsight repository. After downloading the scripts, you'll find it together in the PixInsight scripts directory.
Setting Up a Telegram Bot
+ +Finding Your Telegram Chat ID
+ +"ok": true,
+ "result": [
+ {
+ "update_id": 83xxxxx35,
+ "message": {
+ "message_id": 2643,
+ "from": {...},
+ "chat": {
+ "id": 123456789,
+ "first_name": "...",
+ "last_name": "...",
+ "username": "@username",
+ "type": "private"
+ },
+ "date": 1703062972,
+ "text": "/start"
+ } } ]}
[hide]
+The script supports the following notification types:
+ +[hide]
+Notifications typically include:
+ +Example messages:
+ +WBPP started+ + +
ImageIntegration starting: processing 48/62 active frames+ + +
LocalNormalization failed, Cannot open reference image+ + +
WBPP terminated+ + +
ImageIntegration successfully executed+ +
[hide]
+Important Notice: The previous Telegram notification script is now deprecated. We recommend switching to the new
+ +NotificationEventScript.js+ +
, which is more flexible and powerful, offering support for multiple platforms and advanced configuration options.
+Copyright © (c) 2025 Luca Bartek, Marco Manenti
+A PixInsight script that sends notifications and images directly to your phone via Telegram, iMessage, or Pushover. [more]
Keywords: Telegram, iMessage, Pushover, Notifications, Image, PixInsight, SendMessageToPhone, Setup, Configuration, Messaging
+[hide]
+[hide]
+The SendMessageToPhone script allows users to send images to their phones directly via Telegram, iMessage (Mac only), or Pushover. This script also serves as the central configurator of things like the NotificationEventScript.
+This document will guide you through the process of setting up the SendMessageToPhone script and using it to send notifications.
+[hide]
+In order to use the SendMessageToPhone script, you need to configure it to send messages and images via your preferred messaging platform: Telegram, iMessage, or Pushover. Follow the detailed steps below to set it up.
+Step 1: Open the SendMessageToPhone script in PixInsight's Script Menu.
+Step 2: Select the messaging platform you would like to use:
+ +Step 3: Configure the necessary fields
+ +
+Step 4: Run the script
+The script will be run on the active image window. If there is no active window, no image will be sent.
+[hide]
+In addition to running it on the active image window, you may also save (any number of) instances as process icons. They may have different parameters. The process icon can be dragged onto any image and the image will be sent out according to the parameters selected.
+[hide]
+The script has a few limitations:
+ +[hide]
+If you face any issues with the notifications, here are some common fixes:
+No notifications received?
+ +Image not received via Pushover
+ +Error: "No valid target image found"
+ +Copyright © (c) 2025 Luca Bartek
+Opens a browser to view the script's documentation.
"; + this.browseDocumentationButton.onClick = function () { + Dialog.browseScriptDocumentation("SendImageToTelegram"); + } + + + // Run Button + this.runButton = new PushButton(this); + this.runButton.text = 'Run'; + this.runButton.icon = this.scaledResource(':/icons/power.png'); + + this.runButton.onClick = () => { + var token = this.tokenInput.text.trim(); + var chatID = this.chatIdInput.value; + var doStretch = this.autoStretchCheckbox.checked; + var linked = this.linkedCheckbox.checked; + var message = this.messageInput.text.trim(); + if (!validateInputs(token, chatID)) { + return; // Exit if validation fails + } + + // Execute the image processing and sending function + if (!ImageWindow.activeWindow.isNull) { + processAndSendImageToTelegram( + ImageWindow.activeWindow, + token, + chatID, + doStretch, + linked, + message + ); + saveTelegramSettings(token, chatID, doStretch, linked, message); // Save settings + this.ok(); // Close the log + } else { + raiseError('No active image window found'); + } + }; + + // Cancel Button + this.cancelButton = new PushButton(this); + this.cancelButton.text = 'Cancel'; + this.cancelButton.icon = this.scaledResource(':/icons/close.png'); + this.cancelButton.onClick = function () { + this.dialog.cancel(); + }; + + // Reset Button + this.resetButton = new ToolButton(this); + this.resetButton.icon = this.scaledResource(':/process-interface/reset.png'); + this.resetButton.setScaledFixedSize(24, 24); + this.resetButton.toolTip = 'Resets all settings to their defaults.
'; + this.resetButton.onClick = () => { + resetTelegramSettings(); + this.tokenInput.text = ''; + this.chatIdInput.setValue(Number.NaN); + this.autoStretchCheckbox.checked = false; + this.linkedCheckbox.checked = false; + this.messageInput.text = ''; + }; + + // Button Layout + var buttonSizer = new HorizontalSizer(); + buttonSizer.spacing = 8; + buttonSizer.add(this.newInstanceButton); + buttonSizer.add(this.browseDocumentationButton); + buttonSizer.addStretch(); + buttonSizer.add(this.runButton); + buttonSizer.add(this.cancelButton); + buttonSizer.add(this.resetButton); + + // Main Layout + this.sizer = new VerticalSizer(); + this.sizer.margin = 10; + this.sizer.spacing = 6; + this.sizer.add(tokenSizer); + this.sizer.add(chatIdSizer); + this.sizer.add(messageSizer); + this.sizer.add(autoStretchSizer); + this.sizer.add(linkedSizer); + this.sizer.addSpacing(8); + this.sizer.add(buttonSizer); + + this.adjustToContents(); +} + +function main() { + printTheSpaceKoalaBanner(); + + // If the process was dragged onto an image, execute immediately without opening the GUI + if (Parameters.isViewTarget) { + let targetWindow = Parameters.targetView.window; + + if (!targetWindow.isNull) { + var token = Parameters.get('telegramBotToken'); + var chatID = Parameters.get('chatID'); + var doStretch = Parameters.get('doStretch'); + var linked = Parameters.get('linked'); + var message = Parameters.get('message'); + + if (!validateInputs(token, chatID)) { + return; // Exit if validation fails + } + + processAndSendImageToTelegram( + targetWindow, + token, + chatID, + doStretch, + linked, + message + ); + } else { + printError('No valid target image found.'); + } + return; + } + + // Otherwise: Open the GUI + let dialog = new TelegramDialog(); + if (!dialog.execute()) { + printInfo('User canceled the script.'); + return; + } +} + +// Extend Dialog prototype +TelegramDialog.prototype = new Dialog(); + +main(); diff --git a/pixinsight_update_bundle/src/scripts/TheSpaceKoala/SendMessageToIMessage.js b/pixinsight_update_bundle/src/scripts/TheSpaceKoala/SendMessageToIMessage.js new file mode 100644 index 0000000..0c702af --- /dev/null +++ b/pixinsight_update_bundle/src/scripts/TheSpaceKoala/SendMessageToIMessage.js @@ -0,0 +1,106 @@ +// ================================================================================== +// SendMessageToIMessage.js +// +// Copyright (c) 2025 Luca Bartek +// Notification Event Script +// Version: V1.0.2 //20250521 +// Author: Luca Bartek +// Website: www.thespacekoala.com +// +// Redistribution and use in both source and binary forms, with or without +// modification, is permitted provided that the following conditions are met: +// +// 1. All redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. All redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// ================================================================================== + +//#include "KoalaUtils.js" + + +// Function to send an iMessage +function sendMessageToIMessage(recipient, message) { + if (CoreApplication.platform != "macOS") { + Console.criticalln("iMessage sending is only available on macOS."); + return; + } + + var script = 'tell application "Messages"\n' + + 'set targetService to first service whose service type = iMessage\n' + + 'set targetBuddy to buddy \"' + recipient + '\" of targetService\n' + + 'send \"' + message + '\" to targetBuddy\n' + + 'end tell'; + + var p = new ExternalProcess(); + p.start("osascript", ["-e", script]); + p.waitForFinished(); + + if (p.exitCode === 0) { + Console.writeln("✅ Message sent successfully."); + } else { + Console.criticalln("❌ Error sending message: " + p.stderr); + } +} + + +// Function to send image via iMessage +function sendImageToIMessage(imagePath, imessageRecipient, message) { + if (!CoreApplication.platform == "macOS") { + printError("iMessage sending is only available on macOS."); + return; + } + + // Define AppleScript for iMessage + var script = + 'tell application "Messages"\n' + + 'set targetService to first service whose service type = iMessage\n' + + 'set targetBuddy to buddy "' + + imessageRecipient + + '" of targetService\n' + + 'send "' + + message + + '" to targetBuddy\n' + + 'send POSIX file "' + + imagePath + + '" to targetBuddy\n' + + 'end tell'; + + var p = new ExternalProcess(); + p.start("osascript", ["-e", script]); + p.waitForFinished(); + + if (p.exitCode === 0) { + Console.writeln("✅ Message sent successfully."); + } else { + Console.criticalln("❌ Error sending message: " + p.stderr); + } +} + +function processAndSendImageToIMessage( + imageWindow, + imessageRecipient, + message, + doStretch, + linked +) { + // Step 1: Duplicate the image window + var duplicateWindow = duplicateImageWindow(imageWindow, 'foobar23204'); +// Step 2: Auto-stretch the image (if needed) + if (doStretch === true) { + applyAutoStretch( + duplicateWindow.mainView ); + } + + // Step 3: Save the image as JPEG + var jpegPath = saveImageAsJpeg(duplicateWindow, null, 'iMessageProcessed'); + + // Step 4: Send the image via iMessage + sendImageToIMessage(jpegPath, imessageRecipient, message); + + // Step 5: Close the duplicate window + duplicateWindow.forceClose(); +} diff --git a/pixinsight_update_bundle/src/scripts/TheSpaceKoala/SendMessageToPhone.js b/pixinsight_update_bundle/src/scripts/TheSpaceKoala/SendMessageToPhone.js new file mode 100644 index 0000000..982fcba --- /dev/null +++ b/pixinsight_update_bundle/src/scripts/TheSpaceKoala/SendMessageToPhone.js @@ -0,0 +1,639 @@ +// ================================================================================== +// SendMessageToPhone.js - A PixInsight script to process an image and send it to Telegram or iMessage +// +// Copyright (c) 2025 Luca Bartek +// +// Send Message To Phone +// Author: Luca Bartek +// Website: www.thespacekoala.com +// +// Redistribution and use in both source and binary forms, with or without +// modification, is permitted provided that the following conditions are met: +// +// 1. All redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. All redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// ================================================================================== + +#feature-id SendMessageToPhone : TheSpaceKoala > SendImageToPhone +#feature-icon messageIcon.svg +#feature-info This script processes the active image and sends it to your phone via the selected service. +#include