|  |  | @ -1,20 +1,20 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | const fs = require('fs'); |  |  |  | const fs = require('fs'); | 
			
		
	
		
		
			
				
					
					|  |  |  | const node_ssh = require('node-ssh'); |  |  |  | const nodeSsh = require('node-ssh'); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | const sdk = require('matrix-js-sdk'); |  |  |  | const sdk = require('matrix-js-sdk'); | 
			
		
	
		
		
			
				
					
					|  |  |  | const yaml = require('js-yaml'); |  |  |  | const yaml = require('js-yaml'); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | const config = yaml.safeLoad(fs.readFileSync('config.yaml')); |  |  |  | const config = yaml.safeLoad(fs.readFileSync('config.yaml')); | 
			
		
	
		
		
			
				
					
					|  |  |  | const matrixclient = sdk.createClient({ |  |  |  | const matrixClient = sdk.createClient({ | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     baseUrl: config.matrix.baseurl, |  |  |  |     baseUrl: config.matrix.baseurl, | 
			
		
	
		
		
			
				
					
					|  |  |  |     accessToken: config.matrix.accesstoken, |  |  |  |     accessToken: config.matrix.accesstoken, | 
			
		
	
		
		
			
				
					
					|  |  |  |     userId: config.matrix.userid |  |  |  |     userId: config.matrix.userid | 
			
		
	
		
		
			
				
					
					|  |  |  | }); |  |  |  | }); | 
			
		
	
		
		
			
				
					
					|  |  |  | const ssh = new node_ssh(); |  |  |  | const ssh = new nodeSsh(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | // Autojoin for the bot (keep commented out when not needed to prevent abuse)
 |  |  |  | // Autojoin for the bot (keep commented out when not needed to prevent abuse)
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /*matrixclient.on('RoomMember.membership', function(event, member) { |  |  |  | /*matrixClient.on('RoomMember.membership', function(event, member) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     if(member.membership === 'invite' && member.userId === userid) { |  |  |  |     if(member.membership === 'invite' && member.userId === userid) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         matrixclient.joinRoom(member.roomId).done(function() { |  |  |  |         matrixClient.joinRoom(member.roomId).done(function() { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             console.log('Auto-joined %s', member.roomId); |  |  |  |             console.log('Auto-joined %s', member.roomId); | 
			
		
	
		
		
			
				
					
					|  |  |  |         }); |  |  |  |         }); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
	
		
		
			
				
					|  |  | @ -58,20 +58,20 @@ commands['rebuild'].usage = '!rebuild <container>'; | 
			
		
	
		
		
			
				
					
					|  |  |  | commands['rebuild'].exec = function(args, room, event) { |  |  |  | commands['rebuild'].exec = function(args, room, event) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     const container = args[1]; |  |  |  |     const container = args[1]; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     matrixclient.sendNotice(room.roomId, 'rebuilding container ' + container); |  |  |  |     matrixClient.sendNotice(room.roomId, 'rebuilding container ' + container); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     remoterun('./rebuild.sh ' + container) |  |  |  |     remoterun('./rebuild.sh ' + container) | 
			
		
	
		
		
			
				
					
					|  |  |  |     .then(function(result) { |  |  |  |     .then(function(result) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         matrixclient.sendNotice(room.roomId, event.sender.userId + '\nrebuilt container ' + container); |  |  |  |         matrixClient.sendNotice(room.roomId, event.sender.userId + '\nrebuilt container ' + container); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     }, function(result) { |  |  |  |     }, function(result) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         matrixclient.sendNotice(room.roomId, event.sender.userId + '\nrebuild of container ' + container + ' failed.\ncode: ' + result.code + '\nstdout: \n```\n' + result.stdout + '```\nstderr: \n```\n' + result.stderr + '\n```'); |  |  |  |         matrixClient.sendNotice(room.roomId, event.sender.userId + '\nrebuild of container ' + container + ' failed.\ncode: ' + result.code + '\nstdout: \n```\n' + result.stdout + '```\nstderr: \n```\n' + result.stderr + '\n```'); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     }); |  |  |  |     }); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | }; |  |  |  | }; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | matrixclient.on('Room.timeline', function(event, room, resettimeline) { |  |  |  | matrixClient.on('Room.timeline', function(event, room, resetTimeline) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     if(resettimeline) { |  |  |  |     if(resetTimeline) { | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         return; |  |  |  |         return; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |     if(event.getType() !== 'm.room.message') { |  |  |  |     if(event.getType() !== 'm.room.message') { | 
			
		
	
	
		
		
			
				
					|  |  | @ -91,7 +91,7 @@ matrixclient.on('Room.timeline', function(event, room, resettimeline) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         const args = body.match(command.regex); |  |  |  |         const args = body.match(command.regex); | 
			
		
	
		
		
			
				
					
					|  |  |  |         if(args === null) { |  |  |  |         if(args === null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             matrixclient.sendNotice(room.roomId, 'usage: ' + command.usage); |  |  |  |             matrixClient.sendNotice(room.roomId, 'usage: ' + command.usage); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             return; |  |  |  |             return; | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -101,4 +101,4 @@ matrixclient.on('Room.timeline', function(event, room, resettimeline) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | matrixclient.startClient(); |  |  |  | matrixClient.startClient(); | 
			
				
				
			
		
	
		
		
	
	
		
		
			
				
					|  |  | 
 |