Просмотр исходного кода

Merge branch 'main' of github.com:binwiederhier/ntfy into ipv6

binwiederhier 7 месяцев назад
Родитель
Сommit
aead619dea

+ 19 - 0
cmd/publish.go

@@ -69,6 +69,7 @@ Examples:
   ntfy pub --icon="http://some.tld/icon.png" 'Icon!'      # Send notification with custom icon
   ntfy pub --icon="http://some.tld/icon.png" 'Icon!'      # Send notification with custom icon
   ntfy pub --attach="http://some.tld/file.zip" files      # Send ZIP archive from URL as attachment
   ntfy pub --attach="http://some.tld/file.zip" files      # Send ZIP archive from URL as attachment
   ntfy pub --file=flower.jpg flowers 'Nice!'              # Send image.jpg as attachment
   ntfy pub --file=flower.jpg flowers 'Nice!'              # Send image.jpg as attachment
+  echo 'message' | ntfy publish mytopic                   # Send message from stdin
   ntfy pub -u phil:mypass secret Psst                     # Publish with username/password
   ntfy pub -u phil:mypass secret Psst                     # Publish with username/password
   ntfy pub --wait-pid 1234 mytopic                        # Wait for process 1234 to exit before publishing
   ntfy pub --wait-pid 1234 mytopic                        # Wait for process 1234 to exit before publishing
   ntfy pub --wait-cmd mytopic rsync -av ./ /tmp/a         # Run command and publish after it completes
   ntfy pub --wait-cmd mytopic rsync -av ./ /tmp/a         # Run command and publish after it completes
@@ -254,6 +255,15 @@ func parseTopicMessageCommand(c *cli.Context) (topic string, message string, com
 	if c.String("message") != "" {
 	if c.String("message") != "" {
 		message = c.String("message")
 		message = c.String("message")
 	}
 	}
+	if message == "" && isStdinRedirected() {
+		var data []byte
+		data, err = io.ReadAll(io.LimitReader(c.App.Reader, 1024*1024))
+		if err != nil {
+			log.Debug("Failed to read from stdin: %s", err.Error())
+			return
+		}
+		message = strings.TrimSpace(string(data))
+	}
 	return
 	return
 }
 }
 
 
@@ -312,3 +322,12 @@ func runAndWaitForCommand(command []string) (message string, err error) {
 	log.Debug("Command succeeded after %s: %s", runtime, prettyCmd)
 	log.Debug("Command succeeded after %s: %s", runtime, prettyCmd)
 	return fmt.Sprintf("Command succeeded after %s: %s", runtime, prettyCmd), nil
 	return fmt.Sprintf("Command succeeded after %s: %s", runtime, prettyCmd), nil
 }
 }
+
+func isStdinRedirected() bool {
+	stat, err := os.Stdin.Stat()
+	if err != nil {
+		log.Debug("Failed to stat stdin: %s", err.Error())
+		return false
+	}
+	return (stat.Mode() & os.ModeCharDevice) == 0
+}

+ 0 - 2
docker-compose.yml

@@ -1,4 +1,3 @@
-version: "2.1"
 services:
 services:
   ntfy:
   ntfy:
     image: binwiederhier/ntfy
     image: binwiederhier/ntfy
@@ -14,4 +13,3 @@ services:
     ports:
     ports:
       - 80:80
       - 80:80
     restart: unless-stopped
     restart: unless-stopped
-

+ 0 - 2
docs/config.md

@@ -79,7 +79,6 @@ using Docker Compose (i.e. `docker-compose.yml`):
 
 
 === "Docker Compose (w/ auth, cache, attachments)"
 === "Docker Compose (w/ auth, cache, attachments)"
     ``` yaml
     ``` yaml
-	version: '3'
 	services:
 	services:
 	  ntfy:
 	  ntfy:
 	    image: binwiederhier/ntfy
 	    image: binwiederhier/ntfy
@@ -101,7 +100,6 @@ using Docker Compose (i.e. `docker-compose.yml`):
 
 
 === "Docker Compose (w/ auth, cache, web push, iOS)"
 === "Docker Compose (w/ auth, cache, web push, iOS)"
     ``` yaml
     ``` yaml
-	version: '3'
 	services:
 	services:
 	  ntfy:
 	  ntfy:
 	    image: binwiederhier/ntfy
 	    image: binwiederhier/ntfy

+ 3 - 3
docs/index.md

@@ -3,9 +3,9 @@ ntfy lets you **send push notifications to your phone or desktop via scripts fro
 or POST requests. I use it to notify myself when scripts fail, or long-running commands complete.
 or POST requests. I use it to notify myself when scripts fail, or long-running commands complete.
 
 
 ## Step 1: Get the app
 ## Step 1: Get the app
