Skip to content

Instantly share code, notes, and snippets.

@HirbodBehnam
Last active November 28, 2023 22:52
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save HirbodBehnam/d7a46fac29f5e1f664d467d5a05620dd to your computer and use it in GitHub Desktop.
Save HirbodBehnam/d7a46fac29f5e1f664d467d5a05620dd to your computer and use it in GitHub Desktop.
A dead simple script to upload files on your server through Telegram bot
#!/bin/bash
# This is a simple script that takes some files as arguments and sends them to a special chat
# Just create a new bot at @BotFather and get your chat ID from @myidbot and enter them here
# You can also make a shortcut in '~/.bashrc' like "alias tg='bash /opt/scripts/tg.sh'"
# After that restart bash and use it like 'tg file1.txt file2.jpg'
# EDIT TOKEN and CHAT_ID:
TOKEN="TOKEN"
CHAT_ID="12341234"
# Make sure curl is installed
for arg in "$@"
do
curl -X POST -H "content-type: multipart/form-data" -F document=@"$arg" -F chat_id=$CHAT_ID https://api.telegram.org/bot$TOKEN/sendDocument
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment