Compare commits

...

2 Commits

1 changed files with 25 additions and 26 deletions

View File

@ -4,13 +4,12 @@ command_length = len(command)
def escaped_string(unescaped_string): def escaped_string(unescaped_string):
result_string = str(unescaped_string) result_string = str(unescaped_string)
for i in ["/", "<", ">"]: for i in ["<", ">"]:
result_string = result_string.replace(i, f"\\{i}") result_string = result_string.replace(i, f"\\{i}")
return result_string return result_string
if (command[0] in self.aliases) and (1 <= command_length <= 3): if (command[0] in self.aliases) and (1 <= command_length <= 3):
try:
models = json.loads(readfile(self.path + "translate_models.json")) models = json.loads(readfile(self.path + "translate_models.json"))
if command_length == 1: if command_length == 1:
@ -21,7 +20,10 @@ if (command[0] in self.aliases) and (1 <= command_length <= 3):
if command_length == 3: if command_length == 3:
text_to_decode = command[2] text_to_decode = command[2]
else: else:
text_to_decode = self.MESSAGE['reply_to_message']['text'] if self.MESSAGE['reply_to_message'].caption:
text_to_decode = self.MESSAGE['reply_to_message'].caption
elif self.MESSAGE['reply_to_message'].text:
text_to_decode = self.MESSAGE['reply_to_message'].text
decoded_text = text_to_decode decoded_text = text_to_decode
if chosen_model not in models: if chosen_model not in models:
@ -35,6 +37,3 @@ if (command[0] in self.aliases) and (1 <= command_length <= 3):
self.RESPONSE = f"<b><u>Результат</u></b>\n{escaped_string(decoded_text)}" self.RESPONSE = f"<b><u>Результат</u></b>\n{escaped_string(decoded_text)}"
self.FORMAT = "HTML" self.FORMAT = "HTML"
except Exception as e:
print(f"[translit-decoder] Got exception: {e}")