Advertisement
OrFeAsGr

Seen Fix

Feb 7th, 2019
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 11.66 KB | None | 0 0
  1. alias deltime {
  2.   ;;;;;YOU ONLY NEED TO INPUT A VALUE HERE IF YOU WANT TO DELETE HOSTS THAT
  3.   ;;;;;HAVEN'T BEEN SEEN FOR A CERTAIN AMOUNT OF TIME.
  4.   ;;;;;IF YOU DON'T WANT TO DELETE HOSTS LEAVE IT AS IT IS
  5.   ;;;;;OTHERWISE INPUT BELOW A TIME VALUE IN THIS FORMAT: 1d (1 day) 1d12h (1 day and 12 hours and so on)
  6.   ;;;;;SO IF YOU WANT 10 DAYS IT SHOULD LOOK LIKE THIS: var %time = 10d
  7.   var %time = 10d
  8.   ;;;;;DON'T EDIT AFTER THIS LINE
  9.   return %time
  10. }
  11.  
  12. ON *:START: {
  13.   if (!$isdir($mircdirseen)) {
  14.     mkdir seen
  15.   }
  16.   .timerseenscanold 0 86400 seenscanold $deltime
  17.   hmake hostlist 10000
  18.   if ($isfile($seendir(hostlist.hsh))) {
  19.     hload hostlist $+($seendir(hostlist),.hsh)
  20.   }
  21.   var %x = $hget(hostlist,0).item
  22.   while (%x) {
  23.     var %y = $hget(hostlist,%x).item
  24.     hmake $seenh(%y) 100
  25.     if ($isfile($+($seendir($seenh(%y)),.hsh))) {
  26.       hload $seenh(%y) $+($seendir($seenh(%y)),.hsh)
  27.     }
  28.     dec %x
  29.   }
  30. }
  31.  
  32. alias valtotim {
  33.   var %s
  34.   var %x = $1
  35.   var %y = $left($replace(%x,s,~s-,m,~m-,h,~h-,d,~d-,w,~w-,y,~y-),-1)
  36.   var %z = $numtok(%y,45)
  37.   while (%z) {
  38.     var %a = $gettok(%y,%z,45)
  39.     var %b = $gettok(%a,1,126)
  40.     var %c = $gettok(%a,2,126)
  41.     if (%c == y) { var %t = 31536000 }
  42.     if (%c == w) { var %t = 604800 }
  43.     if (%c == w) { var %t = 604800 }
  44.     if (%c == d) { var %t = 86400 }
  45.     if (%c == h) { var %t = 3600 }
  46.     if (%c == m) { var %t = 60 }
  47.     if (%c == s) { var %t = %b }
  48.     var %v = $calc(%t * %b)
  49.     var %s = $calc(%s + %v)
  50.     dec %z
  51.   }
  52.   return %s
  53. }
  54.  
  55. alias seenscanold {
  56.   var %e
  57.   var %d = $1
  58.   if (%d != nodel) {
  59.     var %x = $hget(hostlist,0).item
  60.     while (%x) {
  61.       var %y = $hget(hostlist,%x).item
  62.       var %z = $hget(hostlist,%x).data
  63.       var %p = $calc($ctime - %z)
  64.       var %s = $seenh(%y)
  65.       var %q = $valtotim(%d)
  66.       if (%p >= %q) {
  67.         var %e = $calc(%e + 1)
  68.         hdel hostlist %y
  69.         hsave hostlist $seendir(hostlist.hsh)
  70.         hfree %s
  71.         .remove $seendir($+(%s,.hsh))
  72.       }
  73.       dec %x
  74.     }
  75.     echo -at (Auto Seen Scan) Found and deleted %e Hosts that haven't been seen for/for more than $1 (as set by user)
  76.   }
  77. }
  78.  
  79.  
  80.  
  81.  
  82.  
  83. alias par {
  84.   if ($1) {
  85.     return $+($chr(40),$1,$chr(41))
  86.   }
  87.   else {
  88.     return $null
  89.   }
  90. }
  91.  
  92. alias evtowo {
  93.   var %e = $1
  94.   if ($istok(join part quit,%e,32)) {
  95.     return $+(%e,ing)
  96.   }
  97.   else {
  98.     if (%e == nick) {
  99.       return changing nick
  100.     }
  101.     if (%e == text) {
  102.       return msging
  103.     }
  104.   }
  105. }
  106.  
  107. alias seendir {
  108.   return $+($mircdirseen\,$1)
  109. }
  110.  
  111. alias seenh {
  112.   return $+(seen,$1)
  113. }
  114.  
  115. alias seenicks {
  116.   return $hget($1,nicks)
  117. }
  118.  
  119. alias addhost {
  120.   if (!$hget(hostlist,$1)) {
  121.     hadd hostlist $1 $ctime
  122.     hsave hostlist $+($seendir(hostlist),.hsh)
  123.   }
  124. }
  125.  
  126.  
  127. alias fss {
  128.   var %x = 1
  129.   var %y = $hget(0)
  130.   while (%x <= %y) {
  131.     var %z = $hget(%x)
  132.     if (seen* iswm %z) {
  133.       var %a = %x
  134.     }
  135.     $iif(%a, break)
  136.     inc %x
  137.   }
  138.   return %a
  139. }
  140.  
  141.  
  142. alias searchnick {
  143.   var %n = $1
  144.   var %d = $hget(0)
  145.   var %f = $fss
  146.   hmake tempsrch
  147.   while (%d >= %f) {
  148.     var %h = $hget(%d)
  149.     var %nicks = $hget(%h,nicks)
  150.     var %i = $istok(%nicks,%n,32)
  151.     var %w = $wildtok(%nicks,%n,1,32)
  152.     if (%i) || (%w) {
  153.       var %time = $hget(%h,time)
  154.       hadd tempsrch %h %time
  155.     }
  156.     dec %d
  157.   }
  158.   var %all = $hget(tempsrch,0).item
  159.   var %res = $ducktop(tempsrch)
  160.   hfree tempsrch
  161.   if (!%res) { return NoRes }
  162.   var %t = $gettok(%res,1,32)
  163.   var %nicks = $gettok($hget(%t,nicks),1-5,32)
  164.   var %event = $hget(%t,event)
  165.   if (*kicke* iswm %event) {
  166.     var %k2 = $hget(%t,k2)
  167.   }
  168.   var %time = $hget(%t,time)
  169.   var %chan = $hget(%t,chan)
  170.   var %net = $hget(%t,net)
  171.   var %extra = $hget(%t,extra)
  172.   var %nt = $numtok(%nicks,32)
  173.   if (%event == nick) {
  174.     var %tonick = $hget(%t,tonick)
  175.   }
  176.   var %t = $replace(%t,humslashhost,/)
  177.   var %seenresult = %time %all °Seen° $replace($mid(%t,5,$len(%t)),humtwodots,:) $par($iif(%nt > 1, Last %nt nicks:) %nicks) $par(Last seen $iif(%event == kicker, kicking %k2 out of %chan, $iif(%event == kicked, being kicked out of %chan by %k2, $evtowo(%event) $iif(%event == nick, to %tonick) %chan)) on %net) $par($iif(%extra, $iif(%event == text, Msg:, Reason:) $iif($istok(quit part,%event,32) && $len(%extra) >= 100, $+($left(%extra,100),[...]), %extra))) $duration($calc($ctime - %time)) ago $+($chr(40),$asctime($ctime,dd/mm/yy HH:nn zz),$chr(41))
  178.   return %seenresult
  179. }
  180.  
  181. alias searchhost {
  182.   var %h = $1
  183.   var %r = $hget(hostlist,%h)
  184.   if (!%r) {
  185.     var %hf = $hfind(hostlist, %h, 0, w)
  186.     if (!%hf) {
  187.       return NoRes
  188.     }
  189.     hmake tempsrch 100
  190.     while (%hf) {
  191.       var %x = $hfind(hostlist, %h, %hf, w)
  192.       var %y = $hget(hostlist,%x)
  193.       hadd tempsrch %x %y
  194.       dec %hf
  195.     }
  196.     var %all = $hget(tempsrch,0).item
  197.     var %res = $ducktop(tempsrch)
  198.     ;msg #test %res
  199.     hfree tempsrch
  200.     var %h = $gettok(%res,1,32)
  201.   }
  202.   var %t = $seenh(%h)
  203.   var %nicks = $gettok($hget(%t,nicks),1-5,32)
  204.   var %event = $hget(%t,event)
  205.   if (*kicke* iswm %event) {
  206.     var %k2 = $hget(%t,k2)
  207.   }
  208.   var %time = $hget(%t,time)
  209.   var %chan = $hget(%t,chan)
  210.   var %net = $hget(%t,net)
  211.   var %extra = $hget(%t,extra)
  212.   if (%event == nick) {
  213.     var %tonick = $hget(%t,tonick)
  214.   }
  215.   var %nt = $numtok(%nicks,32)
  216.   var %t = $replace(%t,humslashhost,/)
  217.   var %seenresult = %time %all °Seen° $replace($mid(%t,5,$len(%t)),humtwodots,:) $par($iif(%nt > 1, Last %nt nicks:) %nicks) $par(Last seen $iif(%event == kicker, kicking %k2 out of %chan, $iif(%event == kicked, being kicked out of %chan by %k2, $evtowo(%event) $iif(%event == nick, to %tonick) %chan)) on %net) $par($iif(%extra, $iif(%event == text, Msg:, Reason:) $iif($istok(quit part,%event,32) && $len(%extra) >= 100, $+($left(%extra,100),[...])),%extra)) $duration($calc($ctime - %time)) ago $+($chr(40),$asctime($ctime,dd/mm/yy HH:nn zz),$chr(41))
  218.   return %seenresult
  219. }
  220.  
  221. alias findper {
  222.   var %numbertotal = $1
  223.   var %numberwant = $2
  224.   var %perwant = $calc((%numberwant * 100) / %numbertotal)
  225.   return $+(%perwant,%)
  226. }
  227.  
  228. ON *:TEXT:*:#: {
  229.   if ($1 == $+($chr(37),seens)) {
  230.     msg $chan I have $hget(hostlist,0).item hosts in my mind!
  231.   }
  232.   if ($1 == $+($chr(37),aka)) {
  233.     if (. isin $2) {
  234.       var %h = $searchhost($replace($2,/,humslashhost),aka)
  235.       msg $chan %h
  236.     }
  237.     else {
  238.       var %n = $searchnick($replace($2,/,humslashhost),aka)
  239.       msg $chan %n
  240.     }
  241.   }
  242.   if ($1 == $+($chr(37),seen)) {
  243.     var %aster = $iif($chr(42) iswm $2, 1, 0)
  244.     var %ticks = $ticks
  245.     var %orig = $2
  246.     var %h = $searchhost($replace($2,/,humslashhost,:,humtwodots))
  247.     var %n = $searchnick($replace($2,/,humslashhost,:,humtwodots))
  248.     if (%h != NoRes) && (%n != NoRes) {
  249.       var %ht = $gettok(%h,1,32)
  250.       var %nt = $gettok(%n,1,32)
  251.       var %bg = $iif(%ht > %nt, %h, %n)
  252.       tokenize 32 %bg
  253.       var %totalres = $2
  254.       var %res = $3-
  255.       msg $chan $iif(%aster && %totalres > 1, Most recent result) %res $calc(($ticks - %ticks) / 1000)
  256.       if (%aster) && (%totalres > 1) { .timer 1 1 .notice $nick For %totalres more results !aka %orig }
  257.       return
  258.     }
  259.     if (%h != NoRes) && (%n == NoRes) {
  260.       tokenize 32 %h
  261.       msg $chan $3-
  262.       return
  263.     }
  264.     if (%h == NoRes) && (%n != NoRes) {
  265.       tokenize 32 %n
  266.       msg $chan $3-
  267.       return
  268.     }
  269.     if (%h %n == NoRes NoRes) {
  270.       msg $chan No results found, sorry!
  271.       return
  272.     }
  273.   }
  274.   var %site = $replace($site,/,humslashhost,:,humtwodots)
  275.   addhost %site
  276.   var %n = $nick
  277.   var %s = $seenh(%site)
  278.   if (!$hget(%s)) {
  279.     hmake %s 100
  280.   }
  281.   if ($hget(%s,tonick)) {
  282.     hdel %s tonick
  283.   }
  284.   hadd %s event $event
  285.   hadd %s time $ctime
  286.   hadd %s extra $+($left($1-,80),[...])
  287.   hadd %s chan $chan
  288.   hadd %s net $network
  289.   var %x = $seenicks(%s)
  290.   var %i = $istok(%x,%n,32)
  291.   hadd %s nicks $iif(%i, $+(%n,$chr(32),$remtok(%x,%n,1,32)), $+(%n,$chr(32),%x))
  292.   var %k = $hget(%s,knick)
  293.   if (%k) { hdel %s knick }
  294.   hsave %s $+($seendir(%s),.hsh)
  295. }
  296.  
  297. ON *:JOIN:#: {
  298.   var %site = $replace($site,/,humslashhost,:,humtwodots)
  299.   addhost %site
  300.   var %n = $nick
  301.   var %s = $seenh(%site)
  302.   if (!$hget(%s)) {
  303.     hmake %s 100
  304.   }
  305.   if ($hget(%s,tonick)) {
  306.     hdel %s tonick
  307.   }
  308.   hadd %s event $event
  309.   hadd %s time $ctime
  310.   hdel %s extra
  311.   hadd %s chan $chan
  312.   hadd %s net $network
  313.   var %x = $seenicks(%s)
  314.   var %i = $istok(%x,%n,32)
  315.   hadd %s nicks $iif(%i, $+(%n,$chr(32),$remtok(%x,%n,1,32)), $+(%n,$chr(32),%x))
  316.   var %k = $hget(%s,knick)
  317.   if (%k) { hdel %s knick }
  318.   hsave %s $+($seendir(%s),.hsh)
  319. }
  320.  
  321. ON *:PART:#: {
  322.   var %site = $replace($site,/,humslashhost,:,humtwodots)
  323.   addhost %site
  324.   var %n = $nick
  325.   var %s = $seenh(%site)
  326.   if (!$hget(%s)) {
  327.     hmake %s 100
  328.   }
  329.   hadd %s event $event
  330.   hadd %s time $ctime
  331.   hadd %s extra $+($left($1-,80),[...])
  332.   hadd %s chan $chan
  333.   hadd %s net $network
  334.   if ($hget(%s,tonick)) {
  335.     hdel %s tonick
  336.   }
  337.   var %x = $seenicks(%s)
  338.   var %i = $istok(%x,%n,32)
  339.   hadd %s nicks $iif(%i, $+(%n,$chr(32),$remtok(%x,%n,1,32)), $+(%n,$chr(32),%x))
  340.   var %k = $hget(%s,knick)
  341.   if (%k) { hdel %s knick }
  342.   hsave %s $+($seendir(%s),.hsh)
  343. }
  344.  
  345. ON *:QUIT: {
  346.   var %site = $replace($site,/,humslashhost,:,humtwodots)
  347.   addhost %site
  348.   var %n = $nick
  349.   var %s = $seenh(%site)
  350.   if (!$hget(%s)) {
  351.     hmake %s 100
  352.   }
  353.   hadd %s event $event
  354.   hadd %s time $ctime
  355.   hadd %s extra $+($left($1-,80),[...])
  356.   hdel %s chan $chan
  357.   hadd %s net $network
  358.   if ($hget(%s,tonick)) {
  359.     hdel %s tonick
  360.   }
  361.   var %x = $seenicks(%s)
  362.   var %i = $istok(%x,%n,32)
  363.   hadd %s nicks $iif(%i, $+(%n,$chr(32),$remtok(%x,%n,1,32)), $+(%n,$chr(32),%x))
  364.   var %k = $hget(%s,knick)
  365.   if (%k) { hdel %s knick }
  366.   hsave %s $+($seendir(%s),.hsh)
  367. }
  368.  
  369. ON *:KICK:#: {
  370.   var %a = $remove($replace($address($nick,2),/,humslashhost,:,humtwodots),*!*@)
  371.   var %a2 = $remove($replace($address($knick,2),/,humslashhost,:,humtwodots),*!*@)
  372.   addhost %a
  373.   addhost %a2
  374.   var %n = $nick
  375.   var %n2 = $knick
  376.   var %s = $seenh(%a)
  377.   var %s2 = $seenh(%a2)
  378.   if (!$hget(%s)) {
  379.     hmake %s 100
  380.   }
  381.   if (!$hget(%s2)) {
  382.     hmake %s2 100
  383.   }
  384.   if ($hget(%s,tonick)) {
  385.     hdel %s tonick
  386.   }
  387.   if ($hget(%s2,tonick)) {
  388.     hdel %s2 tonick
  389.   }
  390.   hadd %s event kicker
  391.   hadd %s k2 $knick
  392.   hadd %s2 event kicked
  393.   hadd %s2 k2 $nick
  394.   hadd %s time $ctime
  395.   hadd %s2 time $ctime
  396.   hadd %s extra $+($left($1-,80),[...])
  397.   hadd %s2 extra $+($left($1-,80),[...])
  398.   hadd %s chan $chan
  399.   hadd %s2 chan $chan
  400.   hadd %s net $network
  401.   hadd %s2 net $network
  402.   var %x = $seenicks(%s)
  403.   var %x2 = $seenicks(%s2)
  404.   var %i = $istok(%x,%n,32)
  405.   var %i2 = $istok(%x2,%n2,32)
  406.   hadd %s nicks $iif(%i, $+(%n,$chr(32),$remtok(%x,%n,1,32)), $+(%n,$chr(32),%x))
  407.   hadd %s2 nicks $iif(%i2, $+(%n2,$chr(32),$remtok(%x2,%n2,1,32)), $+(%n2,$chr(32),%x2))
  408.   hsave %s $+($seendir(%s),.hsh)
  409.   hsave %s2 $+($seendir(%s2),.hsh)
  410. }
  411.  
  412. ON *:NICK: {
  413.   var %site = $replace($site,/,humslashhost,:,humtwodots)
  414.   addhost %site
  415.   var %n = $newnick
  416.   var %s = $seenh(%site)
  417.   if (!$hget(%s)) {
  418.     hmake %s 100
  419.   }
  420.   hadd %s event $event
  421.   hadd %s time $ctime
  422.   hdel %s extra
  423.   hdel %s chan
  424.   hadd %s net $network
  425.   hadd %s tonick %n
  426.   var %x = $seenicks(%s)
  427.   var %i = $istok(%x,%n,32)
  428.   hadd %s nicks $iif(%i, $+(%n,$chr(32),$remtok(%x,%n,1,32)), $+(%n,$chr(32),%x))
  429.   var %k = $hget(%s,knick)
  430.   if (%k) { hdel %s knick }
  431.   hsave %s $+($seendir(%s),.hsh)
  432. }
  433.  
  434. alias ducktop {
  435.   var %p = $1
  436.   var %max = 0
  437.   var %x = 1
  438.   var %y = $hget(%p,0).item
  439.   while (%x <= %y) {
  440.     var %z = $gettok($hget(%p,%x).data,1,32)
  441.     var %a = $hget(%p,%x).item
  442.     if (%z > %max) {
  443.       var %max = %z
  444.       var %maxi = %a
  445.     }
  446.     inc %x
  447.   }
  448.   return %maxi %max
  449. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement