Skip to content

Instantly share code, notes, and snippets.

@vladkosinov
Last active October 11, 2015 21:45
Show Gist options
  • Save vladkosinov/12a7b04d0df4b5f2a050 to your computer and use it in GitHub Desktop.
Save vladkosinov/12a7b04d0df4b5f2a050 to your computer and use it in GitHub Desktop.
Send message in telegram from bash script
#!/bin/bash
if [ $# -lt 2 ]; then
echo "Usage: send.bash USER_NAME MESSAGE [DATA ... DATA]"
exit 1
fi
USER=$1
MESSAGE=$2
if [ $# -ge 3 ]; then
DATA=$3;
while shift && [ -n "$3" ]; do
DATA="$DATA $3"
done
MESSAGE="$MESSAGE with data: $DATA"
fi
/usr/bin/telegram -k /etc/telegram/server.pub -W << AAA
msg $USER $MESSAGE
quit
AAA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment