labnotes

Telegram with curl

so easy to send messages

tags
telegram
bot
curl

For getting messages in private chat with bot

  1. Create a bot using @BotFather, get it's token
  2. Start conversation with bot
  3. Run following curl command
1
2
3
4
  export TELEGRAM_CHAT_ID=$(
      curl https://api.telegram.org/bot${TELEGRAM_TOKEN}/getUpdates |
          jq '.result[0].message.chat.id'
         )

Send a simple message

1
2
3
4
5
  curl -X POST \
       -H "Content-Type:multipart/form-data" \
       -F chat_id=$TELEGRAM_CHAT_ID \
       -F text="Hello this is my message" \
       https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage

Send a photo

Get a file, say like this

1
  shot-scraper https://willschenk.com -h 600 -o screenshot.png

And once you have a file, send it like this:

1
2
3
4
5
  curl -X POST \
       -H "Content-Type:multipart/form-data" \
       -F chat_id=$TELEGRAM_CHAT_ID \
       -F photo=@"screenshot.png" \
       https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendPhoto

Send a document

1
2
3
4
5
  curl -X POST \
       -H "Content-Type:multipart/form-data" \
       -F chat_id=$TELEGRAM_CHAT_ID \
       -F document=@"open_web_ui.org" \
       https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument

Previously

labnotes

Using act to test github actions locally

code on microsofts dime

tags
act
github

Next

labnotes

Roda + Sequel

maybe its time to move past sinatra

tags
ruby
roda
sequel