async def search(self, ctx, arg): lwrcase = arg.lower() if ".loli" in lwrcase: lwrarg = lwrcase else: lwrarg = lwrcase + ".loli" try: if ".loli" not in lwrcase and len(lwrcase) > 1: configs = session.query(Configs).filter( Configs.name.contains(lwrcase)).all() headers = ['Names'] rows = [[c.name] for c in configs] table = tabulate(rows, headers, tablefmt="github") await ctx.send("```\n" + table + "```") elif len(lwrcase) > 1 and ".loli" in lwrarg: configs = session.query(Configs).filter( Configs.name == lwrarg).first() info = [ ['Name', configs.name], ['Captcha', configs.captcha], ['Capture', configs.capture], ['Proxies', configs.proxies], ['Author', configs.author], ['Uploaded by', configs.uploaded_by], ["Wordlists", configs.wordlist1 + "|" + configs.wordlist2] ] await ctx.send("```\n" + tabulate(info, tablefmt="plain") + "```") elif len(lwrcase) == 1 and lwrcase != lwrarg: configs = session.query(Configs).filter( Configs.name.startswith(lwrcase)).all() headers = ['Names'] rows = [[c.name] for c in configs] table = tabulate(rows, headers, tablefmt="github") await ctx.send("```\n" + table + "```") if not configs: await ctx.send("Config not found") return except Exception as e: await ctx.send("Could not complete your request") print(e)
async def configs(self, ctx): configs = session.query(Configs).order_by(Configs.name).all() rows = [[c.name] for c in configs] pagey = MyPaginator(title='List of configs', colour=0xc67862, embed=True, timeout=90, use_defaults=True, entries=rows, length=50, format='**') await pagey.start(ctx)
async def remove(self,ctx,arg): lwrcase = arg.lower() if ".loli" in lwrcase: lwrarg = lwrcase else: lwrarg = str(arg.lower())+".loli" name = session.query(Configs).filter(Configs.name == lwrarg).first() session.delete(name) session.commit() self.bot.reload_extension("cogs.request") self.bot.reload_extension("cogs.upload") self.bot.reload_extension("cogs.download") self.bot.reload_extension("cogs.view") self.bot.reload_extension("cogs.delete") self.bot.reload_extension("cogs.search") await ctx.send("Database reloaded successfully")
async def download(self,ctx,arg): lwrcase = arg.lower() list = str(lwrcase).split(",") for elem in list: if ".loli" in elem: lwrarg = elem else: lwrarg = str(elem)+".loli" try: configs = session.query(Configs).filter(Configs.name == lwrarg).first() if lwrarg not in present_configs: await ctx.send("Config not found, please request it !") return user = ctx.message.author info = [['Name',configs.name],['Captcha',configs.captcha],['Capture',configs.capture],['Proxies',configs.proxies],['Author',configs.author],['Uploaded by',configs.uploaded_by],["Wordlists",configs.wordlist1+"|"+configs.wordlist2]] file = discord.File(f"cogs/configs/{lwrarg}") await user.send("```\n"+tabulate(info)+"```",file=file) except Exception as e: await ctx.send("Could not complete your command.") print(e) await ctx.send("Sent you a DM containing the config.")
async def delete(self,ctx,arg): lwrcase = arg.lower() if ".loli" in lwrcase: lwrarg = lwrcase else: lwrarg = str(arg.lower())+".loli" if lwrarg in present_configs: os.remove(f"cogs/configs/{lwrarg}") await ctx.send("Successfully deleted config") name = session.query(Configs).filter(Configs.name == lwrarg).first() session.delete(name) session.commit() else: await ctx.send("Config not deleted") self.bot.reload_extension("cogs.request") self.bot.reload_extension("cogs.upload") self.bot.reload_extension("cogs.download") self.bot.reload_extension("cogs.view") self.bot.reload_extension("cogs.delete") self.bot.reload_extension("cogs.search") await ctx.send("Database reloaded successfully.")