Skip to content

[mIRC] Request: Ban an IP file

A quick and short script written to zline IPs in a specified file. The IPs must be listed in the file as one IP per line, e.g.:

Follow the instructions to use.

; To use:
;1) Type /ipban.reset
;2) Ensure you specify the right file/directory in set %ipban.ipfile "nodes.csv"
;3) Type /ipban
;4) Wait until script completes, can take a while depending on size of file.

alias -l ipban_next {
  if (%ipban.pos <= {
    zline $+(*@,$read(%ipban.ipfile,%ipban.pos)) 1d Tor Exit Servers are not permitted on this network
    inc %ipban.pos
  else {
    echo -atc info *** Zlined IPs from %ipban.ipfile
    .unset %ipban.*
alias ipban {
  set %ipban.ipfile "nodes.csv"
  if ($isfile(%ipban.ipfile) == $false) { echo -atc info *** IP Ban Error: %ipban.ipfile does not exist | return }
  set $lines(%ipban.ipfile)
  if (%ipban.pos == $null) { set %ipban.pos 1 }
  .timer -m 1 5 ipban_next
alias ipban.reset .unset %ipban.*

Let me bring to attention my use of timers over a while loop for budding scripters.

The reason is for large IP files, a while loop will freeze your script. For this reason a timer was used with a 5 millisecond delay, ensuring fast zlines but without freezing the script.

I will edit this script to auto carry out /ipban.reset upon execution, but, as of now, this isn’t required as it does its job (plus I’m short on time again!!!).

Note: to edit the zline time and message:

zline $+(*@,$read(%ipban.ipfile,%ipban.pos)) 1d Tor Exit Servers are not permitted on this network

“1d” to something you want
“Tor Exit Servers are not permitted on this network” to something you want

No comments yet

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.