Skip to content

Commit

Permalink
Fix issue with * in move inputs
Browse files Browse the repository at this point in the history
`*` 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.
  • Loading branch information
AbhijeetKrishnan committed Apr 24, 2024
1 parent 1fab263 commit f2df597
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/frame_service/wavu/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down
3 changes: 3 additions & 0 deletions src/framedb/framedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
7 changes: 4 additions & 3 deletions src/heihachi/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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",
Expand All @@ -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),
Expand Down

0 comments on commit f2df597

Please sign in to comment.