| | 
| 
| 
|  |  
| 
Joined:  Mar 2004 Posts: 358 Fjord artisan |  
| OP   Fjord artisan Joined:  Mar 2004 Posts: 358 | 
I may not be even doing this right, but basically what I want to do is with on mode, check for specific modes being set, and if I find one (or more) (by themselves or multiple modes set at once), then display which modes were set to a seperate channel. For example:in #mainchannel: * User1 sets mode: +imN
 
 in #botchannel:
 * <Bot> #mainchannel +imN by User1.
 It works right (as in, the $regex string triggers the modes perfectly) from what I can tell, all except for when I try to display them. (Note: $_botchan is fine) 
on *:mode:#: {
  if ($me ison $_botchan) {
    if ($regex(fmode,$1,/^[\+]?[iRmN]+$/)) { msg $_botchan $chan Modes: $regml(fmode,1) set by $nick }
  }
}
I've been playing around with various things to try and get it to work, $regml $ifmatch $v1 $v2.. I'm stumped. |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2007 Posts: 1,124 Hoopy frood |  
|   Hoopy frood Joined:  Jul 2007 Posts: 1,124 | 
on @*:RAWMODE:#: {
  if ($me ison $_botchan) && ($regex(fmode,$1,/\+[^\-]*(i\S*|R\S*|m\S*|N\S*)/)) .msg $_botchan $chan Mode(s): $+(+,$regml(1)) set by $nick $+ .
}You can also use on mode event if you want.
Last edited by Tomao; 08/06/09 07:32 AM.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2007 Posts: 1,124 Hoopy frood |  
|   Hoopy frood Joined:  Jul 2007 Posts: 1,124 | 
Made a little mistake. Corrected. |  |  |  
| 
| 
|  |  
| 
Joined:  Nov 2006 Posts: 1,552 Hoopy frood |  
|   Hoopy frood Joined:  Nov 2006 Posts: 1,552 | 
If you're happy with your current regex and just want to have the the $regml return something: put the respective part of the regex inside round brackets to create your back reference , e.g.: /^( [\+]?[iRmN]+) $/ for the whole string.    |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2007 Posts: 1,124 Hoopy frood |  
|   Hoopy frood Joined:  Jul 2007 Posts: 1,124 | 
I agree with Horstl. But with the round bracket, it will still return a single mode, so that needs to change to: 
Last edited by Tomao; 08/06/09 10:14 AM.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Nov 2006 Posts: 1,552 Hoopy frood |  
|   Hoopy frood Joined:  Nov 2006 Posts: 1,552 | 
Hm, not exactly. It matches/returns: "start of the string, possibly followed by a single plus char, followed by one or more  chars out of "iRmN", followed by no other chars (end of string)" It matches/returns for example: mr / +m / +miR / +Ni / N It won't match: +I / +R-m / -i / + / +mk somekey Now I don't know what the OP intended  to match/return... Not all of the matched examples are possible values of $1- in "on mode", while some out of the unmatched examples are possible values.   If the goal is to message any changes in the modes iRmN, ignoring changes of other modes: Edit: added part to remove leading/trailing mode prefixes if followed by no mode. I admit it's not pretty thoughon *:mode:#: {
  if ($me ison $_botchan) { 
    ; remove from the first word of the mode string everything that is no char out of: iRmN+-
    ; if anything besides "+" and/or "-" remains: message the changes of the modes "iRmN" to $_botchan
    var %m = $regsubex($1,/[^iRmN+-]/g,$null)
    if ($remove(%m,+,-)) {
      msg $_botchan $chan Modes: $replace($iif(($right(%m,1) isin +-),$left(%m,-1),%m),+-,-,-+,+) set by $nick
    }
  }
} |  |  |  
| 
| 
|  |  
| 
Joined:  Mar 2004 Posts: 358 Fjord artisan |  
| OP   Fjord artisan Joined:  Mar 2004 Posts: 358 | 
The regex /^([\+]?[iRmN]+)$/  almost worked. It didn't work in situations where it was +i-G, etc. 
on *:mode:#: {
  if ($me ison $_botchan) { 
    ; remove from the first word of the mode string everything that is no char out of: iRmN+-
    ; if anything besides "+" and/or "-" remains: message the changes of the modes "iRmN" to $_botchan
    var %m = $regsubex($1,/[^iRmN+-]/g,$null)
    if ($remove(%m,+,-)) {
      msg $_botchan $chan Modes: $replace($iif(($right(%m,1) isin +-),$left(%m,-1),%m),+-,-,-+,+) set by $nick
    }
  }
}
This is almost it.. however after playing with it I still can't make it ignore the changes if they are unset, I just need it to show when they are set. Thanks for all the help so far guys. |  |  |  
| 
| 
|  |  
| 
Joined:  Nov 2006 Posts: 1,552 Hoopy frood |  
|   Hoopy frood Joined:  Nov 2006 Posts: 1,552 | 
Ah, I thought you wanted to track both set and unset of these modes. Try: on *:mode:#: {
  if ($me ison $_botchan) && ($regsubex($gettok($1,$iif((- isin $1),2,1),43),/[^iRmN]/g,$null)) {
    msg $_botchan $chan Modes: + $+ $v1 set by $nick
  }
}This code assumes that if both +<mode(s)> and -<mode(s)> are set in the same mode string, the "-" modes will preceed the "+" modes, which afaik  will always be true.  |  |  |  
| 
| 
|  |  
| 
Joined:  Mar 2004 Posts: 358 Fjord artisan |  
| OP   Fjord artisan Joined:  Mar 2004 Posts: 358 | 
If I read it right, you meant that is wasn't possible. It is on UnrealIRCd anyway:
 Edit: It works both ways.
 
 * Phase sets mode: +m-iQ
 * Phase sets mode: +iRNT-m
 
 * Phase sets mode: -i+l 23
 
 
Last edited by LostServ; 08/06/09 04:10 PM.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Nov 2006 Posts: 1,552 Hoopy frood |  
|   Hoopy frood Joined:  Nov 2006 Posts: 1,552 | 
Nah, gettok was to keep it more simple; and sorry for the wrong assumtion    It's possible, e.g. by changing the if-line to:   if ($me ison $_botchan) && ($regsubex($regsubex($1,/-\w+/,$null),/[^iRmN]/g,$null)) {The inner regsubex removes a possible "-<mode(s)>" from $1. The outer regsubex removes any char that is not i,R,m, or N from what's left. If any chars are left now, they should be the mode(s) you're looking for. |  |  |  
| 
| 
|  |  
| 
Joined:  Mar 2004 Posts: 358 Fjord artisan |  
| OP   Fjord artisan Joined:  Mar 2004 Posts: 358 | 
This appears to be working perfectly. Thanks for your help.   |  |  |  | 
 |