westor

Bad Channels Protection for Kendy v4.2

Nov 29th, 2020 (edited)
1,199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 3.51 KB | None | 0 0
  1. ; ----------- Settings --------------
  2.  
  3. alias -l chans { return # } ; The channel(s) that code to work
  4. alias -l bad_file { return badchans.txt } ; The bad channels location file
  5. alias -l ban_kick { return 1 } ; 1 = kick him yes, 0 = no kick just ban
  6. alias -l ban_time { return 300 } ; 0 = permanent, (use seconds only)
  7. alias -l ban_type { return 2 } ; use /help $mask for ban type
  8. alias -l auto_recheck_secs { return 0 } ; seconds for automatically rescan (whois) all nicknames, use 0 to disable it
  9.  
  10. ; ----------- Settings --------------
  11.  
  12. ON *:JOIN:$($chans): {
  13.   if ($nick == $me) {
  14.     if ($auto_recheck_secs) { .timer[CHECK_ $+ $chan $+ _BADCHANS] 0 $auto_recheck_secs recheck_all_badchans $chan }
  15.  
  16.     return
  17.   }
  18.  
  19.   if ($me isreg $chan) { return }
  20.  
  21.   recheck_badchan $nick
  22. }
  23.  
  24. ON *:PART:$($chans): { if ($nick == $me) { .timer[CHECK_ $+ $chan $+ _BADCHANS] off } }
  25. ON *:KICK:$($chans): { if ($knick == $me) { .timer[CHECK_ $+ $chan $+ _BADCHANS] off } }
  26.  
  27. RAW *:*: {
  28.   if (!$hget(BCS,0).item) || ($status !== connected) { return }
  29.  
  30.   haltdef
  31.  
  32.   var %h = $hget(BCS,$2)
  33.  
  34.   if ($numeric == 318) && (%h) { hdel BCS $2 }
  35.  
  36.   if ($numeric == 319) && (%h) {
  37.     var %r = $check_badchans($3-)
  38.     var %t = $comchan($2,0)
  39.  
  40.     if (!%r) || (!%t) { return }
  41.  
  42.     var %i = 1
  43.     while (%i <= %t) {
  44.       var %c = $comchan($2,%i)
  45.  
  46.       if ($me ison %c) && ($me isop %c) && ($2 ison %c) {
  47.         inc %knum 1
  48.  
  49.         var %f = -
  50.  
  51.         if ($ban_kick) { var %f = %f $+ k }
  52.         if ($ban_time) { var %f = %f $+ u $+ $ban_time }
  53.  
  54.         ban %f %c $2 $ban_type 4[Banned] (reason: You have been found in ( $+ $numtok(%r,32) $+ ) blacklisted channels ( $+ %r $+ ) -- for more infomation reagarding your ban please contact Kendy for removal -52- [Kick id: $chr(35) $+ %knum $+ ] (Expires in: $duration($ban_time) $+ )
  55.       }
  56.  
  57.       inc %i
  58.     }
  59.  
  60.   }
  61. }
  62.  
  63. alias recheck_all_badchans {
  64.   ; /recheck_all_badchans <#channel>
  65.  
  66.   if (!$1) || ($me !ison $1) || ($me !isop $1) || ($status !== connected) { return }
  67.  
  68.   var %t = $nick($1,0,r)
  69.  
  70.   if (!%t) { return }
  71.  
  72.   var %i = 1
  73.   while (%i <= %t) {
  74.     var %n = $nick($1,%i,r)
  75.  
  76.     if (%n) { .timer[SCAN_ $+ %n $+ _BADCHANS] 1 $calc(%i * 5) recheck_badchan %n }
  77.  
  78.     inc %i
  79.   }
  80. }
  81.  
  82. alias recheck_badchan {
  83.   ; /recheck_badchan <nickname>
  84.  
  85.   if (!$1) || ($status !== connected) { return }
  86.  
  87.   hadd -mu10 BCS $1 1
  88.  
  89.   whois $1
  90. }
  91.  
  92. alias -l check_badchans {
  93.   ; $check_badchans(#channel1 #channel2 ...)
  94.  
  95.   if (!$1) || (!$file($bad_file)) { return }
  96.  
  97.   var %chans = $fix_badchans($1-)
  98.   var %win = $+(@BD_,$crc($1-,0))
  99.  
  100.   if ($window(%win)) { window -c $v1 }
  101.  
  102.   window -hj10000000000000 %win
  103.   loadbuf %win $qt($bad_file)
  104.  
  105.   var %t = $line(%win,0)
  106.   var %i = 1
  107.  
  108.   while (%i <= %t) {
  109.     var %r = $line(%win,%i)
  110.  
  111.     if (!%r) { goto next }
  112.  
  113.     if ($istok(%chans,%r,32)) { var %tot = $addtok(%tot,%r,32) | goto next }
  114.  
  115.     var %z = 1
  116.     while (%z <= $numtok(%chans,32)) {
  117.       var %n = $gettok(%chans,%z,32)
  118.  
  119.       if (%n) && (%r iswm %n) { var %tot = $addtok(%tot,%n,32) }
  120.  
  121.       inc %z
  122.     }
  123.  
  124.     :next
  125.     inc %i
  126.   }
  127.  
  128.   window -c %win
  129.  
  130.   return $iif(%tot,$v1,0)
  131. }
  132.  
  133. alias -l fix_badchans {
  134.   ; $fix_badchans(@#channel1 ~#channel2 ...)
  135.  
  136.   if (!$1) { return 0 }
  137.  
  138.   var %t = $numtok($1-,32)
  139.   var %i = 1
  140.  
  141.   while (%i <= %t) {
  142.     var %o = $gettok($1-,%i,32)
  143.  
  144.     if (%o) { var %c = $+($chr(35),$right(%o,- $+ $pos(%o,$chr(35),1))) }
  145.     if (%c) { var %tot = $addtok(%tot,%c,32) }
  146.  
  147.     inc %i
  148.   }
  149.  
  150.   return $iif(%tot,$v1,0)
  151. }
  152.  
Add Comment
Please, Sign In to add comment