Minor changes.
This commit is contained in:
29
scripts/unix/usr/local/bin/send-telegram
Normal file
29
scripts/unix/usr/local/bin/send-telegram
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_NAME=$0
|
||||
MESSAGE_TEXT=$1
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "You can pass only one argument. For string with spaces put it on quotes"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ARGS=$(xargs echo $(perl -anle 's/^[^:]+//g && s/:\s+//g && print' /etc/email.conf) < /dev/null)
|
||||
set -- $ARGS "$@";
|
||||
|
||||
GROUP_ID=$1
|
||||
BOT_TOKEN=$2
|
||||
|
||||
# this 3 checks (if) are not necessary but should be convenient
|
||||
if [ "${MESSAGE_TEXT}" == "-h" ]; then
|
||||
echo "Usage: `basename ${SCRIPT_NAME}` \"text message\""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "${MESSAGE_TEXT}" ]
|
||||
then
|
||||
echo "Add message text as second arguments"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
curl -s --data "text=${MESSAGE_TEXT}" --data "chat_id=$GROUP_ID" 'https://api.telegram.org/bot'$BOT_TOKEN'/sendMessage' > /dev/null
|
||||
Reference in New Issue
Block a user