Guest User

JavaScript Evaluator for MPP :3

a guest
Sep 29th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. // simple JavaScript evaluater in chat - meow :3
  2. if (typeof gScriptLoaded === "undefined") {
  3. gScriptLoaded = true;
  4.  
  5. var args;
  6. var cmd;
  7. var input;
  8. var isAdmin;
  9. var admins = [MPP.client.user._id]; // you're added by default.
  10. // If you want to add more preople use !js admins.push(their_id_here)
  11. // this will allow them to use !js too. But be careful who you trust!
  12. var cmdChar = "!"; // you can change this to any single character :3
  13.  
  14. // simplified
  15. function sendChat(msg) {
  16. MPP.chat.send(msg);
  17. }
  18.  
  19. Object.prototype.toString = function() {
  20. return JSON.stringify(this);
  21. }
  22.  
  23. MPP.client.on("a", function (msg) {
  24. args = msg.a.split(' ');
  25. cmd = args[0];
  26. input = msg.a.substring(cmd.length).trim();
  27.  
  28. isAdmin = false; // this will remain false if the below check fails
  29. // if this isAdmin is manually set to true anyone
  30. // will be able to use !js. This is very bad
  31. if (admins.indexOf(msg.p._id) != -1) isAdmin = true; // makes you admin if you're in admins
  32.  
  33. // anything inside this block will run if the user is an admin
  34. if (isAdmin) {
  35. if (cmd == cmdChar+"js") {
  36. try {
  37. sendChat("Console: " + eval(input));
  38. } catch (err) {
  39. sendChat(''+err);
  40. }
  41. }
  42. } // else they're not admin
  43. });
  44. } else {
  45. console.warn("You've already pasted the script!\nRefresh the page then paste it again");
  46. }
Add Comment
Please, Sign In to add comment