westor

OP List based realname for Dune2K v1.4

Sep 27th, 2020 (edited)
1,047
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. alias channels { return #SWGhost,#SWGhost-Game }
  2.  
  3. ON *:JOIN:$($channels): {
  4.   if ($nick == $me) {
  5.     .ialfill -f $chan
  6.  
  7.     .timer[CHECK_ $+ $chan $+ _OPLIST] 1 5 chk_all_realname $chan
  8.  
  9.     return
  10.   }
  11.  
  12.   chk_all_realname $chan
  13. }
  14.  
  15. ON *:TEXT:*:?: {
  16.   tokenize 32 $strip($1-)
  17.  
  18.   if ($1 == !op) {
  19.     if (!$2) { msg $nick ( $+ $nick $+ ): Error, Insert a realname! | return }
  20.     if (!$3) { msg $nick ( $+ $nick $+ ): Error, Insert the channel! | return }
  21.     if ($2 == $me) { msg $nick ( $+ $nick $+ ): Error, You cannot use that on the bot! | return }
  22.     if ($me !ison $3) { msg $nick ( $+ $nick $+ ): Error, I am not on $3 channel! | return }
  23.     if (!$istok($channels,$3,44)) { msg $nick ( $+ $nick $+ ): I don't support the channel you enter! | return }
  24.     if (!$chk_access($nick,$3)) { msg $nick ( $+ $nick $+ ): Error, Access denied! | return }
  25.  
  26.     var %f = ops_ $+ $3 $+ .db
  27.     var %r = $read(%f,nw,$2)
  28.  
  29.     if (%r) { msg $nick ( $+ $nick $+ ): Error, This realname is already exists on $3 channel OP list! | return }
  30.  
  31.     write $qt(%f) $2
  32.  
  33.     chk_all_realname $3
  34.  
  35.     msg $nick ( $+ $nick $+ ): Realname $qt($2) has been added on $qt($3) channel OP list.
  36.   }
  37.  
  38.   if ($1 == !deop) {
  39.     if (!$2) { msg $nick ( $+ $nick $+ ): Error, Insert a realname! | return }
  40.     if (!$3) { msg $nick ( $+ $nick $+ ): Error, Insert the channel! | return }
  41.     if ($2 == $me) { msg $nick ( $+ $nick $+ ): Error, You cannot use that on the bot! | return }
  42.     if ($me !ison $3) { msg $nick ( $+ $nick $+ ): Error, I am not on $3 channel! | return }
  43.     if (!$istok($channels,$3,44)) { msg $nick ( $+ $nick $+ ): I don't support the channel you enter! | return }
  44.     if (!$chk_access($nick,$3)) { msg $nick ( $+ $nick $+ ): Error, Access denied! | return }
  45.  
  46.     var %f = ops_ $+ $3 $+ .db
  47.     var %r = $read(%f,nw,$2)
  48.     var %rn = $readn
  49.  
  50.     if (!%r) { msg $nick ( $+ $nick $+ ): Error, This realname does not exists on $3 channel OP list! | return }
  51.  
  52.     write -dl $+ %rn $qt(%f)
  53.  
  54.     chk_all_realname $3
  55.  
  56.     msg $nick ( $+ $nick $+ ): Realname $qt($2) has been removed from $qt($3) channel OP list.
  57.   }
  58.  
  59.   if ($1 == !oplist) {
  60.     if (!$2) { msg $nick ( $+ $nick $+ ): Error, Insert the channel! | return }
  61.     if (!$istok($channels,$2,44)) { msg $nick ( $+ $nick $+ ): I don't support the channel you enter! | return }
  62.     if (!$chk_access($nick,$2)) { msg $nick ( $+ $nick $+ ): Error, Access denied! | return }
  63.  
  64.     var %f = ops_ $+ $2 $+ .db
  65.     var %t = $lines(%f)
  66.  
  67.     if (!$file(%f)) { msg $nick ( $+ $nick $+ ): The OP list for $2 channel is empty! | return }
  68.  
  69.     var %i = 1
  70.     while (%i <= %t) {
  71.       var %r = $read(%f,n,%i)
  72.  
  73.       if (%r) { msg $nick $+([,%i,]:) %r }
  74.  
  75.       inc %i
  76.     }
  77.  
  78.     msg $nick ( $+ $nick $+ ): End of $2 channel OP list. - (Total: %t $+ )
  79.   }
  80.  
  81.   if ($1 == !opclear) {
  82.     if (!$2) { msg $nick ( $+ $nick $+ ): Error, Insert the channel! | return }
  83.     if (!$istok($channels,$2,44)) { msg $nick ( $+ $nick $+ ): I don't support the channel you enter! | return }
  84.     if ($me !ison $2) { msg $nick ( $+ $nick $+ ): Error, I am not on $3 channel! | return }
  85.     if (!$chk_access($nick,$2)) { msg $nick ( $+ $nick $+ ): Error, Access denied! | return }
  86.  
  87.     var %f = ops_ $+ $2 $+ .db
  88.     var %t = $lines(%f)
  89.  
  90.     if (!$file(%f)) { msg $nick ( $+ $nick $+ ): The OP list for $2 channel is empty! | return }
  91.  
  92.     .remove $qt(%f)
  93.  
  94.     chk_all_realname $2
  95.  
  96.     msg $nick ( $+ $nick $+ ): OP list for $2 channel is now cleared. - (Total: %t $+ )
  97.   }
  98. }
  99.  
  100. alias chk_access {
  101.   ; $chk_access(nick,#chan)
  102.  
  103.   if (!$1) || (!$2) || ($encode($network,m) !== Q2hhdEhVQg==) { return }
  104.  
  105.   var %f = $nick($2,$1).pnick
  106.  
  107.   if (*~* iswm %f) || (*&* iswm %f) { return 1 }
  108.  
  109.   return 0
  110. }
  111.  
  112. alias chk_all_realname {
  113.   ; /chk_all_realname #chan
  114.  
  115.   if (!$1) || ($me !ison $1) || ($me !isop $1) || ($encode($network,m) !== Q2hhdEhVQg==) { return }
  116.  
  117.   var %f = ops_ $+ $1 $+ .db
  118.   var %t = $nick($1,0)
  119.  
  120.   var %i = 1
  121.   while (%i <= %t) {
  122.     var %n = $nick($1,%i)
  123.     var %p = $remove($nick($1,%i).pnick,%n)
  124.     var %a = $gettok($ial(%n).gecos,1,32)
  125.     var %r = $read(%f,nw,%a)
  126.  
  127.     if (%n == $me) { goto next }
  128.  
  129.     if (%r) && (%n !isop $1) { mode $1 +o %n }
  130.     if (!%r) && (%n isop $1) { mode $1 -o %n }
  131.  
  132.     :next
  133.     inc %i
  134.   }
  135. }
  136.  
  137. raw 352:*: { haltdef }
  138. raw 315:*: { haltdef }
  139. raw 974:*: { haltdef }
  140.  
RAW Paste Data