prog

cubix

Sep 20th, 2010
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var TICK_DELAY      = 1;
  2. var LOCK_DELAY      = 60;
  3. var MAX_LINES       = 50;
  4. var MAX_CHARS       = 1024;
  5. var LINES_PER_TICK  = 10;
  6. var CHARS_PER_TICK  = 512;
  7.  
  8. var lineCount = 0;
  9. var charCount = 0;
  10. var timeLocked = null;
  11.  
  12. function resetText()
  13. {
  14.   lineCount -= LINES_PER_TICK;
  15.   if (lineCount < 0)
  16.   {
  17.     lineCount = 0;
  18.   }
  19.   charCount -= CHARS_PER_TICK;
  20.   if (charCount < 0)
  21.   {
  22.     charCount = 0;
  23.   }
  24.   if (timeLocked != null)
  25.   {
  26.     if (new Date() - timeLocked > LOCK_DELAY)
  27.     {
  28.       irc.raw('SILENCE -*');
  29.       timeLocked = null;
  30.     }
  31.   }
  32. }
  33.  
  34. context.CreateTimer("resetText", null, TICK_DELAY);
  35.  
  36. function processText()
  37. {
  38.   if (timeLocked != null)
  39.   {
  40.     return;
  41.   }
  42.   lineCount++;
  43.   charCount += text.length;
  44.   if (lineCount > MAX_LINES || charCount > MAX_CHARS)
  45.   {
  46.     irc.raw('SILENCE +*!~*@*');
  47.     timeLocked = new Date();
  48.   }
  49. }
  50.  
  51. onprivtext = processText;
  52. onprivnotice = processText;
  53. onprivaction = processText;
  54. onprivctcp = processText;
  55. onctcpreply = processText;
Add Comment
Please, Sign In to add comment