arfer wrote:I think the regexp I have used would be correct in all circumstances.
Code: Select all
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: Select all
-- 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: Select all
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: Select all
-- 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!!