|  |  |  | @ -2,6 +2,7 @@ const fs = require('fs'); | 
		
	
		
			
				|  |  |  |  | const remoteExec = require('./remoteExec.js'); | 
		
	
		
			
				|  |  |  |  | const sdk = require('matrix-js-sdk'); | 
		
	
		
			
				|  |  |  |  | const yaml = require('js-yaml'); | 
		
	
		
			
				|  |  |  |  | const commandUtil = require('./commands.js'); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | global.config = yaml.safeLoad(fs.readFileSync('config.yaml')); | 
		
	
		
			
				|  |  |  |  | const matrixClient = sdk.createClient({ | 
		
	
	
		
			
				
					|  |  |  | @ -24,7 +25,6 @@ process.on('unhandledRejection', (reason) => { | 
		
	
		
			
				|  |  |  |  |     console.log('Reason: ' + reason); | 
		
	
		
			
				|  |  |  |  | }); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | const commands = {}; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | commands['rebuild'] = {}; | 
		
	
	
		
			
				
					|  |  |  | @ -61,7 +61,9 @@ matrixClient.on('Room.timeline', function(event, room, resetTimeline) { | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     project = project[1]; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     if(commands[project] !== undefined) { | 
		
	
		
			
				|  |  |  |  |     let command = commands[project]; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     if(command !== undefined) { | 
		
	
		
			
				|  |  |  |  |         const command = commands[project]; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         const args = body.match(command.regex); | 
		
	
	
		
			
				
					|  |  |  | @ -71,6 +73,14 @@ matrixClient.on('Room.timeline', function(event, room, resetTimeline) { | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         command.exec(args, room, event); | 
		
	
		
			
				|  |  |  |  |     }else{ //command not found
 | 
		
	
		
			
				|  |  |  |  |         let tmp = commandUtil.fetchCommand(project, commands); | 
		
	
		
			
				|  |  |  |  |         let suggestions = ""; | 
		
	
		
			
				|  |  |  |  |         for(let i = 0; i < tmp.length; i++){ | 
		
	
		
			
				|  |  |  |  |             suggestions += "\n"+tmp[i]; | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |         matrixClient.sendNotice(room.roomId, 'Unrecognized command.\n' + | 
		
	
		
			
				|  |  |  |  |             'Did you mean:'+suggestions); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  | }); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
	
		
			
				
					|  |  |  | 
 |