Skip to content

Commit

Permalink
rewrite wikihow
Browse files Browse the repository at this point in the history
  • Loading branch information
rtk-rnjn committed Aug 1, 2023
1 parent 878b923 commit 305811a
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions cogs/owner/owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,27 +631,25 @@ async def wikihow(self, ctx: Context, *, query: int | str) -> None:
def _join_values(values: list[str] | list[list[str]]) -> str:
if isinstance(values, list) and isinstance(values[0], list):
return "\n".join([" ".join(i) for i in values])
return "\n".join(values)
return "\n".join(" ".join(i) for i in values)

if real.get("Things You Should Know"):
things = _join_values(real["Things You Should Know"].values())
await interface.add_line(
f"# Things You Should Know\n> {things}",
)

if steps := real.get("Steps"):
for hd, stps in steps.items():
if wiki_steps := real.get("Steps"):
for hd, steps in wiki_steps.items():
await interface.add_line(f"## {hd}")
if isinstance(steps, list):
for sub_step in stps:
if sub_step.endswith("jpg"):
await interface.add_line(f"- [Link To Image]({sub_step})")
if isinstance(sub_step, list):
for sub_sub_step in sub_step:
await interface.add_line(f" - {sub_sub_step}")
else:
await interface.add_line(f"- {sub_step}")
await interface.add_line("")
for points in steps:
for sub_head, sub_steps in points:
await interface.add_line(f"### {sub_head}")
for step in sub_steps:
if step.endswith("jpg"):
await interface.add_line(f"[Link To Image]({step})")
else:
await interface.add_line(f"- {step}")

if real.get("Tips"):
tips = _join_values(real["Tips"].values())
Expand Down

0 comments on commit 305811a

Please sign in to comment.