mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Using
Code:
 /chanserv sop #channel list 
returns something like
Quote:
-ChanServ- *** SOP list for #channel: ***
-
-ChanServ- Num User
-
-ChanServ- 1 RusselB-afk (Private)
-
-ChanServ- *** End of list - 1 match shown. ***


What I want to do is get a list of the nicks that are returned, but there's no guarantee as to how many (if any) nicks will be returned.

Any suggestions as to how I can go about this?

Joined: Feb 2005
Posts: 342
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
Pretty simple process. I'll give you a small example. Since I'm sure you already know how to add things to a hash table, or variables.

Code:
on $*:notice:/(SOp|AOp) list for/:?:{
  enable #capturelist | set %list $4 :: $regml(1)
}
on *:notice:End of List:?:{ disable #capturelist | unset %list }
#capturelist off
on $*:notice:/-.*?(\S+.*)/:?:{
  echo -sg %list :: $regml(1)
}
#capturelist end


Edit: I suppose I should mention that this is how you would go about it on DALnet. Not sure which network you go to.

Last edited by Rand; 07/08/06 06:08 AM.
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Thanks, and you're right regarding the hash tables/variables.

I see that you used regex in the on notice events.
While I have done some studying on them, would you mind explaining them in detail, so that I can make sense of them. Regex items always give me a headache when I try to do them myself, and I'd like to understand just how they work.

Sorry to say this, but the code doesn't seem to be working.
I made a couple of small changes, but I don't think they'd have much affect regarding the operation of the code.
Here's the code with the changes that I made
Code:
on $*:notice:/(SOp|AOp) list for/:*:{
  enable #capturelist2
  set %list $4 :: $regml(1)
}
on *:notice:End of List:*:{
  disable #capturelist2
  unset %list
}
#capturelist2 off
on $*:notice:/-.*?(\S+.*)/:*:{
  echo 4 -ag %list :: $regml(1)
}
#capturelist2 end

  

The information is still being returned in the status window, which is where chanserv sends it's notices on the network that I'm working on (actually all 3 networks that I'm testing with)
As you can see, the changes that I made are limited to using the * in place of the ? for the location, a change in the group name (simply because I already have a #capturelist group in this script), and having the echo of the information sent to the active window and coloured red, rather than the status window.

If it helps, the three networks that I'm testing on are Bondage.com, BDSM-Net.com and Maximum-IRC.com

Last edited by RusselB; 07/08/06 07:12 AM.
Joined: Feb 2005
Posts: 342
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
Hmm, well, as the help file says, regex is a bit beyond the scope of just simple explanations. There's a lot to it, though once you have the basics down, it's fairly easy to work with.

I'd suggest just looking up examples, and attempting them inside of mIRC (just //echo -ag $regex() - $regml(1) - $regml(2), etc, would work fine).

But as far as what I used in the examples I gave you:

/(SOp|AOp) list for/

This checks for "SOp list for" and "AOp list for." It matches both. This then assigns the corresponding word to $regml(1) (so $regml(1) would return SOp or AOp).

In other words: /(you and i|i and you) are going to the park/
Would match: you and i are going to the park
Also matches: i and you are going to the park

/-.*?(\S+.*)/

This looks for a "-" in the line, the .*? I used is just filler (spaces), you can probably replace .*? with \s+ and achieve the same effect. the \S catches the first NON space after the -, and reads/matches until the end of the string. This is also passed into $regml(1) since it's in ()'s.

This is the sort of notice ChanServ would send you for the list:
1 - nick (ident@host)

Hope that helps a little, I'm not so great at explaining regular expressions, well, not in short atleast. You'd be better off just looking up some tutorials. Trying to explain them based off a few examples is horrible, and I don't want to put the hours in writing my tutorial for them.

Anyway, good luck.

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
I can't see any reason for the third event to be using a regex at all. Beyond the fact that it doesn't match your example text, it is completely unnecessary.

Code:
on $*:notice:& *:*:{
  echo 4 -ag Num: $1 Nick: $2 Etc: $3-
}


Using your example text, a suitable regex might be this:

/^(\d+)\s(\S+)(\s.+)?$/

^ = beginning of string

(\d+) = match 1 or more \d (digits, 0-9) (chanserv inserts a number before each nick) and return as $regml(1)

\s = single whitespace character

(\S+) = match 1 or more \S (non-whitespace) (The nick is made up of non-whitespace characters) and return as $regml(2)

(\s.+)? = match a whitespace character followed by 1 or more of any character (including whitespace) (this is in case chanserv gives other information after the nick, like "(private)" in your example). The ? indicates that the section within the () is optional (ie. the regex will still match if that portion is not present). If the match is present, it will be returned as $regml(3)

$ = end of string


BTW, you may want to check out this program for working with regular expressions: http://kodos.sourceforge.net/

-genius_at_work

Last edited by genius_at_work; 07/08/06 04:43 PM.

Link Copied to Clipboard