Advertisement
westor

Allow Country & Ident via JSON for DeMoN v3.0

Aug 24th, 2018
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 10.25 KB | None | 0 0
  1. ON *:TEXT:*:#opers: {
  2.   tokenize 32 $strip($1-)
  3.  
  4.   if ($1 == !i) {
  5.     var %opts = add del clear list total start stop on off
  6.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please use an option of $qt(%opts) $+ . | return }
  7.     if (!$istok(%opts,$2,32)) { .msg $chan ( $+ $nick $+ ):  Error, Please use on of the correct options $qt(%opts) $+ . | return }
  8.     if ($2 == start) || ($2 == on) {
  9.       if (%banident) { .msg $chan ( $+ $nick $+ ): The Ban Ident module is already running! | return }
  10.       set %banident 1
  11.       .msg $chan ( $+ $nick $+ ): The Ban Ident module has been started.
  12.     }
  13.     if ($2 == stop) || ($2 == off) {
  14.       if (!%banident) { .msg $chan ( $+ $nick $+ ): The Ban Ident module is NOT running! | return }
  15.       set %banident 0
  16.       .msg $chan ( $+ $nick $+ ): The Ban Ident module has been stopped.
  17.     }
  18.     if ($2 == add) {
  19.       if (!$3) { .msg $chan ( $+ $nick $+ ): Error, Please use the ident! | return }
  20.       if ($ulist($3,ident,1)) { .msg $chan ( $+ $nick $+ ):  Error, That $qt($3) ident is already exists in the list! | return }
  21.       .auser ident $3
  22.       .msg $chan ( $+ $nick $+ ): The $qt($3) ident has been added to the list.
  23.     }
  24.     if ($2 == del) {
  25.       if (!$3) { .msg $chan ( $+ $nick $+ ): Error, Please use the ident! | return }
  26.       if (!$ulist($3,ident,1)) { .msg $chan ( $+ $nick $+ ):  Error, That $qt($3) ident does NOT exists in the list! | return }
  27.       .ruser ident $3
  28.       .msg $chan ( $+ $nick $+ ): The $qt($3) ident has been removed from the list.
  29.     }
  30.     if ($2 == list) {
  31.       var %t = $ulist(*,ident,0)
  32.       if (!%t) { .msg $chan ( $+ $nick $+ ): The ident list is empty. | return }
  33.       var %i = 1
  34.       while (%i <= %t) { .msg $chan ( $+ $nick $+ ): $chr(35) $+ %i -> $ulist(*,ident,%i) | inc %i }
  35.     }
  36.     if ($2 == clear) {
  37.       var %t = $ulist(*,ident,0)
  38.       if (!%t) { .msg $chan ( $+ $nick $+ ): The ident list is empty. | return }
  39.       while (%t) { .ruser country $ulist(*,ident,%t) | dec %t }
  40.       .msg $chan ( $+ $nick $+ ): All the idents have been cleared.
  41.     }
  42.     if ($2 == total) {
  43.       var %t = $ulist(*,ident,0)
  44.       if (!%t) { .msg $chan ( $+ $nick $+ ): The ident list is empty. }
  45.       else { .msg $chan ( $+ $nick $+ ): There are %t idents in the list. }
  46.     }
  47.   }
  48.  
  49.   ; -------
  50.  
  51.   if ($1 == !c) {
  52.     var %opts = add del clear list total start stop on off
  53.     if (!$2) { .msg $chan ( $+ $nick $+ ): Error, Please use an option of $qt(%opts) $+ . | return }
  54.     if (!$istok(%opts,$2,32)) { .msg $chan ( $+ $nick $+ ):  Error, Please use on of the correct options $qt(%opts) $+ . | return }
  55.     if ($2 == start) || ($2 == on) {
  56.       if (%bancountry) { .msg $chan ( $+ $nick $+ ): The Ban Country module is already running! | return }
  57.       set %bancountry 1
  58.       .msg $chan ( $+ $nick $+ ): The Ban Country module has been started.
  59.     }
  60.     if ($2 == stop) || ($2 == off) {
  61.       if (!%bancountry) { .msg $chan ( $+ $nick $+ ): The Ban Country module is NOT running! | return }
  62.       set %bancountry 0
  63.       .msg $chan ( $+ $nick $+ ): The Ban Country module has been stopped.
  64.     }
  65.     if ($2 == add) {
  66.       if (!$3) { .msg $chan ( $+ $nick $+ ): Error, Please use the country code! | return }
  67.       if ($ulist($3,country,1)) { .msg $chan ( $+ $nick $+ ):  Error, That $qt($3) country code is already exists in the list! | return }
  68.       .auser country $3
  69.       .msg $chan ( $+ $nick $+ ): The $qt($3) country code has been added to the list.
  70.     }
  71.     if ($2 == del) {
  72.       if (!$3) { .msg $chan ( $+ $nick $+ ): Error, Please use the country code! | return }
  73.       if (!$ulist($3,country,1)) { .msg $chan ( $+ $nick $+ ):  Error, That $qt($3) country code does NOT exists in the list! | return }
  74.       .ruser country $3
  75.       .msg $chan ( $+ $nick $+ ): The $qt($3) country code has been removed from the list.
  76.     }
  77.     if ($2 == list) {
  78.       var %t = $ulist(*,country,0)
  79.       if (!%t) { .msg $chan ( $+ $nick $+ ): The country code list is empty. | return }
  80.       var %i = 1
  81.       while (%i <= %t) { .msg $chan ( $+ $nick $+ ): $chr(35) $+ %i -> $ulist(*,country,%i) | inc %i }
  82.     }
  83.     if ($2 == clear) {
  84.       var %t = $ulist(*,country,0)
  85.       if (!%t) { .msg $chan ( $+ $nick $+ ): The country code list is empty. | return }
  86.       while (%t) { .ruser country $ulist(*,country,%t) | dec %t }
  87.       .msg $chan ( $+ $nick $+ ): All the country codes have been cleared.
  88.     }
  89.     if ($2 == total) {
  90.       var %t = $ulist(*,country,0)
  91.       if (!%t) { .msg $chan ( $+ $nick $+ ): The country code list is empty. }
  92.       else { .msg $chan ( $+ $nick $+ ): There are %t country codes in the list. }
  93.     }
  94.   }
  95.   if ($1 == !clines) {
  96.     if (%scan_nick) { .msg $chan ( $+ $nick $+ ): This progress is already running from %scan_nick $+ , Please wait $var(scan_nick,1).unset seconds.. | return }
  97.     .msg $chan ( $+ $nick $+ ): Start removing all G:Lines and Z:Lines from this server..
  98.     set -eu20 %scan_nick $nick
  99.     set -eu10 %scan_glines 1
  100.     os akill list
  101.     stats g
  102.     .timer[SCAN_ZLINES] -h 1 1000 set -eu10 %scan_zlines 1 $(|) stats k
  103.   }
  104. }
  105.  
  106. raw 216:*: { if (%scan_nick) { haltdef } }
  107. raw 223:*: {
  108.   if (%scan_nick) {
  109.     haltdef
  110.     if (%scan_zlines) && ($2 === z) { set -eu3 %zlines $calc(%zlines +1) | zline - $+ $3 }
  111.     if (%scan_glines) && ($2 === G) { set -eu3 %glines $calc(%glines +1) | gline - $+ $3 }
  112.   }
  113. }
  114. raw 219:*: {
  115.   if (%scan_nick) {
  116.     haltdef
  117.     if ($me ison #opers) {
  118.       if (%scan_zlines) && (%zlines) { .msg #opers ( $+ %scan_nick $+ ): All Z:Lines have been removed. - (Total: %zlines $+ ) | unset %scan_zlines %zlines }
  119.       elseif (%scan_zlines) && (!%zlines) { .msg #opers ( $+ %scan_nick $+ ): Z:Lines are currently empty. | unset %scan_zlines }
  120.       if (%scan_glines) && (%glines) { .msg #opers ( $+ %scan_nick $+ ): All G:Lines have been removed. - (Total: %glines $+ ) | unset %scan_glines %glines }
  121.       elseif (%scan_glines) && (!%glines) { .msg #opers ( $+ %scan_nick $+ ): G:Lines are currently empty. | unset %scan_glines }
  122.     }
  123.     if ($2 === k) && ($me ison #opers) { .msg #opers ( $+ %scan_nick $+ ): End of removing all G:Lines and Z:Lines from the server. }
  124.   }
  125. }
  126.  
  127. ON ^*:NOTICE:*:?: {
  128.   if ($nick == OperServ) && (%scan_nick) {
  129.     haltdef
  130.     tokenize 32 $strip($1-)
  131.  
  132.     if (*AKILL list is empty* iswm $1-) { .msg #opers ( $+ %scan_nick $+ ): BOT AKILLs List is currently empty. }
  133.     if (*Current AKILL list:* iswm $1-) { set -eu3 %akills_start 1 }
  134.     if (*End of Akill list* iswm $1-) {
  135.       if (%akills) { .msg #opers ( $+ %scan_nick $+ ): All BOT AKILLs have been removed. - (Total: %akills $+ ) }
  136.       else { .msg #opers ( $+ %scan_nick $+ ): BOT AKILLs are currently empty. }
  137.     }
  138.  
  139.     if (%akills_start) && ($1 isnum) && ($remove($2,*,@,.) isletter) && ($len($remove($2,*,@,.)) == 2) && (!$ulist($remove($2,*,@,.),country,1)) { set -eu3 %akills $calc(%akills +1) | os akill del $2 }
  140.   }
  141. }
  142.  
  143. ON ^*:SNOTICE:*: {
  144.   haltdef
  145.  
  146.   if (*Z:Line added for* iswm $1-) { .timer[COUNTRYBAN_ $+ $remove($5,*,@) $+ _NOW] off }
  147.  
  148.   if (*Client Exiting* iswm $1-) {
  149.     if ($hget(COUNTRIES,$6)) { hdel COUNTRIES $6 }
  150.     .timer[COUNTRY_ $+ $6 $+ _SCAN] off
  151.     .timer[BANIDENT_ $+ $6 $+ _NOW] off
  152.   }
  153.  
  154.   if (*Client Connecting* iswm $1-) && (*on port* iswm $1-) {
  155.  
  156.     var %nick = $9
  157.     var %addr = $remove($10,$chr(40),$chr(41),~)
  158.     var %ident = $gettok($remove($10,$chr(40),$chr(41),~),1,64)
  159.  
  160.     if (%banident) {
  161.  
  162.       if (%nick) && (%addr) && (%ident) && (!$ulist(%ident,ident,1)) {
  163.         .timer[BANIDENT_ $+ %nick $+ _NOW] -h 1 1000 gline *@ $+ $gettok(%addr,2,64) 2h 10[ 4G-Lined 10]: 5Your ident ( $+ %ident $+ ) is NOT permitted on that network.
  164.         .msg #opers 10-- Client 4BANNED 10due connecting with bad-ident4 %ident 10as5 %nick 10(4 $+ %addr $+ 10)
  165.         return
  166.       }
  167.  
  168.     }
  169.  
  170.     if (%bancountry) {
  171.       var %code = $upper($gettok(%addr,$numtok(%addr,46),46))
  172.  
  173.       if ($len(%code) == 2) && (%code isletter) && (!$ulist(%code,country,1)) {
  174.         os akill add +2h *@*. $+ %code 2[ 4AKILLED 2]: Your country ( $+ %code $+ ) is NOT permitted to connect on this network.
  175.         gline *@ $+ $gettok($remove($10,$chr(40),$chr(41)),2,64) 2h 2[ 4G-Lined 2]: Your country ( $+ %code $+ ) is NOT permitted on that network.
  176.         if ($me ison #opers) { .msg #opers 2-- Client 4BANNED 2due connecting4 $9 2(5 $+ %addr $+ 2) from4 %code }
  177.         return
  178.       }
  179.     }
  180.  
  181.     if ($check_ip(%addr)) { .timer[COUNTRY_ $+ %nick $+ _SCAN] -h 1 1000 scan_country %nick %addr %ident }
  182.     else { hadd -m COUNTRIES %nick %addr %ident | .timer[COUNTRY_ $+ %nick $+ _SCAN] -h 1 1000 userip %nick }
  183.   }
  184. }
  185.  
  186. raw 340:*: {
  187.   haltdef
  188.  
  189.   var %nick = $gettok($2-,1,61)
  190.   var %ip = $gettok($2-,2,64)
  191.   var %match = $hget(COUNTRIES,%nick)
  192.  
  193.   if (%match) && (%ip) { scan_country %nick %ip $gettok(%match,2,32) }
  194. }
  195.  
  196. alias -l scan_country {
  197.   if (!$check_ip($2)) { var %addr = $gettok($hget(COUNTRIES,$1),1,32) $+ @ $+ $gettok($hget(COUNTRIES,$1),2,32) | hdel COUNTRIES $1 }
  198.   else { var %addr = $3 $+ @ $+ $2 }
  199.  
  200.   var %v = lookup_ $+ $rand(1,10000000000000)
  201.   var %u = https://geoip.nekudo.com/api/ $+ $2 $+ /en/short
  202.   JSONOpen -u %v %u
  203.   if ($JSONError) { JSONClose %v | return }
  204.  
  205.   var %name = $json(%v,country,name).value
  206.   var %country = $upper($json(%v,country,code).value)
  207.   JSONClose %v
  208.  
  209.   if (%name) && (%country) { .timer[COUNTRYBAN_ $+ $2 $+ _NOW] -h 1 1000 send_msg $1 %addr $2 %country %name }
  210. }
  211.  
  212. alias -l send_msg {
  213.   if (!$1-) { return }
  214.   if (%bancountry) && (!$ulist($4,country,1)) {
  215.     os akill add +2h *@*. $+ $4 2[ 4AKILLED 2]: Your country ( $+ $4 $+ ) is NOT permitted to connect anymore on this network.
  216.     zline *@ $+ $3 2h 2[ 4Z-Lined 2]: Your country ( $+ $4 $+ ) is NOT permitted on that network.
  217.     if ($me ison #opers) { .msg #opers 2-- Client 4BANNED 2due connecting4 $1 2(5 $+ $2 $+ 2) (4 $+ $3 $+ 2) from4 $5- ( $+ $4 $+ ) }
  218.   }
  219.   else {
  220.     if ($me ison #opers) { .msg #opers 2-- Client connecting3 $1 2(5 $+ $2 $+ 2) (3 $+ $3 $+ 2) from3 $5- ( $+ $4 $+ ) }
  221.   }
  222. }
  223.  
  224. alias -l check_ip {
  225.   if (!$1) { return 0 }
  226.   if ($regex($1-,/^(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})$/Sx)) { return 1 }
  227.   return 0
  228. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement