transliteration-decoder: add the ability to read the reply_to message text as decoding argument

This commit is contained in:
dymik739 2023-04-10 17:50:20 +03:00
parent dc656e2156
commit 0def45c6ce
1 changed files with 7 additions and 4 deletions

View File

@ -1,9 +1,12 @@
if self.MESSAGE['text'].split()[0] == "!decode" and len(self.MESSAGE['text'].split(" ", 2)) == 3: if self.MESSAGE['text'].split()[0] == "!decode" and (2 <= len(self.MESSAGE['text'].split(" ", 2)) <= 3):
try: try:
models = json.loads(readfile(self.path + "translate_models.json")) models = json.loads(readfile(self.path + "translate_models.json"))
chosen_model = self.MESSAGE['text'].split(" ", 2)[1] chosen_model = self.MESSAGE['text'].split(" ", 2)[1]
t = self.MESSAGE['text'].split(" ", 2)[2] if len(self.MESSAGE['text'].split(" ", 2)) == 3:
t = self.MESSAGE['text'].split(" ", 2)[2]
elif len(self.MESSAGE['text'].split(" ", 2)) == 2:
t = self.MESSAGE['reply_to_message']['text']
translated_t = t translated_t = t
if chosen_model not in models: if chosen_model not in models: