Skip to content

Commit

Permalink
change fallback to unknown and add a space before lang codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick80835 committed Sep 23, 2020
1 parent 64f283e commit c9a7b22
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ubot/modules/scrapers.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ async def wiki_cmd(event):
await event.edit(text)


@ldr.add("trt", pattern_extra=f"({'|'.join(constants.LANGUAGES.keys())}|)", help="Translates text to the given language code appended to the trt command, defaults to English.")
@ldr.add("trt", pattern_extra=f"( {'| '.join(constants.LANGUAGES.keys())}|)", help="Translates text to the given language code appended to the trt command, defaults to English.")
async def translate(event):
text_arg = await ldr.get_text(event)
lang = event.other_args[0].lower() or "en"
lang = event.other_args[0].lower().strip() or "en"
translation = translator.translate(text_arg, dest=lang)
await event.edit(f"Translated from **{constants.LANGUAGES.get(translation.src.lower(), 'English').title()}** to **{constants.LANGUAGES.get(translation.dest.lower(), 'English').title()}**:\n\n__{translation.text}__")
await event.edit(f"Translated from **{constants.LANGUAGES.get(translation.src.lower(), 'Unknown').title()}** to **{constants.LANGUAGES.get(translation.dest.lower(), 'Unknown').title()}**:\n\n__{translation.text}__")


@ldr.add("corona", help="Fetches Coronavirus stats, takes an optional country name as an argument.")
Expand Down

0 comments on commit c9a7b22

Please sign in to comment.