(*) Changed timer to utimer
(*) Added bind and proc for on join delay limit change for large channels
Code: Select all
##############################
## ------------------------ ##
## 10. Channel Limit Script ##
## ------------------------ ##
##############################
#Channels in which to activate limiting, this should be a list like
#"#elephants #wildlife #etc". Leave it set to "" if you wish to activate
#limiting on all channels the bot is on.
set cl_chans "#awyeah"
#Limit to set (number of users on the channel + this setting)
set cl_limit "5"
#Limit grace (if the limit doesn't need to be changed by more than this,
#don't bother setting a new limit)
set cl_grace "2"
# Frequency of checking whether a new limit needs to be set (in seconds)
set cl_utimer "8"
bind join - "*" limit:chng:on:bot:join
proc limit:chng:on:bot:join {nick uhost hand chan} {
global cl_chans limit_delay
if {[isbotnick $nick] && ([lsearch -exact [split [string tolower $cl_chans]] [string tolower $chan]] != -1)} {
set limit_delay([string tolower $chan]) 1
utimer 3 [list unset limit_delay([string tolower $chan])]
}
}
proc cl_dolimit {} {
global cl_chans cl_limit cl_grace cl_utimer limit_delay
utimer $cl_utimer cl_dolimit
foreach chan [string tolower [channels]] {
if {$cl_chans != ""} {
if {([lsearch -exact [split [string tolower $cl_chans]] [string tolower $chan]] == -1)} { continue }
}
if {[info exists limit_delay($chan)]} { continue }
if {![botisop $chan]} { continue }
set numusers [llength [chanlist $chan]]
set newlimit [expr $numusers + $cl_limit]
if {[string match "*l*" [lindex [getchanmode $chan] 0]]} {
set currlimit [string range [getchanmode $chan] [expr [string last " " [getchanmode $chan]] + 1] end]
} else {
set currlimit 0
}
if {$newlimit == $currlimit} { continue }
if {$newlimit > $currlimit} {
set difference [expr $newlimit - $currlimit]
} elseif {$currlimit > $newlimit} {
set difference [expr $currlimit - $newlimit]
}
if {$difference <= $cl_grace} { continue }
putquick "MODE $chan +l $newlimit" -next
}
}
proc cl_startlimit {} {
global cl_utimer
if {[string match "*cl_dolimit*" [utimers]]} { return 0 }
utimer $cl_utimer cl_dolimit
}
cl_startlimit