Open ajkblue opened 8 months ago
Can you confirm the version of shoutrrr you tested with? I'm guessing we're on an older version.
I pulled the latest tag from docker, so it appears to be v0.8.0
I did it simpler, add script to the yaml
file:
notify:
urls:
- "script:///opt/scrutiny/bin/signal-notifications.sh"
Mount it in compose file
volumes:
- ${WORKINGDIR}/docker/scrutiny/signal-notifications.sh:/opt/scrutiny/bin/signal-notifications.sh
...
And create this script as signal-notifications.sh
:
#!/bin/bash
# By Georgiy Sitnikov.
# https://github.com/GAS85
# AS-IS without any warranty
signalHost="signal-cli:8080"
signalRegisteredNubmer="+123456789"
signalRecipients="+987654321"
# Replace new lines with \n
signalMessage=$(echo "$SCRUTINY_MESSAGE" | sed ':a;N;$!ba;s/\n/\\n/g')
curl -fsS -m 10 --retry 2 -X POST -H "Content-Type: application/json" "http://$signalHost/v2/send" \
-d "{\"message\": \"$signalMessage\", \"number\": \"$signalRegisteredNubmer\", \"recipients\": [ \"$signalRecipients\" ]}" && exit 0 || exit 1
Thank you, I want to send msg to telegram, But I'm in china with poor network, I tested more than 10 times, all of them failed via Shoutrrr,
I checked network, domain, dns, port, It's all right. and waste much time, finnally find the reason until write my own script that copy from answer above. thanks for your idea.
Shoutrrr's timeout is about 10 seconds, maybe it's too short in some case. in my script, It's 40s worked finnally.
#!/bin/bash
# apt install curl -y
chat_id="your chat id"
telegramToken="your token"
# Replace new lines with \n
signalMessage=$(echo "$SCRUTINY_MESSAGE" | sed ':a;N;$!ba;s/\n/\\n/g')
notification_telegram="curl -X POST --retry 5 --header 'Content-Type: application/json' --data '{\"chat_id\":\"$chat_id\",\"text\":\"$signalMessage\"}' -m 40 https://api.telegram.org/bot$telegramToken/sendMessage"
# eval $notification_telegram
response=$(eval $notification_telegram 2>&1)
status=$?
if [ $status -ne 0 ]; then
echo "telegram send failed curl: $response"
else
echo "telegram send success: $response"
fi
BTW, the cli tool cloud not work
docker run --rm -it containrrr/shoutrrr generate telegram
Generating URL for telegram using telegram generator
To start we need your bot token. If you haven't created a bot yet, you can use this link:
https://t.me/botfather?start
Enter your bot token: xxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Fetching bot info...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x720910]
goroutine 1 [running]:
github.com/containrrr/shoutrrr/pkg/services/telegram.(*Generator).Generate(0xc00016a1b0, {0xc000052030?, 0xc000155c38?}, 0xc000023f80, {0x3?, 0x0?, 0x4?})
/home/runner/work/shoutrrr/shoutrrr/pkg/services/telegram/telegram_generator.go:55 +0x470
github.com/containrrr/shoutrrr/shoutrrr/cmd/generate.Run(0xc3eda0, {0xc00002a800?, 0x1?, 0x8b7ab2?})
/home/runner/work/shoutrrr/shoutrrr/shoutrrr/cmd/generate/generate.go:119 +0x872
github.com/spf13/cobra.(*Command).execute(0xc3eda0, {0xc00002a7d0, 0x1, 0x1})
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:944 +0x863
github.com/spf13/cobra.(*Command).ExecuteC(0xc3e7e0)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992
main.main()
/home/runner/work/shoutrrr/shoutrrr/shoutrrr/main.go:31 +0x1a
@smilence86 did you check documentation? Telegram should be supported out of the box.
Describe the bug When trying to use the generic:// notification option from Shoutrrr, it fails to pass along JSON keys. I am trying to get the Signal CLI working as a means of receiving notifications. At first, it appeared to fail to due Shoutrrr not supporting arrays, but the signal-cli recently allowed for a single
recipient
parameter to be used, which should allow me to send a message. Running the below setup and testing the notifications withpodman exec -it scrutiny-web curl -X POST http://localhost:8080/api/health/notify
gives me this result from Webhook (which is incorrect, thenumber
andrecipient
fields are not respected). This should work, as Shoutrrr supports custom data fields with the$key=value
parameter as shown in the documentation:But, when running the shoutrrr container itself with the exact same parameters:
podman run --rm docker.io/containrrr/shoutrrr send -u 'generic://webhook.site/random-webhook-generated-id-here?template=json&disabletls=yes&$number=%2b12223334444&$recipient=%2b16667779999' --message "MESSAGE"
it does work, and also works when swapping the URL for my local signal API instance as the correct JSON keys are preserved (number and recipient):Expected behavior I expect to be able to send a proper notification to my locally running Signal CLI, testing with Webhook.site.
Config files $HOME/config/scrutiny.yaml
I am running all of this in Podman with the hub-spoke method, the collector is running with sudo permissions while everything else (the influx database and the web interface) are running rootless. All of that works fine, SMART status, dashboard etc... it's only notifications I am struggling with: