Default to hiding any filtered text
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 7s

This commit is contained in:
Nexus 2024-05-01 00:54:55 +01:00
parent 959d83f0b1
commit bbd74cd1e9
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -16,6 +16,25 @@ from rich.tree import Tree
from conf import CONFIG
class GetFilteredTextView(discord.ui.View):
def __init__(self, text: str):
self.text = text
super().__init__(timeout=600)
@discord.ui.button(
label="See filtered data",
emoji="\N{INBOX TRAY}"
)
async def see_filtered_data(self, _, interaction: discord.Interaction):
await interaction.response.defer(ephemeral=True)
await interaction.followup.send(
file=discord.File(
io.BytesIO(self.text.encode()),
"filtered.txt"
)
)
class NetworkCog(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@ -107,14 +126,16 @@ class NetworkCog(commands.Cog):
file.write(stderr)
file.seek(0)
return await ctx.respond(
"Seemingly all output was filtered. Returning raw command output.", file=discord.File(file, "whois.txt")
"Seemingly all output was filtered. Returning raw command output.",
file=discord.File(file, "whois.txt")
)
last: discord.Interaction | discord.WebhookMessage | None = None
for page in paginator.pages:
await ctx.respond(page)
if redacted.getvalue():
redacted.seek(0)
await ctx.respond(file=discord.File(redacted, "redacted.txt"))
last = await ctx.respond(page)
if last and redacted.tell():
view = GetFilteredTextView(redacted.getvalue().decode())
await last.edit(view=view)
@commands.slash_command()
async def dig(
@ -163,7 +184,7 @@ class NetworkCog(commands.Cog):
with console.capture() as capture:
console.print(tree)
text = capture.get()
paginator = commands.Paginator(prefix="```", suffix="```")
paginator = commands.Paginator()
for line in text.splitlines():
paginator.add_line(line)
paginator.add_line(empty=True)