async def install(event): if event.fwd_from: return if event.reply_to_msg_id: try: downloaded_file_name = ( await event.client.download_media( # pylint:disable=E0602 await event.get_reply_message(), "pearl/modules/", # pylint:disable=E0602 )) if "(" not in downloaded_file_name: path1 = Path(downloaded_file_name) shortname = path1.stem load_module(shortname.replace(".py", "")) await event.edit( "BLACK PEARL 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(str(e)) os.remove(downloaded_file_name) await asyncio.sleep(DELETE_TIMEOUT) await event.delete()
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), "pearl/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, "Black Pearl Has Safely Installed Plugin `{}`.".format( os.path.basename(downloaded_file_name)), ) else: await borg.send_message( event.chat_id, "Looks Like Some Dumbass Asshole Has Tried To Reinstall The existing Plugins: `{}` ." .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)}" )
if len(argv) not in (1, 3, 4): bot.disconnect() else: bot.tgbot = None if Var.TG_BOT_USER_NAME_BF_HER is not None: bot.tgbot = 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 = "pearl/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", "")) rider.info("Black Pearl Has Been Installed Sucessfully !") rider.info("You Can Visit @Blackpearlsupport For Any Support Or Doubts") if len(argv) not in (1, 3, 4): bot.disconnect() else: bot.run_until_disconnected()