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(), "/root/userbot/userbot/modules/sql_helper/" # 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("Installed sql module `{}`".format( os.path.basename(downloaded_file_name))) else: os.remove(downloaded_file_name) await event.edit( f"`{JAVES_NNAME}`: **Error, module already installed or unknown formet**" ) 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): try: chat = event.pattern_match.group(1) text = f"**Installing plugins from {chat}..\n\n**" cui = await client.get_messages(chat, limit=75, filter=InputMessagesFilterDocument) total = int(cui.total) total_doxx = range(0, total) except: return await event.edit( "Error\nUsage: `!installall <channel/group username>`") for ixo in total_doxx: await event.edit(text) mxo = cui[ixo].id downloaded_file_name = await event.client.download_media( await client.get_messages(chat, ids=mxo), "userbot/modules/") if "(" not in downloaded_file_name: path1 = Path(downloaded_file_name) shortname = path1.stem if (os.path.basename(downloaded_file_name)).endswith('.py'): try: load_module(shortname.replace(".py", "")) text += f"**• Installed** {(os.path.basename(downloaded_file_name))}\n" except: text += f"**× Failed to install** {(os.path.basename(downloaded_file_name))}\n" os.remove(downloaded_file_name) pass else: text += f"** Skiped** {(os.path.basename(downloaded_file_name))}\n" os.remove(downloaded_file_name) else: text += f"** Skiped** {(os.path.basename(downloaded_file_name))}\n" os.remove(downloaded_file_name) return await event.edit(f"{text}\n\n**Install completed**")
async def load(event): if event.fwd_from: return shortname = event.pattern_match["shortname"] 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 install(event): a = "__Installing.__" b = 1 await event.edit(a) 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(), "/root/userbot/userbot/modules/" # pylint:disable=E0602 ) if "(" not in downloaded_file_name: path1 = Path(downloaded_file_name) shortname = path1.stem load_module(shortname.replace(".py", "")) if shortname in CMD_LIST: string = "**Commands found in** `{}`\n".format( (os.path.basename(downloaded_file_name))) for i in CMD_LIST[shortname]: string += " • `" + i string += "`\n" if b == 1: a = "__Installing..__" b = 2 else: a = "__Installing...__" b = 1 await event.edit(a) return await event.edit( f"**Installed module**\n`{shortname}`\n\n{string}") return await event.edit( f"Installed module `{os.path.basename(downloaded_file_name)}`" ) else: os.remove(downloaded_file_name) return await event.edit( f"**Failed to Install** \n`Error`\nModule already installed or unknown formet" ) except Exception as e: await event.edit(f"**Failed to Install** \n`Error`\n{str(e)}") return os.remove(downloaded_file_name)
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(), "/root/userbot/userbot/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("Installed module `{}`".format( os.path.basename(downloaded_file_name))) else: os.remove(downloaded_file_name) await event.edit("Errors! Cannot install this plugin.") 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()