| View previous topic :: View next topic |
| Author |
Message |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Fri Aug 14, 2009 8:22 pm Post subject: |
|
|
| arfer wrote: | | I think the regexp I have used would be correct in all circumstances. |
| Code: | | set limit [lindex [split [string trim [lindex [split [getchanmode $chan] l] 1]]] 0] | Note: that is a lowercase L during the [split] on [getchanmode]. It is not the numeral 1.
This works almost as well as your regexp with the same common problem. If the channel is keyed and contains any digits, your regexp will pick this up instead as k comes before l. In my version it will pick up the entire key regardless of digits or not. Yours will fail on a key with digits, mine will fail with a key period.. HAW
There is probably a simple way to extract just the limit but may require more than a single line of code. Need to get an if in there to perform some manipulation depending upon circumstances (presence of +k)...
| Code: | -- in channel #test
* speechles sets mode: +l 1337
* speechles sets mode: +k 31337
-- in partyline
<speechles> .tcl regexp -- {\+[^\-]+l ([0-9]+)} [getchanmode #test] -> limit
<bot> Tcl: 1
<speechles> .tcl set test $limit
<bot> Tcl: 31337
<speechles> .tcl set test [lindex [split [string trim [lindex [split [getchanmode #test] l] 1]]] 0]
<bot> Tcl: 31337 |
Basically, it needs this code: | Code: | set place 0
if {[string match "*k*" [lindex [split [getchanmode #test] l] 0]]} { incr place }
set limit [lindex [split [string trim [lindex [split [getchanmode #test] l] 1]]] $place] |
This should work with a key now and in all situations. *crosses fingers*
| Code: | -- in partyline
<speechles> .tcl set place 0
<bot> Tcl: 0
<speechles> .tcl if {[string match "*k*" [lindex [split [getchanmode #test] l] 0]]} { incr place }
<bot> Tcl: 1
<speechles> .tcl set limit [lindex [split [string trim [lindex [split [getchanmode #test] l] 1]]] $place]
<bot> Tcl: 1337
<speechles> YAY!! |
_________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Fri Aug 14, 2009 9:18 pm Post subject: |
|
|
Ok thanks. It was my IRC knowledge that let me down, though I don't doubt there must be a regexp that would do the trick no matter how complex the compounded modes get.
| Code: |
regexp -- {\+[^\-]+k?l([\s].+)? ([0-9]+)} [getchanmode $chan] -> key limit
|
The above seems to work as long as there is no other mode appearing between k and l _________________ I must have had nothing to do |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Sat Aug 15, 2009 6:18 am Post subject: |
|
|
Just to answer the original poster, I think the following will now work in all circumstances (all that I can test anyway).
| Code: |
bind JOIN - * pLimitJoin
bind MODE - "% +l" pLimitChange
proc pLimitJoin {nick uhost hand chan} {
if {[isbotnick $nick]} {
utimer 10 [list pLimitCheck $chan]
}
return 0
}
proc pLimitCheck {chan} {
global vLimitOld
regexp -- {^[^-\s]+k?l([\s][^-\s]+)?[\s]([0-9]+)} [getchanmode $chan] -> dummy vLimitOld($chan)
return 0
}
proc pLimitChange {nick uhost hand chan mode target} {
global vLimitOld
if {([info exists vLimitOld($chan)]) && ([string length $vLimitOld($chan)] != 0)} {
if {$vLimitOld($chan) != $target} {
putlog "limit change in $chan from $vLimitOld($chan) to $target"
}
}
set vLimitOld($chan) $target
return 0
}
# eof
|
_________________ I must have had nothing to do |
|
| Back to top |
|
 |
neoclust Halfop
Joined: 14 Aug 2009 Posts: 55
|
Posted: Sat Aug 15, 2009 7:03 am Post subject: |
|
|
| Thanks a lot arfer and Speechless the code works |
|
| Back to top |
|
 |
|