import telebot
import os
TOKEN = 'your_bot_token'
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(content_types=['document', 'audio', 'video', 'photo'])
def file_type(message):
file_id = message.document.file_id if message.content_type == 'document' else \
message.audio.file_id if message.content_type == 'audio' else \
message.video.file_id if message.content_type == 'video' else \
message.photo[-1].file_id if message.content_type == 'photo' else None
if file_id:
file_info = bot.get_file(file_id)
file_extension = os.path.splitext(file_info.file_path)[-1].lower()
if file_extension in ['.jpg', '.jpeg', '.png', '.gif']:
bot.reply_to(message, "Это изображение.")
elif file_extension in ['.mp3', '.wav', '.flac']:
bot.reply_to(message, "Это аудиофайл.")
elif file_extension in ['.mp4', '.avi', '.mkv']:
bot.reply_to(message, "Это видеофайл.")
elif file_extension in ['.doc', '.docx', '.txt']:
bot.reply_to(message, "Это документ.")
else:
bot.reply_to(message, "Неизвестный тип файла.")
else:
bot.reply_to(message, "Не удалось определить тип файла.")
bot.polling()
Памагите