westor

Nicks Per IP for GaMbiTo v1.0

Dec 4th, 2020
884
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ON *:START: {
  2.   hmake NIPS 5000
  3.  
  4.   var %f = nips.db
  5.  
  6.   if ($file(%f)) { hload NIPS $qt(%f) }
  7. }
  8.  
  9. ON *:EXIT: {
  10.   var %f = nips.db
  11.  
  12.   if ($hget(NIPS)) && ($hget(NIPS,0).item) { hsave NIPS $qt(%f) }
  13. }
  14.  
  15. ON *:TEXT:*:#: {
  16.   tokenize 32 $strip($1-)
  17.  
  18.   if ($1 == !ipnick) {
  19.     if (!$2) { msg $chan ( $+ $nick $+ ): Error, Please insert an IP Address! | return }
  20.     if (!$check_ipv4($2)) { msg $chan ( $+ $nick $+ ): Error, Please insert a valid IP Address! | return }
  21.  
  22.     var %r = $hget(NIPS,$2)
  23.     var %t = $numtok(%r,32)
  24.  
  25.     if (!%r) { msg $chan ( $+ $nick $+ ): No results founded for $bold($2) IP Address! | return }
  26.  
  27.     msg $chan ( $+ $nick $+ ): $iif(%t == 1,There is $bold(%t) nickname change,There are $bold(%t) nickname changes) from $bold($2) IP Address.
  28.     msg $chan ( $+ $nick $+ ): $iif(%t == 1,Nickname was:,Nicknames were:) $bold(%r)
  29.   }
  30.  
  31. }
  32.  
  33. ON *:SNOTICE:*: {
  34.   tokenize 32 $strip($1-)
  35.  
  36.   if (*Conectando* iswm $1-) {
  37.     var %nick = $3
  38.     var %ip = $remove($5,[,])
  39.  
  40.     if (%nick == $me) || (%ip == $ip) || (!$check_ipv4(%ip)) { return }
  41.  
  42.     var %r = $hget(NIPS,%ip)
  43.  
  44.     var %r = $addtok(%r,%nick,32)
  45.  
  46.     hadd NIPS %ip %r
  47.   }
  48.  
  49.   if (*Cambia el nick a* iswm $1-) {
  50.     var %old_nick = $2
  51.     var %new_nick = $9
  52.     var %ip = $remove($4,[,])
  53.  
  54.     if (%old_nick == $me) || (%new_nick == $me) || (%ip == $ip) || (!$check_ipv4(%ip)) { return }
  55.  
  56.     var %r = $hget(NIPS,%ip)
  57.  
  58.     var %r = $addtok(%r,%old_nick,32)
  59.     var %r = $addtok(%r,%new_nick,32)
  60.  
  61.     hadd NIPS %ip %r
  62.   }
  63.  
  64. }
  65.  
  66. alias -l bold { return $+($chr(2),$1-,$chr(2)) }
  67. alias -l check_ipv4 {
  68.   if (!$1) { return 0 }
  69.  
  70.   if ($regex($1,/^(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})$/Sx)) && ($iptype($1) == ipv4) { return 1 }
  71.  
  72.   return 0
  73. }
  74.  
RAW Paste Data