Code: Select all
set yourfloodflag "o|o"
set yourfloodfile "news.txt"
if { [file exists $yourfloodfile] } {
set fd [open $yourfloodfile r]
gets $fd yourflood
close $fd
} else {
close [open $yourfloodfile w]
}
bind evnt - save yourfloodsave
bind time - "00 00 *" yourfloodday
bind mkch - "*" yourfloodnkch
proc yourproc { ... } {
...
if { $hand == "*" && ![matchattr $hand $::yourfloodflag $chan] } {
if { [set line [lsearch -glob $::yourflood "all *"]] == -1 } {
lappend ::yourflood [list all 1 0 0 0 0 0 0]
} elseif { [expr [lindex [set entry [lindex $::yourflood $line]] 1] + [lindex $entry 2] + [lindex $entry 3] + [lindex $entry 4] + [lindex $entry 5] + [lindex $entry 6] + [lindex $entry 7]] >= 21 } {
puthelp "NOTICE $nick :Your weekly limit has been reached!"
return 0
} else {
set ::yourflood [lreplace $::yourflood $line $line [lreplace $entry 1 1 [expr [lindex $entry 1] + 1]]
}
} else {
if { [set line [lsearch -glob $::yourflood "$hand *"]] == -1 } {
lappend ::yourflood [list $hand 1 0 0 0 0 0 0]
} elseif { [expr [lindex [set entry [lindex $::yourflood $line]] 1] + [lindex $entry 2] + [lindex $entry 3] + [lindex $entry 4] + [lindex $entry 5] + [lindex $entry 6] + [lindex $entry 7]] >= 11 } {
puthelp "NOTICE $nick :Your weekly limit has been reached!"
return 0
} else {
set ::yourflood [lreplace $::yourflood $line $line [lreplace $entry 1 1 [expr [lindex $entry 1] + 1]]
}
}
...
}
proc yourfloodday {min h d m y} {
global yourflood
set i 0
foreach line $yourflood {
set linsert $line 1 "0"
set line [lreplace $line e e]
set yourflood [lreplace $yourflood $i $i $line]
incr i
}
}
proc yourfloodnkch {old new} {
if { [set line [lsearch -glob $::yourflood "$old *"]] != -1 } {
set ::yourflood [lreplace $::yourflood $line $line [lreplace [lindex $::yourflood $line] 0 0 [split $new]]]
}
return 0
}
proc yourfloodsave {type} {
set fd [open $::yourfloodfile w]
puts -nonewline $::yourflood
close $fd
return 0
}but how would it check for dates..? as in num/week. can't imagine this is possible.gb wrote:you could save the info to the XTRA field in the userlist, that way you get away with alot less code. (assuming only known users can execute commands.)
Code: Select all
bind time - "00 00 *" whatdayisit
proc whatdayisit {mi hr da mo yr} {
if {[strftime %a]=="Mon"} {
foreach u [userlist -b] {
setuser $u XTRA count 0
}
}
}