dedicated jssandbox for debugging
This commit is contained in:
		
							
								
								
									
										36
									
								
								src/inc/trigger/debug.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/inc/trigger/debug.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					const vm = require("vm");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					let maxoutput = 500;
 | 
				
			||||||
 | 
					let context = vm.createContext({
 | 
				
			||||||
 | 
					  e: null,
 | 
				
			||||||
 | 
					  bot: null
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					module.exports = bot => {
 | 
				
			||||||
 | 
					  bot._trigger.set("sandbox_debug", {
 | 
				
			||||||
 | 
					    call: /^\!debug (.*)/i,
 | 
				
			||||||
 | 
					    level: 0,
 | 
				
			||||||
 | 
					    active: true,
 | 
				
			||||||
 | 
					    clients: ["irc", "tg"],
 | 
				
			||||||
 | 
					    f: e => {
 | 
				
			||||||
 | 
					      const args = e.message.trim().substring(7);
 | 
				
			||||||
 | 
					      if ((e.user.nick === "Flummi" && e.network === "n0xy")
 | 
				
			||||||
 | 
					        || (e.user.nick === "belst" && e.network === "n0xy")
 | 
				
			||||||
 | 
					        || (e.user.nick === "jkhsjdhjs" && e.network === "n0xy")
 | 
				
			||||||
 | 
					      ) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					          let output = vm.runInContext(args, context);
 | 
				
			||||||
 | 
					          if (typeof output !== undefined && output) {
 | 
				
			||||||
 | 
					            output = JSON.stringify(output);
 | 
				
			||||||
 | 
					            if (output.length > maxoutput)
 | 
				
			||||||
 | 
					              return e.reply(`holy fuck, Ausgabe wäre viel zu lang! (${output.length} Zeichen :DDDDDD)`);
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					              e.reply(output);
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (err) {
 | 
				
			||||||
 | 
					          e.reply(err.message);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
		Reference in New Issue
	
	Block a user