forked from dymik739/modular-bot-framework-for-telegram
		
	added new module: qna-basic
This commit is contained in:
		
							parent
							
								
									2f6d1113b8
								
							
						
					
					
						commit
						cf2223f40a
					
				
							
								
								
									
										6
									
								
								modules/qna-basic/db/obj.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								modules/qna-basic/db/obj.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
    "trigger_lists": [
 | 
			
		||||
        ["коли", "тест", "обж"]
 | 
			
		||||
    ],
 | 
			
		||||
    "responce_text": "Тести з ОБЖ необхідно проходити лише тим студентам, які не були на практичному занятті. Якщо Ви були на практиці, але все одно пройдете тест, то ризикуєте отримати нижчу оцінку та знизити свій загальний бал"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										25
									
								
								modules/qna-basic/index.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								modules/qna-basic/index.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
			
		||||
msg = self.MESSAGE["text"].lower()
 | 
			
		||||
 | 
			
		||||
responce_given = False
 | 
			
		||||
 | 
			
		||||
for file in os.listdir(self.path + "db/"):
 | 
			
		||||
    if responce_given:
 | 
			
		||||
        break
 | 
			
		||||
 | 
			
		||||
    try:
 | 
			
		||||
        criteria = json.loads( readfile(self.path + "db/" + file) )
 | 
			
		||||
 | 
			
		||||
        for wordset in criteria["trigger_lists"]:
 | 
			
		||||
            all_words_in = True
 | 
			
		||||
            for word in wordset:
 | 
			
		||||
                if not word in msg:
 | 
			
		||||
                    all_words_in = False
 | 
			
		||||
                    break
 | 
			
		||||
 | 
			
		||||
            if all_words_in:
 | 
			
		||||
                self.RESPONCE = criteria["responce_text"]
 | 
			
		||||
                responce_given = True
 | 
			
		||||
                break
 | 
			
		||||
 | 
			
		||||
    except Exception as e:
 | 
			
		||||
        print("[WARN] module : qna-basic: db file {} raised exception \"{}\"".format(file, e))
 | 
			
		||||
							
								
								
									
										6
									
								
								modules/qna-basic/meta.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								modules/qna-basic/meta.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
    "version": 1,
 | 
			
		||||
    "index_file": "index.py",
 | 
			
		||||
    "start_on_boot": true,
 | 
			
		||||
    "alias": "qna-basic"
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user