Fix translate

This commit is contained in:
blank X 2020-10-21 21:28:27 +07:00
parent cf912a4a72
commit 0d87a789e0
1 changed files with 6 additions and 4 deletions

View File

@ -23,14 +23,16 @@ async def translate(client, message):
lang = ' '.join(message.command[1:]).lower()
for i in PROBLEM_CODES:
if lang.startswith(i):
src_lang = i
lang = lang[len(i):]
lang = lang[len(i) + 1:]
if lang:
dest_lang = lang[1:] or 'en'
src_lang = i
dest_lang = lang
else:
dest_lang = i
break
else:
lang = lang.split('-', 1)
if len(lang) == 1:
if len(lang) == 1 or not lang[-1]:
dest_lang = lang.pop(0) or dest_lang
else:
src_lang, dest_lang = lang