Code: Select all
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 -- {\+[^\-]+l ([0-9]+)} [getchanmode $chan] -> vLimitOld($chan)
return 0
}
proc pLimitChange {nick uhost hand chan mode target} {
global vLimitOld
if {[info exists vLimitOld($chan)]} {
if {$vLimitOld($chan) != $target} {
putlog "limit change in $chan from $vLimitOld($chan) to $target"
}
}
set vLimitOld($chan) $target
return 0
}
# eof
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]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: 31337Code: 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]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!!Code: Select all
regexp -- {\+[^\-]+k?l([\s].+)? ([0-9]+)} [getchanmode $chan] -> key limit
Code: Select all
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