transliteration-decoder: add !dc command trigger, allow cz-ua model to be default and make code more readable
This commit is contained in:
parent
c4f6e952bc
commit
45b0a5973c
|
@ -1,11 +1,18 @@
|
|||
if self.MESSAGE['text'].split()[0] == "!decode" and (2 <= len(self.MESSAGE['text'].split(" ", 2)) <= 3):
|
||||
cmd = self.MESSAGE['text'].split(" ", 2)
|
||||
l = len(cmd)
|
||||
|
||||
if (cmd[0] in self.aliases) and (1 <= l <= 3):
|
||||
try:
|
||||
models = json.loads(readfile(self.path + "translate_models.json"))
|
||||
chosen_model = self.MESSAGE['text'].split(" ", 2)[1]
|
||||
|
||||
if len(self.MESSAGE['text'].split(" ", 2)) == 3:
|
||||
t = self.MESSAGE['text'].split(" ", 2)[2]
|
||||
elif len(self.MESSAGE['text'].split(" ", 2)) == 2:
|
||||
if l == 1:
|
||||
chosen_model = "cz-ua"
|
||||
else:
|
||||
chosen_model = cmd[1]
|
||||
|
||||
if l == 3:
|
||||
t = cmd[2]
|
||||
else:
|
||||
t = self.MESSAGE['reply_to_message']['text']
|
||||
|
||||
translated_t = t
|
||||
|
@ -18,5 +25,6 @@ if self.MESSAGE['text'].split()[0] == "!decode" and (2 <= len(self.MESSAGE['text
|
|||
translated_t = translated_t.replace(i[0].upper(), i[1].upper())
|
||||
|
||||
self.RESPONCE = f"Результат: {translated_t}"
|
||||
|
||||
except Exception as e:
|
||||
print(f"[translit-decoder] Got exception: {e}")
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
"version": 1,
|
||||
"index_file": "index.py",
|
||||
"start_on_boot": true,
|
||||
"alias": "translit-decoder"
|
||||
"alias": "translit-decoder",
|
||||
"predefine": "predefine.py"
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
self.aliases = ["!decode", "!dc"]
|
Loading…
Reference in New Issue