fork download
  1.  
  2. import telebot
  3. import requests
  4.  
  5. # Replace 'YOUR_BOT_TOKEN' with your actual bot token obtained from BotFather
  6. bot = telebot.TeleBot('YOUR_BOT_TOKEN')
  7.  
  8. @bot.message_handler(commands=['start', 'help'])
  9. def send_welcome(message):
  10. bot.reply_to(message, "Welcome to the TikTok Video Downloader Bot! Please send me a TikTok video link.")
  11.  
  12. @bot.message_handler(func=lambda message: True)
  13. def download_video(message):
  14. video_url = message.text
  15. if 'tiktok.com' in video_url:
  16. try:
  17. response = requests.get(video_url)
  18. video_file = response.content
  19. bot.send_video(message.chat.id, video_file)
  20. except:
  21. bot.reply_to(message, "Sorry, I couldn't download the video. Please make sure the link is valid.")
  22. else:
  23. bot.reply_to(message, "Please send a valid TikTok video link.")
  24.  
  25. bot.polling()
  26.  
Success #stdin #stdout 0.03s 25852KB
stdin
Standard input is empty
stdout
import telebot
import requests

# Replace 'YOUR_BOT_TOKEN' with your actual bot token obtained from BotFather
bot = telebot.TeleBot('YOUR_BOT_TOKEN')

@bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
    bot.reply_to(message, "Welcome to the TikTok Video Downloader Bot! Please send me a TikTok video link.")

@bot.message_handler(func=lambda message: True)
def download_video(message):
    video_url = message.text
    if 'tiktok.com' in video_url:
        try:
            response = requests.get(video_url)
            video_file = response.content
            bot.send_video(message.chat.id, video_file)
        except:
            bot.reply_to(message, "Sorry, I couldn't download the video. Please make sure the link is valid.")
    else:
        bot.reply_to(message, "Please send a valid TikTok video link.")

bot.polling()