Advertisement
Guest User

Untitled

a guest
Mar 30th, 2023
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.33 KB | Source Code | 0 0
  1. #!/bin/sh
  2.  
  3. # Set your Telegram bot token and chat ID
  4. BOT_TOKEN="your_bot_token_here"
  5. CHAT_ID="your_chat_id_here"
  6.  
  7. # Set the folder path where your files are located
  8. FOLDER_PATH="/path/to/folder"
  9.  
  10. # Loop through all files in folder
  11. for file in $FOLDER_PATH/*
  12.     do
  13.         # Check if file is an image
  14.         if [[ "$file" == "*.jpg" ]] || [[ "$file" == "*.jpeg" ]] || [[ "$file" == "*.png" ]] || [[ "$file" == "*.JPG" ]] || [[ "$file" == "*.JPEG" ]] || [[ "$file" == "*.PNG" ]]
  15.         then
  16.             # Upload image to Telegram
  17.             curl -s -F chat_id="$CHAT_ID" -F photo=@"$file" https://api.telegram.org/bot$BOT_TOKEN/sendPhoto > /dev/null
  18.        
  19.         # Check if file is a video
  20.         elif [[ "$file" == "*.mp4" ]] || [[ "$file" == "*.mov" ]] || [[ "$file" == "*.avi" ]] || [[ "$file" == "*.MP4" ]] || [[ "$file" == "*.MOV" ]] || [[ "$file" == "*.AVI" ]]
  21.         then
  22.             # Upload video to Telegram
  23.             curl -s -F chat_id="$CHAT_ID" -F video=@"$file" https://api.telegram.org/bot$BOT_TOKEN/sendVideo > /dev/null
  24.        
  25.         else
  26.             # Upload file to Telegram
  27.             curl -s -F chat_id="$CHAT_ID" -F document=@"$file" https://api.telegram.org/bot$BOT_TOKEN/sendDocument > /dev/null
  28.     fi
  29.  
  30.     # Delete file from folder
  31.     rm "$file"
  32. done
  33.  
  34. echo "All files uploaded to Telegram!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement