2023-04-26 13:12:15 +03:00
|
|
|
cmd = self.MESSAGE['text'].split(" ", 2)
|
|
|
|
l = len(cmd)
|
|
|
|
|
|
|
|
if (cmd[0] in self.aliases) and (1 <= l <= 3):
|
2023-04-07 00:19:39 +03:00
|
|
|
try:
|
|
|
|
models = json.loads(readfile(self.path + "translate_models.json"))
|
|
|
|
|
2023-04-26 13:12:15 +03:00
|
|
|
if l == 1:
|
|
|
|
chosen_model = "cz-ua"
|
|
|
|
else:
|
|
|
|
chosen_model = cmd[1]
|
|
|
|
|
|
|
|
if l == 3:
|
|
|
|
t = cmd[2]
|
|
|
|
else:
|
2023-04-10 17:50:20 +03:00
|
|
|
t = self.MESSAGE['reply_to_message']['text']
|
|
|
|
|
2023-04-07 00:19:39 +03:00
|
|
|
translated_t = t
|
|
|
|
if chosen_model not in models:
|
|
|
|
self.RESPONCE = f"Такого варіанту транслітерації не існує. Доступні варіанти: {', '.join(list(models.keys()))}"
|
|
|
|
else:
|
|
|
|
for i in models[chosen_model]:
|
|
|
|
translated_t = translated_t.replace(i[0], i[1])
|
2023-04-17 22:11:49 +03:00
|
|
|
translated_t = translated_t.replace(i[0].capitalize(), i[1].capitalize())
|
2023-04-07 00:19:39 +03:00
|
|
|
translated_t = translated_t.replace(i[0].upper(), i[1].upper())
|
2023-04-10 17:50:20 +03:00
|
|
|
|
2023-04-07 00:19:39 +03:00
|
|
|
self.RESPONCE = f"Результат: {translated_t}"
|
2023-04-26 13:12:15 +03:00
|
|
|
|
2023-04-07 00:19:39 +03:00
|
|
|
except Exception as e:
|
|
|
|
print(f"[translit-decoder] Got exception: {e}")
|