-<a href="https://play.google.com/store/apps/details?id=io.heckel.ntfy"><img src="static/img/badge-googleplay.png"></a>
-<a href="https://f-droid.org/en/packages/io.heckel.ntfy/"><img src="static/img/badge-fdroid.png"></a>
-<a href="https://apps.apple.com/us/app/ntfy/id1625396347"><img src="static/img/badge-appstore.png"></a>
+<a href="https://play.google.com/store/apps/details?id=io.heckel.ntfy"><img width="170" src="static/img/badge-googleplay.png"></a>
+<a href="https://f-droid.org/en/packages/io.heckel.ntfy/"><img width="170" src="static/img/badge-fdroid.png"></a>
+<a href="https://apps.apple.com/us/app/ntfy/id1625396347"><img width="150" src="static/img/badge-appstore.png"></a>
 
 
 To [receive notifications on your phone](subscribe/phone.md), install the app, either via Google Play, App Store or F-Droid.
 To [receive notifications on your phone](subscribe/phone.md), install the app, either via Google Play, App Store or F-Droid.
 Once installed, open it and subscribe to a topic of your choosing. Topics don't have to explicitly be created, so just
 Once installed, open it and subscribe to a topic of your choosing. Topics don't have to explicitly be created, so just

+ 0 - 2
docs/install.md

@@ -280,8 +280,6 @@ docker run \
 
 
 Using docker-compose with non-root user and healthchecks enabled:
 Using docker-compose with non-root user and healthchecks enabled:
 ```yaml
 ```yaml
-version: "2.3"
-
 services:
 services:
   ntfy:
   ntfy:
     image: binwiederhier/ntfy
     image: binwiederhier/ntfy

+ 1 - 0
docs/integrations.md

@@ -95,6 +95,7 @@ I've added a ⭐ to projects or posts that have a significant following, or had
 - [wlzntfy](https://github.com/Walzen-Group/ntfy-toaster) - A minimalistic, receive-only toast notification client for Windows 11
 - [wlzntfy](https://github.com/Walzen-Group/ntfy-toaster) - A minimalistic, receive-only toast notification client for Windows 11
 - [Ntfy_CSV_Reminders](https://github.com/thiswillbeyourgithub/Ntfy_CSV_Reminders) - A Python tool that sends random-timing phone notifications for recurring tasks by using daily probability checks based on CSV-defined frequencies.
 - [Ntfy_CSV_Reminders](https://github.com/thiswillbeyourgithub/Ntfy_CSV_Reminders) - A Python tool that sends random-timing phone notifications for recurring tasks by using daily probability checks based on CSV-defined frequencies.
 - [Daily Fact Ntfy](https://github.com/thiswillbeyourgithub/Daily_Fact_Ntfy) - Generate [llm](https://github.com/simonw/llm) generated fact every day about any topic you're interested in.
 - [Daily Fact Ntfy](https://github.com/thiswillbeyourgithub/Daily_Fact_Ntfy) - Generate [llm](https://github.com/simonw/llm) generated fact every day about any topic you're interested in.
+- [ntfyexec](https://github.com/alecthomas/ntfyexec) - Send a notification through ntfy.sh if a command fails
 
 
 ## Projects + scripts 
 ## Projects + scripts 
 
 

BIN
docs/static/img/badge-appstore.png


BIN
docs/static/img/badge-fdroid.png


BIN
docs/static/img/badge-googleplay.png


+ 3 - 3
docs/subscribe/phone.md

@@ -4,9 +4,9 @@ to receive notifications directly on your phone. Just like the server, this app
 on GitHub ([Android](https://github.com/binwiederhier/ntfy-android), [iOS](https://github.com/binwiederhier/ntfy-ios)). Feel free to 
 on GitHub ([Android](https://github.com/binwiederhier/ntfy-android), [iOS](https://github.com/binwiederhier/ntfy-ios)). Feel free to 
 contribute, or [build your own](../develop.md).
 contribute, or [build your own](../develop.md).
 
 
-<a href="https://play.google.com/store/apps/details?id=io.heckel.ntfy"><img src="../../static/img/badge-googleplay.png"></a>
-<a href="https://f-droid.org/en/packages/io.heckel.ntfy/"><img src="../../static/img/badge-fdroid.png"></a>
-<a href="https://apps.apple.com/us/app/ntfy/id1625396347"><img src="../../static/img/badge-appstore.png"></a>
+<a href="https://play.google.com/store/apps/details?id=io.heckel.ntfy"><img width="170" src="../../static/img/badge-googleplay.png"></a>
+<a href="https://f-droid.org/en/packages/io.heckel.ntfy/"><img width="170" src="../../static/img/badge-fdroid.png"></a>
+<a href="https://apps.apple.com/us/app/ntfy/id1625396347"><img width="150" src="../../static/img/badge-appstore.png"></a>
 
 
 You can get the Android app from both [Google Play](https://play.google.com/store/apps/details?id=io.heckel.ntfy) and 
 You can get the Android app from both [Google Play](https://play.google.com/store/apps/details?id=io.heckel.ntfy) and 
 from [F-Droid](https://f-droid.org/en/packages/io.heckel.ntfy/). Both are largely identical, with the one exception that
 from [F-Droid](https://f-droid.org/en/packages/io.heckel.ntfy/). Both are largely identical, with the one exception that