- Create a bot using @BotFather, get it's token
- Start conversation with bot
- Run following curl command
curl https://api.telegram.org/bot<TO:KEN>/getUpdates | grep -Po '"from":{"id":.+?,'
or
- Go to @getmyid_bot and obtain your account id
- Create a bot using @BotFather, get it's token
- Invite your bot to desired chat
- Write message like this
/test @your_bot_tag
- Run following curl command
curl https://api.telegram.org/bot<TO:KEN>/getUpdates | grep -Po '"chat":{"id":.+?,'
You will get output like the one below, keep chat id:
"chat":{"id":-1001182736542,
Environment variables used in examples
# bot token
$TOKEN=abc:de123
# your acc or group chat id
$CHAT_ID=12345
curl -X POST -H "Content-Type:multipart/form-data" -F chat_id=$CHAT_ID -F
text="message" "https://api.telegram.org/bot$TOKEN
/sendMessage"
curl -X POST -H "Content-Type:multipart/form-data" -F
document=@"path/to/some.file" "https://api.telegram.org/bot$TOKEN
/sendDocument"
Creating qr code from string, piping stdout to curl, sending it as an image
qrencode -s 6 -o - "Some text to encode" | curl -X POST -H "Content-Type:multipart/form-data" -F chat_id=$CHAT_ID -F
photo=@- "https://api.telegram.org/bot$TOKEN/
sendPhoto"
/sendAudio
audio
/sendPhoto
photo
/sendVideo
video
/sendAnimation
animation
/sendVoice
voice
/sendVideoNote
video_note