diff --git a/FIXXMUSIC/plugins/tools/clone.py b/FIXXMUSIC/plugins/tools/clone.py deleted file mode 100644 index 94f4f73..0000000 --- a/FIXXMUSIC/plugins/tools/clone.py +++ /dev/null @@ -1,188 +0,0 @@ -import re -import logging -import asyncio -import importlib -from sys import argv -from pyrogram import idle -from pyrogram import Client, filters -from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton -from pyrogram.errors.exceptions.bad_request_400 import ( - AccessTokenExpired, - AccessTokenInvalid, -) -from FIXXMUSIC.utils.database import get_assistant -from config import API_ID, API_HASH -from FIXXMUSIC import app -from FIXXMUSIC.misc import SUDOERS -from FIXXMUSIC.utils.database import get_assistant, clonebotdb -from config import LOGGER_ID - -CLONES = set() - - -@app.on_message(filters.command("vashuclone" , "vclone") & SUDOERS) -async def clone_txt(client, message): - userbot = await get_assistant(message.chat.id) - if len(message.command) > 1: - bot_token = message.text.split("/clone", 1)[1].strip() - mi = await message.reply_text("Please wait while I process the bot token salee clone mat bana please andy bandy sandy ager tune clone banaya to tere maa randi.") - try: - ai = Client( - bot_token, - API_ID, - API_HASH, - bot_token=bot_token, - plugins=dict(root="FIXXMUSIC.plugin"), - ) - await ai.start() - bot = await ai.get_me() - bot_users = await ai.get_users(bot.username) - bot_id = bot_users.id - - except (AccessTokenExpired, AccessTokenInvalid): - await mi.edit_text( - "You have provided an invalid bot token. Please provide a valid bot token sun clone mat bana bhenchod." - ) - return - except Exception as e: - await mi.edit_text(f"An error occurred: {str(e)}") - return - - # Proceed with the cloning process - await mi.edit_text( - "Cloning process started. Please wait for the bot to be start." - ) - try: - - await app.send_message( - LOGGER_ID, f"**#New_Clones**\n\n**Bot:- @{bot.username}**" - ) - await userbot.send_message(bot.username, "/start") - - details = { - "bot_id": bot.id, - "is_bot": True, - "user_id": message.from_user.id, - "name": bot.first_name, - "token": bot_token, - "username": bot.username, - } - clonebotdb.insert_one(details) - CLONES.add(bot.id) - await mi.edit_text( - f"Bot @{bot.username} has been successfully cloned and started ✅.\n**Remove cloned by :- /delclone**" - ) - except BaseException as e: - logging.exception("Error while cloning bot.") - await mi.edit_text( - f"⚠️ ᴇʀʀᴏʀ:\n\n{e}\n\n**ᴋɪɴᴅʟʏ ғᴏᴡᴀʀᴅ ᴛʜɪs ᴍᴇssᴀɢᴇ ᴛᴏ @Vashu23456 ᴛᴏ ɢᴇᴛ ᴀssɪsᴛᴀɴᴄᴇ**" - ) - else: - await message.reply_text( - "**Give Bot Token After /clone Command From @Botfather.**" - ) - - -@app.on_message( - filters.command( - [ - "deletecloned", - "delcloned", - "delclone", - "deleteclone", - "removeclone", - "cancelclone", - ] - ) -) -async def delete_cloned_bot(client, message): - try: - if len(message.command) < 2: - await message.reply_text( - "**⚠️ Please provide the bot token after the command.**" - ) - return - - bot_token = " ".join(message.command[1:]) - await message.reply_text("Processing the bot token...") - - cloned_bot = clonebotdb.find_one({"token": bot_token}) - if cloned_bot: - clonebotdb.delete_one({"token": bot_token}) - CLONES.remove(cloned_bot["bot_id"]) - await message.reply_text( - "**🤖 your cloned bot has been disconnected from my server ☠️\nClone by :- /clone**" - ) - await restart_bots() - # Call restart function here after successful deletion - else: - await message.reply_text( - "**⚠️ The provided bot token is not in the cloned list.**" - ) - except Exception as e: - await message.reply_text("An error occurred while deleting the cloned bot.") - logging.exception(e) - - -async def restart_bots(): - global CLONES - try: - logging.info("Restarting all cloned bots........") - bots = list(clonebotdb.find()) - for bot in bots: - bot_token = bot["token"] - ai = Client( - f"{bot_token}", - API_ID, - API_HASH, - bot_token=bot_token, - plugins=dict(root="FIXXMUSIC.cplugin"), - ) - await ai.start() - bot = await ai.get_me() - if bot.id not in CLONES: - try: - CLONES.add(bot.id) - except Exception: - pass - except Exception as e: - logging.exception("Error while restarting bots.") - - -@app.on_message(filters.command("vashucloned" , "Bhenchodclonematkar") & SUDOERS) -async def list_cloned_bots(client, message): - try: - cloned_bots = list(clonebotdb.find()) - if not cloned_bots: - await message.reply_text("No bots have been cloned yet.") - return - - total_clones = len(cloned_bots) - text = f"**Total Cloned Bots: {total_clones}**\n\n" - - for bot in cloned_bots: - text += f"**Bot ID:** {bot['bot_id']}\n" - text += f"**Bot Name:** {bot['name']}\n" - text += f"**Bot Username:** @{bot['username']}\n\n" - - await message.reply_text(text) - except Exception as e: - logging.exception(e) - await message.reply_text("An error occurred while listing cloned bots.") - - -@app.on_message(filters.command("delallclone") & SUDOERS) -async def delete_all_cloned_bots(client, message): - try: - await message.reply_text("Deleting all cloned bots...") - - # Delete all cloned bots from the database - clonebotdb.delete_many({}) - - # Clear the CLONES set - CLONES.clear() - - await message.reply_text("All cloned bots have been deleted successfully.") - except Exception as e: - await message.reply_text("An error occurred while deleting all cloned bots.") - logging.exception(e)