mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2004
Posts: 27
P
parvez Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Apr 2004
Posts: 27
Hi! (damn..it's been a long time since i came here)

I need help again. I want a code that will give +v to anyone who is an oper and join #support.

For example:
Method 1: If John is an oper in the server and he joins #support then I should whois him and see that "John is an operator" and then +v him automatically. That means I will whois "anyone" who joins #support to check if they're an oper or not.

Method 2: I am a service administrator. So is it possible for me to whois and check their usermodes and based on that, I will give +v automatically?

I really need the code. Thank you! I'll reply back asap.


Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Code:
On @*:Join:#support: {
  .enable #Oper
  who $nick
}

#Oper off
Raw 352:*: { 
  if (* isin $7) {
    mode #support +v $6
  }
  halt
}
Raw 315:*: {
  .disable #Oper
  halt
}
#Oper end


A more simplistic approach to check if they're an oper is to check their oper host maybe.

Joined: Apr 2004
Posts: 27
P
parvez Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Apr 2004
Posts: 27
Dude!!

You are a true genius. It worked. Thank you so much. I appreciate the help.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
No need to use /whois for this, as /who will return the proper codes
Code:
on @*:join:#support:{
  .enable #voice_check
  .who $nick
}
#voice_check off
raw 352:*:{
  if $chr(42) isin $7 {
    .mode #support +v $6
  }
}
raw 315:*:{
  .disable #voice_check
  haltdef
}
#voice_check end


Beat by SladeKraven..oh well, had to happen sometime

Last edited by RusselB; 22/07/07 08:29 PM.
Joined: Apr 2004
Posts: 27
P
parvez Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Apr 2004
Posts: 27
Both codes worked. Thanks again!

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Recently, while making a script that accesses /who raw data, I have discovered that you can't reliably /who $nick to get the results you are looking for. Example:

If you do /who frank, the server will reply with all the users who have frank as their nick, ident, or realname. The simplest reliable method I've found is to use the /userhost $nick command.

Here is my code that parses RAW 302 (/userhost response):

Code:
  var %c = 1, %cc = $0
  while (%c < %cc) {
    inc %c
    ; REGEX: (nick)(*=+)(ident)@(host)
    noop $regex($gettok($1-,%c,32),/(.+?)(\*?\=[+-])(.+?)@(.+)/)

    echo -a .Nick: $regml(1) 
    echo -a .Mode: $regml(2)
    if (* isin $regml(2)) echo -a Oper: Yes
    else echo -a Oper: No
    if (- isin $regml(2)) echo -a Away: Yes
    elseif (+ isin $regml(2)) echo -a Away: No
    echo -a Ident: $regml(3) 
    echo -a .Host: $regml(4)
  }



The while loop is included because /userhost can support multiple nicks, so RAW 302 can return multiple sets of data.

Here is the equivalent of your code, except using USERHOST:

Code:
on *:JOIN:#support:{
  if ($me isop $chan) {
    set -u5 $+(%,UH.,$nick) 1
    userhost $nick
  }
}

RAW 302:*:{
  var %c = 1, %cc = $0
  while (%c < %cc) {
    inc %c
    ; REGEX: (nick)(*=+)(ident)@(host)
    noop $regex($gettok($1-,%c,32),/(.+?)(\*?\=[+-])(.+?)@(.+)/)
    tokenize 32 $regml(1) $regml(2) $regml(3) $regml(4)
    if ($($+(%,UH.,$1),2)) {
      if ((* isin $2) && ($1 ison #support)) .mode #support +v $1
      unset $+(%,UH.,$1)
      haltdef
    }
  }
}



-genius_at_work

Joined: Apr 2004
Posts: 27
P
parvez Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Apr 2004
Posts: 27
Wow. So many ways to approach to this command. Thank you!!


Link Copied to Clipboard