kamijoutouma

my mod command file

Apr 28th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // Derplib command file
  3.  
  4. var MM       = module.parent,
  5.     commands = MM.plugin.load('commands'),
  6.     db       = MM.plugin.load('database'),
  7.     utils    = MM.libary.load('utils'),
  8.     DerpLib  = MM.parent,
  9.     _        = require('underscore');
  10.    
  11. commands.register({
  12.     key: 'mods',
  13.     access: 1,
  14.     run: function(req){
  15.         var owner = [],
  16.             mods = [],
  17.             all = {};
  18.         var pm = _.find(MM.parent._data.pms, function(pm){
  19.             return pm._sock && pm._sock._connected;
  20.         });
  21.         setTimeout(function(){
  22.             if(pm){
  23.                 pm.addfreind(req.room.admin);
  24.                 pm.on('frame_wladd', function(frame){
  25.                     var _frame = utils.parseContact(frame.state, frame.time);
  26.                     if(_frame.state == 'online'){
  27.                         all[frame.name] = {name: frame.name, rank: 'admin', status: _frame.state};
  28.                     }else if(_frame.state == 'offline'){
  29.                         all[frame.name] = {name: frame.name, rank: 'admin', status: _frame.state};
  30.                     }else if(_frame.state == 'idle'){
  31.                         all[frame.name] = {name: frame.name, rank: 'admin', status: _frame.state};
  32.                     }else{
  33.                         all[frame.name] = {name: frame.name, rank: 'admin'};
  34.                     }
  35.                 });
  36.             }else{
  37.                 all[req.room.admin] = {name: req.room.admin, rank: 'admin'};
  38.             }
  39.             _.each(req.room.mods, function(user){
  40.                 if(pm){
  41.                     pm.addfreind(user);
  42.                     pm.on('frame_wladd', function(frame){
  43.                         if(!(frame.name == req.room.admin)){
  44.                             var _frame = utils.parseContact(frame.state, frame.time);
  45.                             if(_frame.state == 'online'){
  46.                                 all[frame.name] = {name: frame.name, rank: 'mod', status: _frame.state};
  47.                             }else if(_frame.state == 'offline'){
  48.                                 all[frame.name] = {name: frame.name, rank: 'mod', status: _frame.state};
  49.                             }else if(_frame.state == 'idle'){
  50.                                 all[frame.name] = {name: frame.name, rank: 'mod', status: _frame.state};
  51.                             }else{
  52.                                 all[frame.name] = {name: frame.name, rank: 'mod'};
  53.                             }
  54.                         }
  55.                     });
  56.                 }else{
  57.                     if(!(req.room.admin == user)){
  58.                         all[user] = {name: user, rank: 'mod'};
  59.                     }
  60.                 }
  61.             });
  62.             if(pm){
  63.                 setTimeout(function(){
  64.                     _.each(all, function(user){
  65.                         if(user.rank == 'mod'){
  66.                             if(user.name == req.room._accountLC){
  67.                                 mods.push("<font color=\"#cc00ff\">"+user.name+"</font>");
  68.                             }else if(user.status == 'online'){
  69.                                 mods.push("<font color=\"#cc00ff\">"+user.name+"</font>");
  70.                             }else if(user.status == 'offline'){
  71.                                 mods.push("<font color=\"#ff0000\">"+user.name+"</font>");
  72.                             }else if(user.status == 'idle'){
  73.                                 mods.push("<font color=\"#00ffff\">"+user.name+"</font>");
  74.                             }else{
  75.                                 mods.push("<font color=\"#666666\">"+user.name+"</font>");
  76.                             }
  77.                         }else if(user.rank == 'admin'){
  78.                             if(user.name == req.room._accountLC){
  79.                                 owner.push("<font color=\"#cc00ff\">"+user.name+"</font>");
  80.                             }else if(user.status == 'online'){
  81.                                 owner.push("<font color=\"#cc00ff\">"+user.name+"</font>");
  82.                             }else if(user.status == 'offline'){
  83.                                 owner.push("<font color=\"#ff0000\">"+user.name+"</font>");
  84.                             }else if(user.status == 'idle'){
  85.                                 owner.push("<font color=\"#00ffff\">"+user.name+"</font>");
  86.                             }else{
  87.                                 owner.push("<font color=\"#666666\">"+user.name+"</font>");
  88.                             }
  89.                         }
  90.                     });
  91.                 }, 800);
  92.             }else{
  93.                 setTimeout(function(){
  94.                     _.each(req.room.mods, function(user){
  95.                         mods.push("<font color=\"#666666\">"+user+"</font>");
  96.                     });
  97.                     owner.push("<font color=\"#666666\">"+req.room.admin+"</font>");
  98.                 }, 800);
  99.             }
  100.             setTimeout(function(){
  101.                 req.write("Owner: "+owner+" \r <font colot=\"#edf345\">Mods: </font>"+mods.join('<font colot=\"#edf345\">, </font>')+" \r <font color=\"#00ffff\">Idle</font>   <font color=\"#ff0000\">Offline</font>   <font color=\"#cc00ff\">Online</font>   <font color=\"#666666\">Unknown (usually because its not connected to the pms)</font>");
  102.             }, 1200);
  103.         }, 400);
  104.     },
  105. });
Advertisement
Add Comment
Please, Sign In to add comment