Advertisement
Guest User

Untitled

a guest
Jul 24th, 2018
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XPP 1.01 KB | None | 0 0
  1. var ignore_check = function(user)
  2. {
  3.     return user.substring(0, 7) == 'tourist';
  4. }
  5.  
  6. let ignore = function(data)
  7. {
  8.     let user = null;
  9.  
  10.     if(typeof data.user == 'string'
  11.     && data.user.length >= 1
  12.     && data.user != 'none')
  13.     {
  14.         user = data.user;
  15.     } else
  16.     if(typeof data.msg == 'string'
  17.     && data.msg.length >= 1)
  18.     {
  19.         let s = data.msg;
  20.         let u = s.indexOf('<b');
  21.         if(u != -1) u = s.indexOf('>', u);
  22.         if(u != -1) ++u;
  23.         let ue = s.indexOf('<', u);
  24.         if(ue != -1) user = s.substring(u, ue);
  25.         if(user)
  26.         {
  27.             console.log('parsed user==['+user+']');
  28.         }
  29.     }
  30.  
  31.     if(user !== null)
  32.     {
  33.         console.log('final user==['+user+']');
  34.  
  35.         if(ignore_check(user.toLowerCase()))
  36.         {
  37.             console.log('ignoring');
  38.             return true;
  39.         }
  40.     }
  41.  
  42.     console.log('not ignoring');
  43.     return false;
  44. };
  45.  
  46. ['private', 'message'].forEach(function(cmd)
  47. {
  48.  
  49.     let cb = window.io(document.location.hostname+':8000')._callbacks
  50. ;
  51.     let old = cb[cmd][0];
  52.     cb[cmd][0] = function(data)
  53.     {
  54.         if(!ignore(data))
  55.         {
  56.             old(data);
  57.         }
  58.     }
  59. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement