]> 91.132.146.200 Git - klimbim.git/commitdiff
simple telegram notify
authorBanana <mail@bananas-playground.net>
Wed, 5 Jan 2022 19:11:07 +0000 (20:11 +0100)
committerBanana <mail@bananas-playground.net>
Wed, 5 Jan 2022 19:11:07 +0000 (20:11 +0100)
bash/telegram-notify.sh [new file with mode: 0644]

diff --git a/bash/telegram-notify.sh b/bash/telegram-notify.sh
new file mode 100644 (file)
index 0000000..a40f66c
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
+#
+# You should have received a copy of the
+# COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+# along with this program.  If not, see http://www.sun.com/cddl/cddl.html
+#
+# 2022 http://www.bananas-playground.net
+
+# this is a simple bash script witch accepts a text input as arg1 or pipe
+# and writes this text to your telegram chat
+# https://core.telegram.org/bots
+# https://core.telegram.org/bots#6-botfather
+
+
+BOTTOKEN="xxxxxxxxxxxxxxxx"
+CHAT_ID="xxxxxxxxxxx"
+URL="https://api.telegram.org/bot$BOTTOKEN/sendMessage"
+
+INPUT_TEXT="Something is ready..."
+if test -n "$1"; then
+       INPUT_TEXT=$1;
+elif test ! -t 0; then
+       INPUT_TEXT=$(</dev/stdin)
+fi
+
+curl -s -X POST -H 'Content-Type: application/json' -d '{"chat_id": "'${CHAT_ID}'", "text": "'"${INPUT_TEXT}"'", "disable_notification": false}' ${URL} > /dev/null 2>&1