Default to hiding any filtered text
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 7s
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 7s
This commit is contained in:
parent
959d83f0b1
commit
bbd74cd1e9
1 changed files with 27 additions and 6 deletions
|
@ -16,6 +16,25 @@ from rich.tree import Tree
|
||||||
from conf import CONFIG
|
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):
|
class NetworkCog(commands.Cog):
|
||||||
def __init__(self, bot: commands.Bot):
|
def __init__(self, bot: commands.Bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
@ -107,14 +126,16 @@ class NetworkCog(commands.Cog):
|
||||||
file.write(stderr)
|
file.write(stderr)
|
||||||
file.seek(0)
|
file.seek(0)
|
||||||
return await ctx.respond(
|
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:
|
for page in paginator.pages:
|
||||||
await ctx.respond(page)
|
last = await ctx.respond(page)
|
||||||
if redacted.getvalue():
|
if last and redacted.tell():
|
||||||
redacted.seek(0)
|
view = GetFilteredTextView(redacted.getvalue().decode())
|
||||||
await ctx.respond(file=discord.File(redacted, "redacted.txt"))
|
await last.edit(view=view)
|
||||||
|
|
||||||
@commands.slash_command()
|
@commands.slash_command()
|
||||||
async def dig(
|
async def dig(
|
||||||
|
@ -163,7 +184,7 @@ class NetworkCog(commands.Cog):
|
||||||
with console.capture() as capture:
|
with console.capture() as capture:
|
||||||
console.print(tree)
|
console.print(tree)
|
||||||
text = capture.get()
|
text = capture.get()
|
||||||
paginator = commands.Paginator(prefix="```", suffix="```")
|
paginator = commands.Paginator()
|
||||||
for line in text.splitlines():
|
for line in text.splitlines():
|
||||||
paginator.add_line(line)
|
paginator.add_line(line)
|
||||||
paginator.add_line(empty=True)
|
paginator.add_line(empty=True)
|
||||||
|
|
Loading…
Reference in a new issue