|
|
|
|
|
|
|
|
|
|
|
from telegram import Update |
|
from telegram.ext import CommandHandler, ContextTypes |
|
|
|
from Mikobot import function |
|
from Mikobot.state import state |
|
|
|
|
|
|
|
DOWNLOADING_STICKER_ID = ( |
|
"CAACAgIAAxkBAAEDv_xlJWmh2-fKRwvLywJaFeGy9wmBKgACVQADr8ZRGmTn_PAl6RC_MAQ" |
|
) |
|
API_URL = "https://karma-api2.vercel.app/instadl" |
|
|
|
|
|
|
|
async def instadl_command_handler(update: Update, context: ContextTypes.DEFAULT_TYPE): |
|
if len(context.args) < 1: |
|
await update.message.reply_text("Usage: /instadl [Instagram URL]") |
|
return |
|
|
|
link = context.args[0] |
|
try: |
|
downloading_sticker = await update.message.reply_sticker(DOWNLOADING_STICKER_ID) |
|
|
|
|
|
response = await state.get(API_URL, params={"url": link}) |
|
data = response.json() |
|
|
|
|
|
if "content_url" in data: |
|
content_url = data["content_url"] |
|
|
|
|
|
content_type = "video" if "video" in content_url else "photo" |
|
|
|
|
|
if content_type == "photo": |
|
await update.message.reply_photo(content_url) |
|
elif content_type == "video": |
|
await update.message.reply_video(content_url) |
|
else: |
|
await update.message.reply_text("Unsupported content type.") |
|
else: |
|
await update.message.reply_text( |
|
"Unable to fetch content. Please check the Instagram URL or try with another Instagram link." |
|
) |
|
|
|
except Exception as e: |
|
print(e) |
|
await update.message.reply_text( |
|
"An error occurred while processing the request." |
|
) |
|
|
|
finally: |
|
await downloading_sticker.delete() |
|
|
|
|
|
function( |
|
CommandHandler(["ig", "instagram", "insta", "instadl"], instadl_command_handler) |
|
) |
|
|
|
|