@ -1,5 +1,6 @@ 
				
			 
			
		
	
		
		
			
				
					 
					 
					const  {  spawn  }  =  require ( 'child_process' ) ;  
					 
					 
					const  {  spawn  }  =  require ( 'child_process' ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					const  {  EOL  }  =  require ( 'os' ) ;  
					 
					 
					const  {  EOL  }  =  require ( 'os' ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					const  os  =  require ( 'os' ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					const  Telegraf  =  require ( 'telegraf' ) ;  
					 
					 
					const  Telegraf  =  require ( 'telegraf' ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					const  {  path  }  =  require ( './util/index.js' ) ;  
					 
					 
					const  {  path  }  =  require ( './util/index.js' ) ;  
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					@ -21,18 +22,24 @@ const bot = new Telegraf(config.botApiKey); 
				
			 
			
		
	
		
		
			
				
					 
					 
					const  sessions  =  [ ] ;  
					 
					 
					const  sessions  =  [ ] ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					sessions . history  =  [ ] ;  
					 
					 
					sessions . history  =  [ ] ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					bot . use ( ( ctx ,  next )  =>    
					 
					 
					bot . use ( ( ctx ,  next )  =>  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
						validator ( ctx )  
					 
					 
						validator ( ctx )  
				
			 
			
		
	
		
		
			
				
					 
					 
							. then ( next )  
					 
					 
							. then ( next )  
				
			 
			
		
	
		
		
			
				
					 
					 
							. catch ( responder . fail (  
					 
					 
							. catch ( responder . fail (  
				
			 
			
		
	
		
		
			
				
					 
					 
								` Username Not authenticated! `  
					 
					 
								` Username Not authenticated! `  
				
			 
			
		
	
		
		
			
				
					 
					 
							) ) ) ;  
					 
					 
							) ) ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					// get os info
  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					const  home   =  os . homedir ( ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					const  hostname  =  os . hostname ( ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					const  username  =  os . userInfo ( ) . username ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					const  defaultShell  =  os . platform ( )  ===  'win32'  ?  'cmd.exe'  :  'bash' ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					bot . command ( 'start' ,  
					 
					 
					bot . command ( 'start' ,  
				
			 
			
		
	
		
		
			
				
					 
					 
						ctx  =>  {  
					 
					 
						ctx  =>  {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
							ctx . replyWithHTML ( 'Welcome to tsh -- <code>Telegram Shell!</code>' ) ;  
					 
					 
							ctx . replyWithHTML ( ` Welcome to tsh -- <code>Telegram Shell!</code><br><br>You are now connected to <code> ${ hostname } </code> as <strong> ${ username } </strong> ` ) ;  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
							const  newProc  =  spawn ( 'bash' ,  {  
					 
					 
							const  newProc  =  spawn ( defaultShell ,  {  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
								cwd :  '/home'  
					 
					 
								cwd :  home  
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 
					 
							} ) ;  
					 
					 
							} ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
							newProc . stdout . setEncoding ( 'utf8' ) ;  
					 
					 
							newProc . stdout . setEncoding ( 'utf8' ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
							sessions . push ( newProc ) ;  
					 
					 
							sessions . push ( newProc ) ;