fix(seautils): fixed only the first A response being used

This commit is contained in:
Seaswimmer 2024-05-28 19:06:11 -04:00
parent fb468ee63e
commit 8608e6a34e
Signed by untrusted user: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -128,19 +128,33 @@ class SeaUtils(commands.Cog):
embed.colour = Color.red()
embed.description = cf.error("Dig query did not return `NOERROR` status.")
question_section = "\n".join(response_data['QUESTION_SECTION'])
embed.add_field(name="Question Section", value=f"```{question_section}```", inline=False)
questions = []
answers = []
authorities = []
for m in data:
response = m['message']['response_message_data']
if 'QUESTION_SECTION' in response:
for question in response['QUESTION_SECTION']:
questions.append(question)
if 'ANSWER_SECTION' in response:
for answer in response['ANSWER_SECTION']:
answers.append(answer)
if 'AUTHORITY_SECTION' in response:
for authority in response['AUTHORITY_SECTION']:
authorities.append(authority)
if 'ANSWER_SECTION' in response_data:
answer_section = "\n".join(response_data['ANSWER_SECTION'])
if len(answer_section) > 1024:
embed.description = answer_section
else:
embed.add_field(name="Answer Section", value=f"```{answer_section}```", inline=False)
question_section = "\n".join(questions)
embed.add_field(name="Question Section", value=f"{cf.box(question_section)}", inline=False)
if 'AUTHORITY_SECTION' in response_data:
authority_section = "\n".join(response_data['AUTHORITY_SECTION'])
embed.add_field(name="Authority Section", value=f"```{authority_section}```", inline=False)
answer_section = "\n".join(answers)
if len(answer_section) > 1024:
embed.description = cf.warning("Answer section is too long to fit within embed field, falling back to description.") + cf.box(answer_section)
else:
embed.add_field(name="Answer Section", value=f"{cf.box(answer_section)}", inline=False)
if authorities:
authority_section = "\n".join(authorities)
embed.add_field(name="Authority Section", value=f"{cf.box(authority_section)}", inline=False)
await ctx.send(embed=embed)
else:
await ctx.send(content=cf.box(text=stdout, lang='yaml'))