Skip to content

Instantly share code, notes, and snippets.

@westor7
Created May 2, 2023 15:29
Show Gist options
  • Save westor7/b9fd0a645f11f049accae03da39bbafb to your computer and use it in GitHub Desktop.
Save westor7/b9fd0a645f11f049accae03da39bbafb to your computer and use it in GitHub Desktop.
Country Scan On Join for HelpMe
; ---- Settings ----
alias -l channel { return #test_channel } ; Channels to work (add more using comma)
alias -l ban_delay { return 3600 } ; Seconds for ban on /ban
alias -l ban_mask { return 2 } ; Ban mask (/help $mask)
alias -l ip_exception { return 1.55.219.132 1.55.219.133 } ; Enter here ip exceptions from scan (space separated)
alias -l country_exception { return GR } ; Enter here countries to not perform a ban-kick (space separated)
; ---- Settings ----
ON @!*:JOIN:$($channel): {
var %host = $ial($nick).host
if ($istok($ip_exception,%host,32)) { return }
country_check $nick $chan %host
}
alias -l country_check {
; /country_check <nick> <#chan> <IP>
if ($0 !== 3) || ($me !ison $2) || ($1 !ison $2) { return }
if ($iptype($3) !== ipv4) && ($iptype($3) !== ipv6) { return }
var %v = COUNTRY_SCAN_ $+ $ticksqpc $+ _ $+ $remove($nopath($tempfn),mirc,adiirc,.tm_)
var %u = http://ip-api.com/json/ $+ $3
jsonopen -ud %v %u
if ($jsonerror) { echo 4 -st * /country_check: Error, Could not connect on server! - Error Details: $jsonerror | return }
var %c = $json(%v,countryCode).value
if (!%c) { echo 4 -st * /country_check: Error, Could not parse the server data! - Error Details: %u | return }
if ($istok($country_exception,%c,32)) { return }
ban $+(-ku,$ban_delay) $2 $1 $ban_mask [Banned]: Your country ( $+ %c $+ ) is NOT allowed to join on this channel! - Bantime: $duration($ban_delay)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment