sparkychild

Untitled

Aug 22nd, 2015
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     parseEmotes: function(html, room) {
  2.  
  3.         if (html.indexOf('<div class=\'chat\'><small>') !== 0) return false;
  4.         var emoteList = ["#freewolf", "feelsbd", "feelsbn", "feelspn", "feelsdd", "feelsgd", "feelsgn", "feelsmd", "feelsnv", "feelsok", "feelspika", "feelspink", "feelsrs", "feelssc", "fukya", "funnylol", "hmmface", "Kappa", "noface", "Obama", "oshet", "PJsalt", "trumpW", "Sanic", "wtfman", "xaa", "yayface", "yesface", "meGusta", "trollface", "Doge"];
  5.         var initialLength = html.length;
  6.         var usersearch = html.indexOf('</small><button name=\'parseCommand\' value=\'/user ') + 49
  7.  
  8.         var user = html.slice(usersearch).split('\' style=\'background:none;border:0;padding:0 5px 0 0;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:9pt;cursor:pointer\'><b><font color=')[0];
  9.  
  10.  
  11.         if (toId(user) === toId(config.nick)) return false;
  12.         var emoteCount = 0;
  13.  
  14.         var emoteStats = {};
  15.  
  16.         for (var j = 0; j < emoteList.length; j++) {
  17.             var replacer = '" title="' + emoteList[j] + '" />';
  18.             var newText = '';
  19.             emoteStats[emoteList[j]] = 0;
  20.             for (var i = 0; i < ~~(initialLength / replacer.length) + 1; i++) {
  21.                 if (html.indexOf(replacer) === -1) {
  22.                     break;
  23.                 }
  24.                 emoteStats[emoteList[j]]++;
  25.                 html = html.replace(replacer, '');
  26.                 emoteCount++;
  27.             }
  28.         }
  29.  
  30.         //parse flooding
  31.         if (emoteStats) {
  32.             if (!emoteFlooding[toId(user)]) {
  33.                 emoteFlooding[toId(user)] = 0;
  34.             }
  35.             emoteFlooding[toId(user)]++
  36.                 setTimeout(function() {
  37.                     emoteFlooding[toId(user)]--
  38.                 }.bind(this), FLOOD_MESSAGE_TIME);
  39.             if (emoteFlooding[toId(user)] >= FLOOD_MESSAGE_NUM) {
  40.                 emoteCount = emoteFlooding[toId(user)];
  41.             }
  42.         }
  43.         //moderation
  44.         this.emoteModerate(emoteCount, user, room)
  45.     },
  46.     emoteModerate: function(count, user, room) {
  47.         if (this.rankFrom(user, '+')) return false;
  48.  
  49.         if (!emoticonAbuse[toId(user)]) {
  50.             emoticonAbuse[toId(user)] = 0
  51.         }
  52.         if (count < 3) return false;
  53.         if (count > 2) {
  54.             emoticonAbuse[toId(user)] = emoticonAbuse[toId(user)] + count;
  55.         }
  56.  
  57.         var noModeration = fs.readFileSync('data/emotemoderation.txt').toString().split('\n');
  58.         if (noModeration.indexOf('d|' + room) > -1) {
  59.             return false;
  60.         }
  61.  
  62.  
  63.         if (count > 15) {
  64.             if (this.hasRank(this.ranks[room], '@#&~')) {
  65.                 return this.talk(room, '/roomban ' + user + ', Emoticon Spam (' + count + ' [' + emoticonAbuse[toId(user)] + '])');
  66.             }
  67.             else if (this.hasRank(this.ranks[room], '%')) {
  68.                 return this.talk(room, '/hourmute ' + user + ', Emoticon Spam (' + count + ' [' + emoticonAbuse[toId(user)] + '])');
  69.             }
  70.         }
  71.         //
  72.  
  73.         if (emoticonAbuse[toId(user)] > 150) {
  74.             if (this.hasRank(this.ranks[room], '@#&~')) {
  75.                 return this.talk(room, '/roomban ' + user + ', Emoticon Spam (' + count + ' [' + emoticonAbuse[toId(user)] + '])');
  76.             }
  77.             else if (this.hasRank(this.ranks[room], '%')) {
  78.                 return this.talk(room, '/hourmute ' + user + ', Emoticon Spam (' + count + ' [' + emoticonAbuse[toId(user)] + '])');
  79.             }
  80.         }
  81.         else if (emoticonAbuse[toId(user)] > 50 && emoticonAbuse[toId(user)] < 151) {
  82.             if (this.hasRank(this.ranks[room], '%@#&~')) {
  83.                 return this.talk(room, '/hourmute ' + user + ', Please do not spam emoticons. (' + count + ' [' + emoticonAbuse[toId(user)] + '])');
  84.             }
  85.         }
  86.         else if (emoticonAbuse[toId(user)] > 6 && emoticonAbuse[toId(user)] < 51) {
  87.             if (this.hasRank(this.ranks[room], '%@#&~')) {
  88.                 return this.talk(room, '/mute ' + user + ', Please do not abuse emoticons. (' + count + ' [' + emoticonAbuse[toId(user)] + '])');
  89.             }
  90.         }
  91.         else if (emoticonAbuse[toId(user)] > 2 && emoticonAbuse[toId(user)] < 7) {
  92.             if (this.hasRank(this.ranks[room], '%@#&~')) {
  93.                 return this.talk(room, '/warn ' + user + ', Please use emoticons in moderation. (' + count + ' [' + emoticonAbuse[toId(user)] + '])');
  94.             }
  95.         }
  96.     },
Advertisement
Add Comment
Please, Sign In to add comment