From 8608e6a34e3aa7517ef713ab9a53b690019a9d56 Mon Sep 17 00:00:00 2001 From: Seaswimmer Date: Tue, 28 May 2024 19:06:11 -0400 Subject: [PATCH] fix(seautils): fixed only the first A response being used --- seautils/seautils.py | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/seautils/seautils.py b/seautils/seautils.py index 1feb77a..2d44336 100644 --- a/seautils/seautils.py +++ b/seautils/seautils.py @@ -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'))