Advertisement
SaNCaK

mIRC Text Flood Pro

Feb 1st, 2014
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 11.82 KB | None | 0 0
  1. alias flood.kick { flood_punish kick $active }
  2. alias flood.ban { flood_punish ban $active }
  3. alias flood.mod { flood_punish +m $active }
  4.  
  5. on *:TEXT:*:#: flood_
  6. on *:ACTION:*:#: flood_
  7. on *:NOTICE:*:#: flood_
  8.  
  9. /*
  10. ; A good way to protect users is to use these events instead of the above and add users to your userlist (/guser 2 nick 3)
  11. on +1:TEXT:*:#: flood_
  12. on +1:ACTION:*:#: flood_
  13. on +1:NOTICE:*:#: flood_
  14. */
  15.  
  16. alias -l flood_punish {
  17.   ; Check if we're using the 'Moderate channel' punishment
  18.   if (!$istok(ban kick,$1,32)) {
  19.     if (($me isop $2) || ($me ishop $2)) {
  20.       mode $chan $1-
  21.     }
  22.   }
  23.   else {
  24.     var %q = $($+(%,flood_punish.,$cid,.,$2),2)
  25.     if (%q) {
  26.       ; Check if you're opped/hopped on the channel
  27.       if (($me isop $2) || ($me ishop $2)) {
  28.         var %wildsite = $gettok(%q,2,32)
  29.         ; Ban the *!*@host
  30.         mode $2 +b $gettok(%q,2,32)
  31.         ; Set timer to unban if enabled
  32.         if (%flood_ban) { .timer 1 %flood_ban if (($me isop $2 $+ ) || ($me ishop $2 $+ )) && ($me ison $2 $+ ) mode $2 -b %wildsite }
  33.         ; If this is the ban punishment, stop here
  34.         if ($1 == ban) { return }
  35.  
  36.         ; Set variables and kick the nickname who triggered the protection
  37.         var %nick = $gettok(%q,1,32), %lines = $gettok(%q,3,32), %secs = $gettok(%q,4,32)
  38.         if ((%nick isreg $2) || (%nick isvoice $2)) && (%nick ison $2) {
  39.           kick $2 %nick $(%flood_kick,2)
  40.         }
  41.  
  42.         ; Loop through $ialchan and kick clones of user who triggered
  43.         var %x = $ialchan(%wildsite,$2,0)
  44.         while (%x) {
  45.           var %nick = $ialchan(%wildsite,$2,%x).nick
  46.           if (%nick isreg $2) || (%nick isvoice $2) {
  47.             kick $2 %nick $(%flood_kick,2)
  48.           }
  49.           dec %x
  50.         }
  51.       }
  52.     }
  53.   }
  54. }
  55.  
  56. alias -l flood_ {
  57.   ; Check if protection is enabled
  58.   if (%flood_protection) && (!$($+(%,flood_triggered.,$cid,.,$site),2)) {
  59.     ; Check if we need to be opped/hopped to use it
  60.     if (%flood_opt & 1) && (($me isop $chan) || ($me ishop $chan)) || (%flood_opt !& 1) {
  61.       ; Check if target user is opped/hopped
  62.       if (%flood_opt & 2) && (($nick isreg $chan) || ($nick isvoice $chan)) || (%flood_opt !& 2) {
  63.  
  64.         var %q = $+($chan,.,$cid,.,$site)
  65.         var %f = $hget(flood_,%q)
  66.  
  67.         ; Reset records according to options
  68.         if ($calc($ticks - $gettok(%f,1,32)) > $calc($gettok(%flood_reset,2,32) * 1000)) { unset %f }
  69.         if ($gettok(%f,2,32) >= $gettok(%flood_reset,1,32)) { unset %f }
  70.  
  71.         ; Increment line count
  72.         if (!$len(%f)) { var %f = $ticks 0 }
  73.         hadd -m flood_ %q $gettok(%f,1,32) $calc($gettok(%f,2,32) + 1)
  74.         var %f = $hget(flood_,%q)
  75.  
  76.         ; Loop through triggers and see if any have been exceeded
  77.         var %secs = $calc(($ticks - $gettok(%f,1,32)) / 1000)
  78.         var %lines = $gettok(%f,2,32)
  79.         var %x = $numtok(%flood_trigger,32)
  80.         while (%x) && (%lines) && (%secs) {
  81.           var %f = $gettok(%flood_trigger,%x,32)
  82.           var %l = $gettok(%f,1,58)
  83.           var %s = $gettok(%f,2,58)
  84.           if (%lines >= %l) && (%secs <= %s) {
  85.             ; If a trigger has been exceeded, display this message
  86.             echo $color(highlight) -t $chan * Channel Flood from $nick ( $+ $site $+ ): %lines lines in %secs seconds.
  87.             if (%flood_reaction == 3) {
  88.               var %kick_key = $replace($upper($gettok(%flood_fkeys,1,32)),s,Shift+,c,Ctrl+)
  89.               var %ban_key = $replace($upper($gettok(%flood_fkeys,2,32)),s,Shift+,c,Ctrl+)
  90.               echo $color(highlight) -t $chan * $iif(%kick_key != _,Press $+(,%kick_key,),Type /flood.kick) to kick/ban or $iif(%ban_key != _,$+(,%ban_key,),/flood.ban) to ban
  91.             }
  92.             elseif (%flood_reaction == 2) {
  93.               echo $color(highlight) -t $chan * Punishing by kick/ban
  94.               flood_punish kick $chan
  95.             }
  96.             elseif (%flood_reaction == 1) {
  97.               echo $color(highlight) -t $chan * Punishing by ban
  98.               flood_punish ban $chan
  99.             }
  100.             if (%flood_opt & 4) {
  101.               if (%flood_opt & 8) {
  102.                 ; Highlight the switchbar button
  103.                 window -g2 $chan
  104.               }
  105.               if (%flood_opt & 16) && (%flood_switchbar) {
  106.                 ; Flash taskbar button
  107.                 flash $(%flood_switchbar,2)
  108.               }
  109.               if (%flood_opt & 32) && (($active != $chan) || ($activecid != $cid)) {
  110.                 ; Display message in active window
  111.                 echo $colour(highlight) -ta * Flood protection triggered in $chan on $network 
  112.               }
  113.             }
  114.             ; Record user who triggered protection
  115.             set $+(%,flood_punish.,$cid,.,$chan) $nick $wildsite %lines %secs
  116.             set -u60 $+(%,flood_triggered.,$cid,.,$site) 1
  117.             break
  118.           }
  119.           dec %x
  120.         }
  121.       }
  122.     }
  123.   }
  124. }
  125. on *:EXIT: {
  126.   ; Cleanup temp variables
  127.   unset %flood_triggered.*
  128.   unset %flood_punish.*
  129. }
  130.  
  131.  
  132. on *:LOAD: {
  133.   echo -a _____________________________________________________
  134.   echo -a 4,1[15,1 SaNCaK 4,1] 0,1 Loading Add-On... 
  135.   echo -a 4,1[15,1 SaNCaK 4,1] 0,1 You are running mIRC $version on $os  $+ .
  136.   echo -a 4,1[15,1 SaNCaK 4,1] 0,1 Coder: 15SaNCaK 0,1 E-Mail: 15SaNCaK@SaNCaK.gen.tr 
  137.   echo -a 4,1[15,1 SaNCaK 4,1] 0,1 Copyright © 200915 http://www.sancak.gen.tr
  138.   echo -a ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  139.   unset %flood_triggered.* %flood_punish.* %flood_trigger %flood_protection %flood_opt %flood_reset $&
  140.     %flood_switchbar %flood_kick %flood_ban %flood_reaction
  141.  
  142.   set %flood_opt 29
  143.   set %flood_kick Text Flood: $+(%,lines) lines in $+(%,secs) seconds.
  144.   set %flood_switchbar Flood in $!chan on $!network
  145.   set %flood_trigger 5:5.5 7:9 8:10 12:15 17:27
  146.   set %flood_reset 18 28
  147.   set %flood_reaction 3
  148.   set %flood_fkeys _ _ _
  149. }
  150. on *:START: {
  151.   ; Cleanup temp variables
  152.   unset %flood_triggered.*
  153.   unset %flood_punish.*
  154. }
  155. on *:UNLOAD: {
  156.   ; Unset all variables
  157.   unset %flood_triggered.* %flood_punish.* %flood_trigger %flood_protection %flood_opt %flood_reset $&
  158.     %flood_switchbar %flood_kick %flood_ban %flood_reaction %flood_fkeys
  159.  
  160. }
  161.  
  162. menu channel,menubar {
  163.   Text Flood Pro
  164.   .$iif(%flood_protection,$style(1)) Use Flood Protection:set %flood_protection $iif(%flood_protection,0,1)
  165.   .$iif(%flood_opt & 1,$style(1)) Use only when opped/hopped:set %flood_opt $iif(%flood_opt & 1,$calc(%flood_opt - 1),$calc(%flood_opt + 1))
  166.   .$iif(%flood_opt & 2,$style(1)) Do not use for other ops/hops:set %flood_opt $iif(%flood_opt & 2,$calc(%flood_opt - 2),$calc(%flood_opt + 2))
  167.   .Change Kick Message: {
  168.     var %k = $input(Enter kick message. Use $+(%,nick) $+ $chr(44) $+(%,lines) and $+(%,secs) variables.,e,Input Request,%flood_kick)
  169.     if (%k) {
  170.       set %flood_kick %k
  171.     }
  172.     else {
  173.       set %flood_kick Text Flood: $+(%,lines) lines in $+(%,secs) seconds.
  174.     }
  175.   }
  176.   .Set Ban Time [[ $+ $iif(%flood_ban,$+($v1,s),Disabled) $+ ]:set %flood_ban $input(Enter ban time in seconds (0 to disable):,e)
  177.   .-
  178.  
  179.   .Alert
  180.   ..$iif(%flood_opt & 4,$style(1)) Alert me when protection is triggered:set %flood_opt $iif(%flood_opt & 4,$calc(%flood_opt - 4),$calc(%flood_opt + 4))
  181.   ..-
  182.   ..$iif(%flood_opt & 8,$style(1)) Highlight the window button:set %flood_opt $iif(%flood_opt & 8,$calc(%flood_opt - 8),$calc(%flood_opt + 8))
  183.   ..$iif(%flood_opt & 16,$style(1)) Flash the mIRC taskbar button: {
  184.     if ($mouse.key !& 4) { set %flood_opt $iif(%flood_opt & 16,$calc(%flood_opt - 16),$calc(%flood_opt + 16)) }
  185.     if (%flood_opt & 16) || ($mouse.key & 4) {
  186.       set %flood_switchbar $iif($input(Enter message to flash. Use $!nick $+ $chr(44) $!network and $!chan identifiers.,e,Input Request,%flood_switchbar),$v1,Flood in $!chan on $!network)
  187.     }
  188.   }
  189.   ..$iif(%flood_opt & 32,$style(1)) Dispay message in active window:set %flood_opt $iif(%flood_opt & 32,$calc(%flood_opt - 32),$calc(%flood_opt + 32))
  190.  
  191.   .Reaction
  192.   ..$iif(%flood_reaction == 1,$style(1)) Ban host: { set %flood_reaction 1 }
  193.   ..$iif(%flood_reaction == 2,$style(1)) Kick/Ban user and clones: { set %flood_reaction 2 }
  194.   ..$iif(%flood_reaction == 3,$style(1)) Let me choose: { set %flood_reaction 3 }
  195.  
  196.   .Triggers
  197.   ..Add Trigger:flood_add_trigger
  198.   ..-
  199.   ..$submenu($flood_trigger($1))
  200.   .Fkeys
  201.   ..Punish with kick/ban
  202.   ...$submenu($fkeys(kick,$1))
  203.   ..Punish with ban
  204.   ...$submenu($fkeys(ban,$1))
  205.   ..Moderate channel
  206.   ...$submenu($fkeys(mod,$1))
  207.   .-
  208.   .Set Defaults:{
  209.     if ($input(Reset all flood protection options to defaults?,yv) == $yes) {
  210.       unset %flood_*
  211.       set %flood_opt 29
  212.       set %flood_kick Text Flood: $+(%,lines) lines in $+(%,secs) seconds.
  213.       set %flood_switchbar Flood in $!chan on $!network
  214.       set %flood_trigger 5:5.5 7:9 8:10 12:15 17:27
  215.       set %flood_reset 18 28
  216.       set %flood_reaction 3
  217.       set %flood_fkeys _ _ _
  218.     }
  219.   }
  220. }
  221. ; Display fkeys in a submenu
  222. alias -l fkeys {
  223.   if ($2 == begin) { set %flood_fkeys_temp 0 }
  224.   if ($2 == end) { unset %flood_fkeys_temp }
  225.   if ($2 isnum) {
  226.     tokenize 32 $1 %flood_fkeys_temp
  227.     var %div = $int($calc($2 / 12))
  228.     var %mod = $calc(($2 % 12) + 1)
  229.     if (%div >= 3) { return }
  230.     var %alias = $+($replace(%div,0,$null,1,s,2,c),f,%mod)
  231.     var %cmd = $isalias(%alias).alias
  232.     if ($gettok(%cmd,1,32) != $+(flood.,$1)) && ($len(%cmd)) { var %return = $style(2) }
  233.     if ($gettok(%cmd,1,32) == $+(flood.,$1)) { var %return = $style(1) }
  234.     inc %flood_fkeys_temp
  235.     return %return $+($replace(%div,0,$null,1,Shift+,2,Ctrl+),F,%mod) $+ :flood_fkeys_set %alias $1
  236.   }
  237. }
  238. alias -l flood_fkeys_set {
  239.   var %x = $replace($2,kick,1,ban,2,mod,3)
  240.   var %old_alias = $gettok(%flood_fkeys,%x,32)
  241.   ; Remove old alias
  242.   if ($isalias(%old_alias).alias == $+(flood.,$2)) {
  243.     .alias %old_alias
  244.   }
  245.   if (%old_alias != $1) {
  246.     ; Add new alias
  247.     .alias $1 $+(flood.,$2)
  248.     set %flood_fkeys $puttok(%flood_fkeys,$1,%x,32)
  249.   }
  250.   else {
  251.     set %flood_fkeys $puttok(%flood_fkeys,_,%x,32)
  252.   }
  253. }
  254. alias -l flood_trigger {
  255.   ; Display triggers in submenu
  256.   if ($1 <= $numtok(%flood_trigger,32)) {
  257.     var %q = $gettok(%flood_trigger,$1,32)
  258.     return $gettok(%q,1,58) lines in $gettok(%q,2,58) seconds:flood_set_trigger $1
  259.   }
  260.   if (!$numtok(%flood_trigger,32)) && ($1 = 1) {
  261.     return $style(2) No triggers defined:/
  262.   }
  263. }
  264. alias -l flood_add_trigger {
  265.   ; Add a trigger
  266.   var %lines = $input(Enter number of lines:,e)
  267.   var %seconds = $input(Enter number of seconds:,e)
  268.   if (%lines isnum) && (%seconds isnum) {
  269.     %flood_trigger = %flood_trigger $+(%lines,:,%seconds)
  270.  
  271.   }
  272.   flood_update_reset
  273. }
  274. alias -l flood_set_trigger {
  275.   ; Change or delete a trigger
  276.   var %q = $gettok(%flood_trigger,$1,32)
  277.   var %d = $input(Do you want to delete this entry or update it? $crlf $+ Click YES to DELETE it. $crlf $+ Click NO to UPDATE it.,nv)
  278.   if (%d == $cancel) { return }
  279.   elseif (%d == $yes) {
  280.     %flood_trigger = $iif($deltok(%flood_trigger,$1,32),$v1,"")
  281.  
  282.   }
  283.   elseif (%d == $no) {
  284.     var %lines = $input(Enter number of lines:,e,Input Request,$gettok(%q,1,58))
  285.     var %seconds = $input(Enter number of seconds:,e,Input Request,$gettok(%q,2,58))
  286.     if (%lines isnum) && (%seconds isnum) {
  287.       %flood_trigger = $puttok(%flood_trigger,$+(%lines,:,%seconds),$1,32)
  288.  
  289.     }
  290.   }
  291.   flood_update_reset
  292. }
  293. alias -l flood_update_reset {
  294.   ; This dynamically updates the flood reset parameters
  295.   var %x = $numtok(%flood_trigger,32)
  296.   while (%x) {
  297.     var %f = $gettok(%flood_trigger,%x,32)
  298.     var %lines = $gettok(%f,1,58) %lines
  299.     var %secs = $gettok(%f,2,58) %secs
  300.     dec %x
  301.   }
  302.   var %highlines = $gettok($sorttok(%lines,32,nr),1,32)
  303.   var %highsecs = $gettok($sorttok(%secs,32,nr),1,32)
  304.   set %flood_reset $calc(%highlines + 1) $calc(%highsecs + 1)
  305. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement