From f2df597e3dd9098793dd14581a984174571c4444 Mon Sep 17 00:00:00 2001 From: Abhijeet Krishnan Date: Tue, 23 Apr 2024 20:33:41 -0400 Subject: [PATCH] Fix issue with `*` in move inputs `*` was previously being escaped in move input while storing in FrameDb, since it is a formatting character in Discord Markdown. However, this causes issues when attempting to recognize move input queries. The input is now stored as is, with the conversion to Discord Markdown done when the embed is being built. --- src/frame_service/wavu/utils.py | 2 +- src/framedb/framedb.py | 3 +++ src/heihachi/embed.py | 7 ++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/frame_service/wavu/utils.py b/src/frame_service/wavu/utils.py index e32b535..fd3946e 100644 --- a/src/frame_service/wavu/utils.py +++ b/src/frame_service/wavu/utils.py @@ -98,7 +98,7 @@ def _convert_json_move(move_json: Any) -> WavuMove: name = html.unescape(_process_links(move_json["name"])) - input = html.unescape(html.unescape(_normalize_data(move_json["input"]))).replace("*", "\\*") + input = html.unescape(html.unescape(_normalize_data(move_json["input"]))) target = _normalize_data(move_json["target"]) diff --git a/src/framedb/framedb.py b/src/framedb/framedb.py index d5b3d2d..cad2f4d 100644 --- a/src/framedb/framedb.py +++ b/src/framedb/framedb.py @@ -142,6 +142,9 @@ def get_move_by_input(self, character: CharacterName, input_query: str) -> Move for entry in character_movelist if FrameDb._simplify_input(entry.input) == FrameDb._simplify_input(input_query) ] + # simple_inputs = [FrameDb._simplify_input(entry.input) for entry in character_movelist] + # simplified_input_query = FrameDb._simplify_input(input_query) + # import code; code.interact(local=locals()) if result: return result[0] diff --git a/src/heihachi/embed.py b/src/heihachi/embed.py index 94fa682..851e26c 100644 --- a/src/heihachi/embed.py +++ b/src/heihachi/embed.py @@ -30,7 +30,7 @@ def get_similar_moves_embed( # TODO: look into improving the similar moves flow ) if len(similar_moves) > 0: - embed.add_field(name="Similar Moves", value="\n".join([move.input for move in similar_moves])) + embed.add_field(name="Similar Moves", value="\n".join([move.input.replace("*", "\\*") for move in similar_moves])) else: embed.add_field(name="No similar moves found", value="") embed.set_thumbnail(url=character.portrait) @@ -47,7 +47,7 @@ def get_success_movelist_embed( For e.g., to a move type """ - desc_string = "\n".join(sorted([move.input for move in moves])) + desc_string = "\n".join(sorted([move.input.replace("*", "\\*") for move in moves])) embed = discord.Embed( title=f"{title}\n", @@ -73,8 +73,9 @@ def get_success_embed(message: Any | None) -> discord.Embed: def get_move_embed(frame_service: FrameService, character: Character, move: Move) -> discord.Embed: """Returns the embed message for character and move.""" + escaped_input = move.input.replace("*", "\\*") embed = discord.Embed( - title=f"**{move.input}**", + title=f"**{escaped_input}**", colour=SUCCESS_COLOR, description=move.name, url=frame_service.get_move_url(character, move),