Skip to content

Instantly share code, notes, and snippets.

@forestbaker
Forked from vladkosinov/send_text_with_data
Created October 11, 2015 21:45
Show Gist options
  • Save forestbaker/c4c50982408365139e6a to your computer and use it in GitHub Desktop.
Save forestbaker/c4c50982408365139e6a 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