$isover

By Meta on Jan 08, 2010

Quick snippet that checks to see if the "level of person $1" is higher than the "level of $2." (or of "level $2" if .prefix property is used...) Should be useful for something. Whether the snippet returns $true or $false depends on several different things, and I'm not sure how to explain them all. So maybe examples will do better...

Examples of use: ------------- :: $prefix = ~&@%+
Nicks: P1, P2, P3, P4 -------- :: Target channel: #chan1
~P1, @P2, @P3, P4 on #chan1 -- :: ~P2, @P3, %P4, P1 on #chan2

-- $isover(P1,P2) = [ is ~P1 higher than @P2 on #chan1 ] = $true
-- $isover(P2,P1,#chan2) = [ is ~P2 higher than P1 on #chan2 ] = $true
-- $isover(P2,P3) = [ is @P2 higher than @P3 on #chan1 ] = $false
-- $isover(P1,@).prefix = [ is ~P1 higher than all @s (ops) on #chan1 ] = $true
-- $isover(P4,@).prefix = [ is P4 higher than all @s (ops) on #chan1] = $false
-- $isover(P3).prefix = [ is @P3 higher than all regular users on #chan1 ] = $true
-- $isover(P4).prefix = [ is P3 higher than all regular users on #chan1 ] = $false
-- $isover(P3,%,#chan2).prefix = [ is @P3 higher than all %s (halfops) on #chan2 ] = $true
-- $isover(P1,%,#chan2).prefix = [ is P1 higher than all %s (halfops) on #chan2 ] = $false
-- $isover(P4,%,#chan2).prefix = [ is %P4 higher than all %s (halfops) on #chan2 ] = $false
-- $isover(P4,#chan2).prefix = [ is %P4 higher than all regular users on #chan2 ] = $true
-- $isover(P1,#chan2).prefix = [ is P1 higher than all regular users on #chan2 ] = $false

There may be other examples, but these above should get the main point across.

Notes:
-- This snippet was made under the assumption that the $prefix identifier always returns the symbols of the prefixes in highest to lowest order. If anyone knows of any cases where this isn't true, I'm curious.

-- This snippet ONLY checks to see if the "level of person $1" is higher than, not equal to, the "level of person / level $2"

If you find any bugs, or see any ways to improve it, let me know. (I realize some lines could be combined, but I wanted to maintain readability, even though some lines might not follow that...)

-- Updates --
-- Made script check to see if second parameter begins with a #. If it does, automatically treat it as a channel. Else check to see if it contains any prefix symbols. If so, check against highest prefix and use third parameter as channel, or target channel if no third parameter. If not, ignore if third parameter, or use as channel if not.

-- Changed examples format and removed a few redundant ones.

-- Blackvenom666 suggested that I specify that this is useful for IRCD (And useless with chatspace, apparently)

alias isover {
  if (!$1) || ($4) || ((!$2) && ($prop != prefix)) { echo $color(info).dd * $iif(!$1,Insufficient,Invalid) parameters: $!isover | halt }
  var %s $len($prefix)
  while (%s) {
    var %pfx %pfx $+ $mid($prefix,%s,1)
    dec %s
  }
  if ($prop == prefix) {
    var %n2 $iif($regex($2,/([ %pfx ]+)/),$pos(%pfx,$left($regsubex(%pfx,/([^ $regml(1) ])/g,),1),1),0)
    var %ch $iif($3,$3,$iif($left($2,1) != $(#,) && $regex($2,/([ %pfx ]+)/) || !$2,#,$2))
  }
  else {
    var %n2 $iif($remove($nick(%ch,$2).pnick,$2),$pos(%pfx,$left($ifmatch,1),1),0)
    var %ch $iif($3,$3,#)
  }
  var %n1 $iif($remove($nick(%ch,$1).pnick,$1),$pos(%pfx,$left($ifmatch,1),1),0)
  return $iif(%n1 > %n2,$true,$false)
}

Comments

Sign in to comment.
blackvenomm666   -  Jun 18, 2011

well chatspace only uses $server:P there is no $network haha. and as for the snippet it looks good. might be something a noob ircd user could use one who isnt familiar with the hierarchy on ircd. but with chatspace as i said there are only a couple typs of levels. you got sop(owner) aop(mod) voice/vop and reguser or member. and in the list it shows no difference between the sop users and the aop they are both fixed with just the @ symbol the only differences are between the aop/sop and vop/reguler @being aop/sop and +being voice/vop and nothing being regular:)

 Respond  
Meta   -  Jun 18, 2011

Done, thanks. I've never used chatspace so I wasn't aware.

If anyone knows any other network types (don't know if that's the correct term) where this would be useful (or useless), please let me know.

 Respond  
blackvenomm666   -  Jun 18, 2011

on chatspace this wouldnt be useful. it would only be comparing between @ and voice/regular users. may wanna put meant for ircd

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.