Skip to content

Instantly share code, notes, and snippets.

@claudio4
Last active July 17, 2020 19:06
Show Gist options
  • Save claudio4/81440dd9fcda9cdd3b567b1496fe76df to your computer and use it in GitHub Desktop.
Save claudio4/81440dd9fcda9cdd3b567b1496fe76df to your computer and use it in GitHub Desktop.
Telica
#!/bin/bash
if [ -z "$TG_CHAT_ID" ]; then
echo '$TG_CHAT_ID is not defined' >&2
exit 1
fi
if [ -z "$TG_BOT_TOKEN" ]; then
echo '$TG_BOT_TOKEN is not defined' >&2
exit 1
fi
if [ -z "$*" ]; then
echo "no arguments were provided" >&2
exit 2
fi
if [ "$1" == "-" ]; then
MESSAGE="$( cat )"
else
MESSAGE="$*"
fi
curl -X POST "https://api.telegram.org/bot$TG_BOT_TOKEN/sendMessage" -d "text=$MESSAGE" -d "chat_id=$TG_CHAT_ID"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment