forked from dymik739/modular-bot-framework-for-telegram
		
	transliteration-decoder: add new module
This commit is contained in:
		
							parent
							
								
									c9271963b2
								
							
						
					
					
						commit
						29a86f7320
					
				
							
								
								
									
										18
									
								
								modules/transliteration-decoder/index.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								modules/transliteration-decoder/index.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
if self.MESSAGE['text'].split()[0] == "!decode" and len(self.MESSAGE['text'].split(" ", 2)) == 3:
 | 
			
		||||
    try:
 | 
			
		||||
        models = json.loads(readfile(self.path + "translate_models.json"))
 | 
			
		||||
        chosen_model = self.MESSAGE['text'].split(" ", 2)[1]
 | 
			
		||||
 | 
			
		||||
        t = self.MESSAGE['text'].split(" ", 2)[2]
 | 
			
		||||
 | 
			
		||||
        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])
 | 
			
		||||
                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}")
 | 
			
		||||
							
								
								
									
										6
									
								
								modules/transliteration-decoder/meta.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								modules/transliteration-decoder/meta.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
    "version": 1,
 | 
			
		||||
    "index_file": "index.py",
 | 
			
		||||
    "start_on_boot": true,
 | 
			
		||||
    "alias": "translit-decoder"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										35
									
								
								modules/transliteration-decoder/translate_models.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								modules/transliteration-decoder/translate_models.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
			
		||||
{
 | 
			
		||||
    "cz-ua": [
 | 
			
		||||
        ["šč", "щ"],
 | 
			
		||||
        ["ja", "я"],
 | 
			
		||||
        ["ju", "ю"],
 | 
			
		||||
        ["ji", "ї"],
 | 
			
		||||
        ["je", "є"],
 | 
			
		||||
        ["f", "ф"],
 | 
			
		||||
        ["b", "б"],
 | 
			
		||||
        ["ž", "ж"],
 | 
			
		||||
        ["q", "к"],
 | 
			
		||||
        ["š", "ш"],
 | 
			
		||||
        ["n", "н"],
 | 
			
		||||
        ["p", "п"],
 | 
			
		||||
        ["r", "р"],
 | 
			
		||||
        ["s", "с"],
 | 
			
		||||
        ["t", "т"],
 | 
			
		||||
        ["h", "х"],
 | 
			
		||||
        ["č", "ч"],
 | 
			
		||||
        ["'", "ь"],
 | 
			
		||||
        ["y", "и"],
 | 
			
		||||
        ["z", "з"],
 | 
			
		||||
        ["l", "л"],
 | 
			
		||||
        ["k", "к"],
 | 
			
		||||
        ["d", "д"],
 | 
			
		||||
        ["u", "у"],
 | 
			
		||||
        ["m", "м"],
 | 
			
		||||
        ["v", "в"],
 | 
			
		||||
        ["j", "й"],
 | 
			
		||||
        ["s", "с"],
 | 
			
		||||
        ["a", "а"],
 | 
			
		||||
        ["i", "і"],
 | 
			
		||||
        ["g", "г"]
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user