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), "WhiteEyeUserBot/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), "WhiteEyeUserBot/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 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, "WhiteEyeUserBot/modules/", ) if "(" not in downloaded_file_name: path1 = Path(downloaded_file_name) shortname = path1.stem load_module(shortname.replace(".py", "")) await event.edit( "WhiteEye 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 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, "WhiteEyeUserBot/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
failed2, failed3 = multiple_client() if Config.LOAD_OTHER_PLUGINS: bot.loop.run_until_complete(get_other_plugins(Config, bot, whiteeyedevs)) import glob path = "WhiteEyeUserBot/modules/*.py" files = glob.glob(path) failed_warner = 0 for name in files: with open(name) as f: path1 = Path(f.name) shortname = path1.stem try: load_module(shortname.replace(".py", "")) except Exception as e: failed_warner += 1 whiteeyedevs.info("------------------------") whiteeyedevs.info( "Failed To Load : " + str(shortname.replace(".py", "")) + f" Error : {str(e)}" ) whiteeyedevs.info("------------------------") if failed2 is None: try: load_module_dclient(shortname.replace(".py", ""), client2) except: pass if failed3 is None: