Advertisement
westor

Country Ban via JSON for DeMoN v3.0

Aug 17th, 2018
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 3.87 KB | None | 0 0
  1. ON *:TEXT:*:#opers: {
  2.   if ($1 == !c) {
  3.     var %opts = add del clear list total start stop on off
  4.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please use an option of $qt(%opts) $+ . | return }
  5.     if (!$istok(%opts,$2,32)) { .msg $chan ( $+ $nick $+ ):  Error, Please use on of the correct options $qt(%opts) $+ . | return }
  6.     if ($2 == start) || ($2 == on) {
  7.       if (%bancountry) { .msg $chan ( $+ $nick $+ ): The Ban Country module is already running! | return }
  8.       set %bancountry 1
  9.       .msg $chan ( $+ $nick $+ ): The Ban Country module has been started.
  10.     }
  11.     if ($2 == stop) || ($2 == off) {
  12.       if (!%bancountry) { .msg $chan ( $+ $nick $+ ): The Ban Country module is NOT running! | return }
  13.       set %bancountry 0
  14.       .msg $chan ( $+ $nick $+ ): The Ban Country module has been stopped.
  15.     }
  16.     if ($2 == add) {
  17.       if (!$3) { .msg $chan ( $+ $nick $+ ): Error, Please use the country code! | return }
  18.       if ($ulist($3,country,1)) { .msg $chan ( $+ $nick $+ ):  Error, That $qt($3) country code is already exists in the list! | return }
  19.       .auser country $3
  20.       .msg $chan ( $+ $nick $+ ): The $qt($3) country code has been added to the list.
  21.     }
  22.     if ($2 == del) {
  23.       if (!$3) { .msg $chan ( $+ $nick $+ ): Error, Please use the country code! | return }
  24.       if (!$ulist($3,country,1)) { .msg $chan ( $+ $nick $+ ):  Error, That $qt($3) country code does NOT exists in the list! | return }
  25.       .ruser country $3
  26.       .msg $chan ( $+ $nick $+ ): The $qt($3) country code has been removed from the list.
  27.     }
  28.     if ($2 == list) {
  29.       var %t = $ulist(*,country,0)
  30.       if (!%t) { .msg $chan ( $+ $nick $+ ): The country code list is empty. | return }
  31.       var %i = 1
  32.       while (%i <= %t) { .msg $chan ( $+ $nick $+ ): $chr(35) $+ %i -> $ulist(*,country,%i) | inc %i }
  33.     }
  34.     if ($2 == clear) {
  35.       var %t = $ulist(*,country,0)
  36.       if (!%t) { .msg $chan ( $+ $nick $+ ): The country code list is empty. | return }
  37.       while (%t) { .ruser country $ulist(*,country,%t) | dec %t }
  38.       .msg $chan ( $+ $nick $+ ): All the country codes have been cleared.
  39.     }
  40.     if ($2 == total) {
  41.       var %t = $ulist(*,country,0)
  42.       if (!%t) { .msg $chan ( $+ $nick $+ ): The country code list is empty. }
  43.       else { .msg $chan ( $+ $nick $+ ): There are %t country codes in the list. }
  44.     }
  45.   }
  46. }
  47.  
  48. ON *:SNOTICE:*Client Connecting*: {
  49.   if (!%bancountry) { return }
  50.   if (*on port* iswm $1-) { set -eu60 %connecting_ [ $+ [ $9 ] ] $server $+ : $+ $remove($8,:) $10 | userip $9 }
  51.   else { set -eu60 %connecting_ [ $+ [ $8 ] ] $remove($7,:) $9 | userip $8 }
  52. }
  53.  
  54. raw 340:*: {
  55.   haltdef
  56.   if (%connecting_ [ $+ [ $gettok($2-,1,61) ] ]) {
  57.     var %nick = $gettok($2-,1,61)
  58.     var %ip = $gettok($2-,2,64)
  59.     var %server = $gettok(%connecting_ [ $+ [ %nick ] ],1,32)
  60.     var %addr = $gettok(%connecting_ [ $+ [ %nick ] ],2,32)
  61.     var %v = lookup_ $+ $rand(1,10000000000000)
  62.     var %u = https://geoip.nekudo.com/api/ $+ %ip $+ /en/short
  63.     JSONOpen -u %v %u
  64.     if ($JSONError) { JSONClose %v | return }
  65.     var %name = $json(%v,country,name).value
  66.     var %country = $json(%v,country,code).value
  67.     JSONClose %v
  68.     if (%name) && (%country) { send_msg $iif(%nick,$v1,N/A) $iif(%addr,$v1,N/A) $iif(%ip,$v1,N/A) $iif(%server,$v1,N/A) $iif(%country,$v1,N/A) $iif(%name,$v1,N/A) }
  69.   }
  70. }
  71.  
  72. alias -l send_msg {
  73.   if (!$1-) { return }
  74.   if ($ulist($5,country,1)) {
  75.     gline *@ $+ $3 2h 10[ 4G-Lined 10]: 5Your country ( $+ $5 $+ ) is NOT permitted on that network.
  76.     if ($me ison #opers) { .msg #opers 10-- Client 4BANNED 10due connecting at7 $4 $+ :4 $1 $+ 5 $2 10(4 $+ $3 $+ 10) 10from4 $6 ( $+ $5 $+ ) }
  77.   }
  78.   else {
  79.     if ($me ison #opers) { .msg #opers 10-- Client connecting at7 $4 $+ :4 $1 $+ 5 $2 10(4 $+ $3 $+ 10) 10from4 $6 ( $+ $5 $+ ) }
  80.   }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement