async def install(event): if event.fwd_from: return if event.reply_to_msg_id: sedplugin = await event.get_reply_message() try: downloaded_file_name = await event.client.download_media( sedplugin, "FreakyUserbot/modules/", ) if "(" not in downloaded_file_name: path1 = Path(downloaded_file_name) shortname = path1.stem load_module(shortname.replace(".py", "")) await event.edit( "Freaky Has Installed `{}` Sucessfully.".format( os.path.basename(downloaded_file_name) ) ) else: os.remove(downloaded_file_name) await event.edit( "Errors! This plugin is already installed/pre-installed." ) except Exception as e: # pylint:disable=C0103,W0703 await event.edit( f"Error While Installing This Plugin, Please Make Sure That its py Extension. \n**ERROR :** {e}" ) os.remove(downloaded_file_name) await asyncio.sleep(DELETE_TIMEOUT) await event.delete()
async def install(event): if event.fwd_from: return chat = event.pattern_match.group(1) await event.edit( f"Starting To Install Plugins From {chat} ! Check PRIVATE GROUP for More Info !" ) documentss = await borg.get_messages(chat, None, filter=InputMessagesFilterDocument) total = int(documentss.total) total_doxx = range(0, total) for ixo in total_doxx: mxo = documentss[ixo].id downloaded_file_name = await event.client.download_media( await borg.get_messages(chat, ids=mxo), "FreakyUserbot/modules/") if "(" not in downloaded_file_name: path1 = Path(downloaded_file_name) shortname = path1.stem load_module(shortname.replace(".py", "")) sed = f"Installing Plugins From {chat}" logger.info(sed) await borg.send_message( event.chat_id, "Installed Plugin `{}` successfully.".format( os.path.basename(downloaded_file_name)), ) else: await borg.send_message( event.chat_id, "Plugin `{}` has been pre-installed and cannot be installed.". format(os.path.basename(downloaded_file_name)), )
async def install(event): if event.fwd_from: return chat = Var.PLUGIN_CHANNEL documentss = await borg.get_messages(chat, None, filter=InputMessagesFilterDocument) total = int(documentss.total) total_doxx = range(0, total) await event.delete() for ixo in total_doxx: mxo = documentss[ixo].id downloaded_file_name = await event.client.download_media( await borg.get_messages(chat, ids=mxo), "FreakyUserbot/modules/") if "(" not in downloaded_file_name: path1 = Path(downloaded_file_name) shortname = path1.stem load_module(shortname.replace(".py", "")) await borg.send_message( event.chat_id, "Installed Plugin `{}` successfully.".format( os.path.basename(downloaded_file_name)), ) else: await borg.send_message( event.chat_id, "Plugin `{}` has been pre-installed and cannot be installed.". format(os.path.basename(downloaded_file_name)), )
async def load(event): if event.fwd_from: return shortname = event.pattern_match.group(1) try: try: remove_plugin(shortname) except: pass load_module(shortname) await event.edit(f"Successfully loaded {shortname}") except Exception as e: await event.edit( f"Could not load {shortname} because of the following error.\n{str(e)}" )
async def get_all_modules(event, borg, channel_id): await event.edit(f"Ìnstalling All Plugins from {channel_id}") try: a_plugins = await borg.get_messages( entity=channel_id, filter=InputMessagesFilterDocument, limit=None, search=".py", ) except: await event.edit( "`Failed To Retrieve Modules. Please Check Channel Username / Id. Make Sure You Are On That Channel`" ) return yesm = 0 nom = 0 len_p = int(a_plugins.total) if len_p == 0: await event.edit("**No PLugins Found To Load !**") return await event.edit(f"**Found : {len_p} Plugins. Trying To Install**") for sed in a_plugins: try: downloaded_file_name = await borg.download_media( sed, "FreakyUserbot/modules/") if "(" not in downloaded_file_name: path1 = Path(downloaded_file_name) shortname = path1.stem load_module(shortname.replace(".py", "")) await event.edit("**Installed :** `{}`".format( os.path.basename(downloaded_file_name))) else: nom += 1 await event.edit( "**Failed to Install [PLugin Already Found] :** `{}`". format(os.path.basename(downloaded_file_name))) os.remove(downloaded_file_name) except: await event.edit("**Failed To Install :** `{}`".format( os.path.basename(downloaded_file_name))) os.remove(downloaded_file_name) nom += 1 yesm = len_p - nom return yesm, nom, len_p
bot.freakybot = TelegramClient( "TG_BOT_TOKEN", api_id=Var.APP_ID, api_hash=Var.API_HASH).start(bot_token=Var.TG_BOT_TOKEN_BF_HER) bot.loop.run_until_complete(add_bot(Var.TG_BOT_USER_NAME_BF_HER)) else: bot.start() import glob path = "FreakyUserbot/modules/*.py" files = glob.glob(path) for name in files: with open(name) as f: path1 = Path(f.name) shortname = path1.stem load_module(shortname.replace(".py", "")) if Config.ENABLE_ASSISTANTBOT == "ENABLE": path = "FreakyUserbot/modules/assistant/*.py" files = glob.glob(path) for name in files: with open(name) as f: path1 = Path(f.name) shortname = path1.stem start_assistant(shortname.replace(".py", "")) sed.info("""\n @ProjectHackfreaks """) else: sed.info("Freaky Has Been Installed Sucessfully !") sed.info("You Can Visit @FreakyUserbot For Any Support Or Doubts") if len(argv) not in (1, 3, 4):