From 586098145ec4aa5ecbfa28dcb8176f7409f48adf Mon Sep 17 00:00:00 2001 From: Corrado Mulas Date: Sat, 9 Apr 2022 00:07:28 +0000 Subject: [PATCH] Aggiungi 'telegram-send' Telegram sender script --- telegram-send | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 telegram-send diff --git a/telegram-send b/telegram-send new file mode 100644 index 0000000..371b4ce --- /dev/null +++ b/telegram-send @@ -0,0 +1,23 @@ +#!/bin/bash + +GROUP_ID=-xxxxxxxxxxxxxx +BOT_TOKEN=xxxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + +# this 3 checks (if) are not necessary but should be convenient +if [ "$1" == "-h" ]; then + echo "Usage: `basename $0` \"text message\"" + exit 0 +fi + +if [ -z "$1" ] + then + echo "Add message text as second arguments" + exit 0 +fi + +if [ "$#" -ne 1 ]; then + echo "You can pass only one argument. For string with spaces put it on quotes" + exit 0 +fi + +curl -s --data "text=$1" --data "chat_id=$GROUP_ID" --data "parse_mode=markdown" 'https://api.telegram.org/bot'$BOT_TOKEN'/sendMessage' > /dev/null