Little tweaks to variables.
This commit is contained in:
parent
45b0a5973c
commit
493a29b9fa
|
@ -1,30 +1,30 @@
|
||||||
cmd = self.MESSAGE['text'].split(" ", 2)
|
command = self.MESSAGE['text'].split(" ", 2)
|
||||||
l = len(cmd)
|
command_length = len(command)
|
||||||
|
|
||||||
if (cmd[0] in self.aliases) and (1 <= l <= 3):
|
if (command[0] in self.aliases) and (1 <= command_length <= 3):
|
||||||
try:
|
try:
|
||||||
models = json.loads(readfile(self.path + "translate_models.json"))
|
models = json.loads(readfile(self.path + "translate_models.json"))
|
||||||
|
|
||||||
if l == 1:
|
if command_length == 1:
|
||||||
chosen_model = "cz-ua"
|
chosen_model = "cz-ua"
|
||||||
else:
|
else:
|
||||||
chosen_model = cmd[1]
|
chosen_model = command[1]
|
||||||
|
|
||||||
if l == 3:
|
if command_length == 3:
|
||||||
t = cmd[2]
|
text_to_decode = command[2]
|
||||||
else:
|
else:
|
||||||
t = self.MESSAGE['reply_to_message']['text']
|
text_to_decode = self.MESSAGE['reply_to_message']['text']
|
||||||
|
|
||||||
translated_t = t
|
decoded_text = text_to_decode
|
||||||
if chosen_model not in models:
|
if chosen_model not in models:
|
||||||
self.RESPONCE = f"Такого варіанту транслітерації не існує. Доступні варіанти: {', '.join(list(models.keys()))}"
|
self.RESPONCE = f"Такого варіанту транслітерації не існує. Доступні варіанти: {', '.join(list(models.keys()))}"
|
||||||
else:
|
else:
|
||||||
for i in models[chosen_model]:
|
for i in models[chosen_model]:
|
||||||
translated_t = translated_t.replace(i[0], i[1])
|
decoded_text = decoded_text.replace(i[0], i[1])
|
||||||
translated_t = translated_t.replace(i[0].capitalize(), i[1].capitalize())
|
decoded_text = decoded_text.replace(i[0].capitalize(), i[1].capitalize())
|
||||||
translated_t = translated_t.replace(i[0].upper(), i[1].upper())
|
decoded_text = decoded_text.replace(i[0].upper(), i[1].upper())
|
||||||
|
|
||||||
self.RESPONCE = f"Результат: {translated_t}"
|
self.RESPONCE = f"Результат: {decoded_text}"
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[translit-decoder] Got exception: {e}")
|
print(f"[translit-decoder] Got exception: {e}")
|
||||||
|
|
Loading…
Reference in New Issue