Advertisement
Guest User

Untitled

a guest
May 9th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var memberarr = [GG.config.user.alias.toLowerCase(),"madhank","kauhut","thermodust","phanakapan","nvidia"];
  2. var adminarr = [GG.config.user.alias.toLowerCase(),"madhank","thermodust","phanakapan","nvidia"];
  3. var banarr = [];
  4.  
  5. var pass = 'mudkipz';
  6.  
  7. function extract0(command){
  8.     //Checks for any spaces in front of the command, and removes them
  9.     while (command.indexOf(' ') == 0) command = command.substring(1,command.length);
  10.    
  11.     return {command: command};
  12. }
  13.  
  14. function extract1(command){
  15.    
  16.     //Checks for any spaces in front of the command, and removes them
  17.     command = extract0(command).command;
  18.     //Checks for spaces in the command, and returns default if there are none
  19.     if (command.indexOf(' ') == -1) return {command: command, modifier: ''};
  20.    
  21.     return {
  22.         command: command.substring(0,command.indexOf(' ')),
  23.         modifier: command.substring(command.indexOf(' ')+1,command.length)
  24.     }
  25. }
  26.  
  27. function extract2(command){
  28.     //Checks for any spaces in front of the command, and removes them
  29.     command = extract0(command).command;
  30.     //Checks for spaces in the command, and returns default if there are none
  31.     if (command.indexOf(' ') == -1) return {command: command, modifier: '',args: []};
  32.     //Checks for commas in the command, and returns extract1 if there are none
  33.     if (command.indexOf(',') < command.indexOf(' '))
  34.     return {command: extract1(command).command, modifier: extract1(command).modifier, args: []};
  35.    
  36.         var modifier = command.substring(command.indexOf(' ')+1,command.length);
  37.        
  38.     return {
  39.         command: command.substring(0,command.indexOf(' ')),
  40.         modifier: modifier.substring(0,modifier.indexOf(' ')),
  41.         args: modifier.substring(modifier.indexOf(' ')+1,modifier.length).replace(/ /g,'').split(',')
  42.     }
  43.    
  44. }
  45.  
  46. function parseCommand(slashcommand,user){
  47.    
  48.     command = extract2(slashcommand).command;
  49.     modifier = extract2(slashcommand).modifier;
  50.     args = extract2(slashcommand).args;
  51.    
  52.     //alert(command+', '+modifier+', '+args.join(','));
  53.     //Member commands
  54.     if(memberarr.join('|').search(user) > -1 || adminarr.toString().search(user) > -1){
  55.         switch(command){
  56.             case 'start':
  57.                 GG.jabber.chat.send(GG.IA.party.id, "Starting Game...");
  58.                 GG.jabber.chat.send(GG.IA.party.id, "Good Luck!");
  59.                 setTimeout(function() {GG.game.domain.start();},2000);
  60.             break;
  61.             case 'invite':
  62.                 invitearr = slashcommand.substring(slashcommand.indexOf(' ')+1,slashcommand.length).replace(/ /g,'').split(',');
  63.                 for(m=0;m<=invitearr.length;m++) GG.IA.party.sendInvite(invitearr[m]);
  64.                 GG.jabber.chat.send(GG.IA.party.id, "Invite(s) sent to "+invitearr.join(', '));
  65.             break;
  66.             default:
  67.                 //Do nothing
  68.             break;
  69.         }
  70.     }
  71.     //Admin commands
  72.     if(adminarr.join('|').search(user) > -1){
  73.         switch(command){
  74.             case 'end':
  75.                 GG.jabber.chat.send(GG.IA.party.id, "Ending current game...");
  76.                 GG.game.domain.end();
  77.             break;
  78.             case 'kick':
  79.                
  80.                 GG.IA.party.kick(modifier);
  81.                 GG.jabber.chat.send(GG.IA.party.id, modifier+" was kicked from the server by "+user);
  82.             break;
  83.             case 'ban':
  84.                 if(banarr.join('|').search(modifier) == -1){
  85.                     GG.IA.party.kick(modifier);
  86.                     banarr.push(modifier.toLowerCase());
  87.                     GG.jabber.chat.send(GG.IA.party.id, modifier+" was banned from the server by "+user);
  88.                 }else{
  89.                     GG.jabber.chat.send(modifier+" is already on the ban list");
  90.                 }
  91.             break;
  92.             case 'get':
  93.                 switch(modifier){
  94.                     case 'members':
  95.                         GG.jabber.chat.send(GG.IA.party.id, "Server Members:");
  96.                         GG.jabber.chat.send(GG.IA.party.id, memberarr.join(', '));
  97.                     break;
  98.                     case 'admins':
  99.                         GG.jabber.chat.send(GG.IA.party.id, "Server Admins:");
  100.                         GG.jabber.chat.send(GG.IA.party.id, adminarr.join(', '));
  101.                     break;
  102.                     case 'banned':
  103.                         if (banarr.length>=1){
  104.                             GG.jabber.chat.send(GG.IA.party.id, "Banned Users:");
  105.                             GG.jabber.chat.send(GG.IA.party.id, banarr.join(', '));
  106.                         }else{
  107.                             GG.jabber.chat.send(GG.IA.party.id, "The list of banned users is currently empty");
  108.                         }
  109.                     break;
  110.                     default:
  111.                         GG.jabber.chat.send(GG.IA.party.id, "Current /get parameters are limited to userlists");
  112.                     break;
  113.                 }
  114.             break;
  115.             case 'add':
  116.                 addarr = modifier.toLowerCase().substring(modifier.indexOf(' '),modifier.length).replace(/ /g,'').split(',');
  117.                 modifier = modifier.toLowercase().substring(0,modifier.indexOf(' '));
  118.                 alert(addarr);
  119.                 alert(modifier);
  120.                 switch(modifier){
  121.                     case 'members':
  122.                         alert('this far');
  123.                         memberarr.concat(addarr);
  124.                         GG.jabber.chat.send(GG.IA.party.id, addarr.slice(1,addarr.length-1).join(', ')+" added to Server Members.");
  125.                     break;
  126.                     case 'admins':
  127.                         for(m=0;m<=addarr.length;m++) adminarr.push(addarr[m].toLowercase());
  128.                         GG.jabber.chat.send(GG.IA.party.id, addarr.slice(1,addarr.length-1).join(', ')+" added to Server Admins.");
  129.                     break;
  130.                     case 'banned':
  131.                         for(m=0;m<=addarr.length;m++) banarr.push(addarr[m].toLowercase());
  132.                         GG.jabber.chat.send(GG.IA.party.id, addarr.slice(1,addarr.length).join(', ')+" added to Banned Users.");
  133.                     break;
  134.                     default:
  135.                         GG.jabber.chat.send(GG.IA.party.id, "Current /add parameters are limited to userlists");
  136.                     break;
  137.                 }
  138.             break;
  139.             default:
  140.                 //Do nothing
  141.             break;
  142.         }
  143.     }
  144. }
  145.  
  146. GG.plugin.game.options.onPacket = function(e){
  147.     if(e.type == 'message'){
  148.         xml = String.parseXML(e.message);
  149.         if(xml.firstChild.getAttribute('type')=='headline'){
  150.             //alert('It\'s a headline!');
  151.             var element;
  152.             if (element = xml.getElementsByTagName('inbox')[0]){
  153.                 //alert('New Inbox Message!');
  154.        
  155.         new Ajax.Request('/messages/inbox',{
  156.             method:'get',
  157.             onSuccess: function(transport){
  158.                 html = transport.responseText;
  159.                 name = html.split('"msg_from"')[1].split('viewProfile(\'')[1].split('\'')[0];
  160.                 title = html.split('"msg_subject"')[1].split('clearCSSTabs(\'messagesNavigation\'); return false;">')[1].split('</a>')[0];
  161.                                 //alert(name+', '+title);
  162.                 if(title==pass) GG.IA.party.sendInvite(name);
  163.             }
  164.         });
  165.        
  166.             }
  167.         }else if(xml.firstChild.getAttribute('type')=='groupchat' && (element = xml.getElementsByTagName('body')[0])){
  168.         from = GG.jabber.splitJID(xml.firstChild.getAttribute('from'));
  169.                 user = from.resource;
  170.         chat = GG.jabber.chat.encode(element.firstChild.nodeValue);
  171.         if(chat.indexOf('/') == 0){
  172.                     slashcommand = chat.substring(1,chat.length);
  173.             parseCommand(slashcommand,user);
  174.         }
  175.     }
  176.     }else if(e.type == 'presence'){
  177.     xml = String.parseXML(e.message);
  178.     //alert(xml.firstChild.getAttribute('from'));
  179.     from = xml.firstChild.getAttribute('from').split('/')[1];
  180.     if (banarr.join('|').search(from) > -1) GG.IA.party.kick(from);
  181.     }
  182.     GG.jabber.switcher(e);
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement