Skip to content

Instantly share code, notes, and snippets.

@ChatchaiJ
Created August 23, 2015 16:49
Show Gist options
  • Save ChatchaiJ/4a4a9bc5460c69e851d5 to your computer and use it in GitHub Desktop.
Save ChatchaiJ/4a4a9bc5460c69e851d5 to your computer and use it in GitHub Desktop.
#!/bin/bash
MSG="$1"
[ -z "$MSG" ] && exit
RES="/tmp/sendMessage.$$"
LOG="/tmp/bot_sendmessage.log"
BOTTOKEN="${HOME}/.tgbot-token"
[ ! -f "$BOTTOKEN" ] && exit
TOKEN=`cat $BOTTOKEN`
BOTAPI="https://api.telegram.org/bot"
SENDMSG="${BOTAPI}${TOKEN}/sendMessage"
CHAT_ID="83784241"
curl -s -S -H 'Content-Type: application/x-www-form-urlencoded' \
-X POST \
-d "chat_id=$CHAT_ID" \
-d "text=$MSG" \
$SENDMSG > $RES
D=`date`
echo "$D `id -u` sent '$MSG' -- `cat $RES`" >> $LOG
rm -f $RES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment