Simple Voice Halfop Op snippet

By Bielie on Jan 04, 2012

USAGE:
/+-vho #channel Target

Good Luck

;;Simple +-vho for mIRC by Bielie
;;Version 1.0
;;Status: This code "smells" and needs refactoring

alias +v {
  if ($2 !ison $1) { echo Target not found | halt }
  if ($2 isvoice $1) { echo Target is already a voice | halt }
  if ($chanaccess($1,$me) >= 2) { .timer 1 1 mode $1 +v $2 | msg $1 +v $2 | halt }
  else { echo No Access | halt }
}
alias -v {
  if ($2 !ison $1) { echo Target not found | halt }
  if ($2 !isvoice $1) { echo Target is not currently voiced | halt }
  if ($chanaccess($1,$me) >= 2) { .timer 1 1 mode $1 -v $2 | msg $1 -v $2 | halt }
  else { echo No Access | halt }
}
alias +h {
  if ($2 !ison $1) { echo Target not found | halt }
  if ($2 ishop $1) { echo Target is already an half-operator | halt }
  if ($chanaccess($1,$me) >= 3) { .timer 1 1 mode $1 +h $2 | msg $1 +h $2 | halt }
  else { echo No Access | halt }
}
alias -h {
  if ($2 !ison $1) { echo Target not found | halt }
  if ($2 !ishop $1) { echo Target is not currently an half-operator  | halt }
  if ($chanaccess($1,$me) >= 3) { .timer 1 1 mode $1 -h $2 | msg $1 -h $2 | halt }
  else { echo No Access | halt }
}
alias +o {
  if ($2 !ison $1) { echo Target not found | halt }
  if ($2 isop $1) { echo Target is already an operator | halt }
  if ($chanaccess($1,$me) >= 3) { .timer 1 1 mode $1 +o $2 | msg $1 +o $2 | halt }
  else { echo No Access | halt }
}
alias -o {
  if ($2 !ison $1) { echo Target not found | halt }
  if ($2 !isop $1) { echo Target is not currently an operator | halt }
  if ($chanaccess($1,$me) >= 3) { .timer 1 1 mode $1 -o $2 | msg $1 -o $2 | halt }
  else { echo No Access | halt }
}

alias chanaccess {
  if ($1 ischan) {
    if ($2 ison $1) {
      var %pre = $remove($nick($1,$2).pnick,$2)
      if ($prop == pre) return %pre
      if ($prop == p) return $left(%pre,1)
      elseif (@ isin %pre) || ($1 isop $2) { return 3  }
      elseif (% isin %pre) || ($1 ishop $2) { return 2  }
      elseif (+ isin %pre) || ($1 isvo $2) { return 1 }
      else { return 0 }
    }
  }
}

Comments

Sign in to comment.
hixxy   -  Jan 11, 2012

Here's my take (supports both nickmodes and channel modes):

on @*:input:#:{ 
  if ($regex($1,/^[+-][ $nickmode ]/x)) {
    if ($2 !ison $chan) { echo 4 User $qt($2) is not currently on the channel. }
    else { mode $chan $1- }
  }
  elseif ($regex($1,/^[+-][ $remove($chanmodes,$chr(44)) ]/x)) { mode $chan $1- }
}
 Respond  
Spoof   -  Jan 10, 2012

just simplify it by setting the services to op anyone half op and up with:
/msg ChanServ levels $?="Channel?" SET autovoice -3

 Respond  
Jethro   -  Jan 05, 2012

Matcou, yes, I agree with you:

on @*:input:#:{
  if ($regex($1,/(?:[+-][vhoaq])/)) {
    if ($2 !ison #) {
      echo 4 User is not currently in the channel.
    }
    else mode # $1-
  }
}
 Respond  
Matcou   -  Jan 05, 2012

@Jethro
Why would you use $regml in this case? It is just an extra ~20 ticks every time. All you need is to add ?:'s to the matches (to make them not be held in $regml(); you could just remove the ()s completely) and use $1- instead of your $+($regml(1),$regml(2)) $2.

 Respond  
Abcdefmonkey   -  Jan 05, 2012

Ermm. I dunno why I said elseif.. in this situation I meant to say just "else".. Lol.. Derp.. but yeah, I know that Jethro :P I said the wrong thing initially xD Just now realized it. :p

 Respond  
Jethro   -  Jan 05, 2012

If you used elseif in place of the second statement, your last else would have been false. The last else corresponds with the first if statement.

if () { ... }
elseif () { ... }
else { ... }

 Respond  
Abcdefmonkey   -  Jan 05, 2012

I prefer elseif, unless I really can't be arsed to go further with it, but something as simple as this, why not just halt. :P

 Respond  
Fuzionx   -  Jan 05, 2012

Yeah I know, I just find it a bit of a dirty way ^^

 Respond  
Jethro   -  Jan 05, 2012

Because, Fuzionx, they give you the same result, either you use else after or halt the first if statement. It's a personal preference, really.

 Respond  
Abcdefmonkey   -  Jan 05, 2012

Ahh, good idea Jethro. I wasn't thinking about that when I made this. To each their own though. :P

 Respond  
Fuzionx   -  Jan 05, 2012

Why /halt if you can use else?

 Respond  
Jethro   -  Jan 05, 2012

Since you've used regex, why not take advantage of $regml() :

on @*:input:#:{
  if ($regex($1,/([+-])([vhoaq])/)) {
    if ($2 !ison #) { 
      echo 4 User is not currently in the channel. 
      halt 
    }
    mode # $+($regml(1),$regml(2)) $2
  }
}
 Respond  
Abcdefmonkey   -  Jan 05, 2012

So much code for something simple. This is what I use

on *:INPUT:*: {
  if ($regex($mid($1-,1,2),[+-][vhoaq])) {
  if ($2 !ison $chan) { echo 4 User is not currently in the channel. | halt } 
    haltdef
    mode $chan $mid($1-,1,1) $+ $remove($mid($1-,2,2),$chr(32)) $2-
    }
}

Granted, it is an on input, but it's shorter and does the same thing yours does. Kudos anyways. :) Good work.

 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.