Skip to content

Instantly share code, notes, and snippets.

@vshmoylov
Last active December 11, 2020 16:19
Show Gist options
  • Save vshmoylov/2ed97dcc0f96e2763c0a1b3c1a85c23c to your computer and use it in GitHub Desktop.
Save vshmoylov/2ed97dcc0f96e2763c0a1b3c1a85c23c to your computer and use it in GitHub Desktop.
#!/bin/sh
TG_BOT_KEY="YOUR_KEY_FROM_BOTFATHER_HERE"
# TODO: parse response and return non-zero code on error
function telegram_notify(){ curl -d "{\"chat_id\": $1, \"text\": \"$2\", \"parse_mode\": \"$3\"}" -H "Content-Type: application/json" -s -X POST https://api.telegram.org/bot$TG_BOT_KEY/sendMessage >/dev/null ; }
# you can get chat id from @getidsbot bot: https://t.me/getidsbot
# before sending message from bot to user/channel, you should start your bot there
telegram_notify $CHAT_ID_HERE "plain text"
telegram_notify $CHAT_ID_HERE "_Markdown_ *text*" MarkdownV2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment