Advertisement
Guest User

!come with warning

a guest
Dec 17th, 2015
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. registerPlugin({
  2.     name: '!come',
  3.     version: '1.1',
  4.     description: 'Implements the !come and !goaway command.',
  5.     author: 'Xuxe <xuxe@xuxe-network.eu>',
  6.     vars: {
  7.  
  8.           ids: {
  9.             title: 'Client Unique Ids (Comma seperated):',
  10.             type: 'string'
  11.           },
  12.        
  13.            cid: {
  14.                title: 'Default Channel ID (Needed for !goaway): ',
  15.                type: 'channel'
  16.            },
  17.        
  18.            sids: {
  19.                title: 'Whitelisted Servergroup Ids (Comma seperated):',
  20.                type: 'string'
  21.            }
  22.     }
  23.  
  24. },  function (sinusbot, config) {          
  25.          
  26.             if (config.sids) {
  27.                 var sids = config.sids.split(',');
  28.             }
  29.             else {
  30.                 log("SIDs not valid...");
  31.                 var sids = new Array();
  32.             }
  33.            
  34.             if (config.ids) {
  35.                 var uids = config.ids.split(',');
  36.             }
  37.             else {
  38.                 log("UIDs not valid...");
  39.                 var uids = new Array();
  40.             }
  41.            
  42.            sinusbot.on('chat', function(ev) {                                  
  43.                    
  44.                         var IsInServerGroup = ev.clientServerGroups.some(function(group)
  45.                         {
  46.                                
  47.                                 if(sids.indexOf(group.i.toString()) >= 0)
  48.                                 {
  49.                                     return true;
  50.  
  51.                                 } else { return false; }
  52.  
  53.  
  54.                         });                
  55.  
  56.                         if(uids.indexOf(ev.clientUid) >= 0 || IsInServerGroup == true)
  57.                         {
  58.            
  59.                                 switch(ev.msg)
  60.                                 {
  61.                                     case "!come":
  62.                                                 var oldChannel = getCurrentChannelId();
  63.                                                 var channel, client;
  64.                                                 var channels = getChannels();
  65.                                            
  66.                                                 for (var i = 0; i < channels.length; i++) {
  67.  
  68.                                                     if (!channels[i].clients) continue;
  69.                                                     channel = channels[i];
  70.                                                         for (var x = 0; x < channel.clients.length; x++) {
  71.                                                         client = channel.clients[x];
  72.                                                        
  73.                                                             if (client.id == ev.clientId) {
  74.                                                                 join(channel.id);
  75.                                                                 log("Going to client: "+ev.clientNick);
  76.                                                                 if(oldChannel == getCurrentChannelId()) {
  77.                                                                     chatPrivate(ev.clientId, 'can not join the channel, maybe missing rights or the channel is full');
  78.                                                                 }
  79.                                                             }
  80.                                          
  81.                                                     }
  82.                                                 }
  83.                                        
  84.                                  
  85.                                          
  86.                                          
  87.                                     break;
  88.                                    
  89.                                     case "!goaway":
  90.                                    
  91.                                                 if(!config.cid) {
  92.                
  93.                                                     log('Default channel is not set. Command !goaway not available.');
  94.                                                     return;
  95.                                                 }
  96.                                                
  97.                                                 join(config.cid);
  98.                                                 log("Going back to my default channel.");
  99.                                     break;
  100.                                 }
  101.                
  102.                         }
  103.    
  104.            
  105.         });
  106.  
  107.  
  108. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement