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
}
just wrote the idea down, haven't had the time to debug it yet.
you maybe replace any varnames or proc names, but replace them ALL then
.
the part between ... should be inserted just before the news are actually created. If you add "yourflood" to the global var list, remove the leading :: from it. The flood should be saved for each day in a week and reset daily. The save to file is done when a save is initiated from the bot (so just before it rehashes, restarts, quits) and load it after it again.
NOTE: the script within ... assumes the nickname is stored in "nick" and the handle is stored in "hand", change it if your script uses diffrent var names! You should not have a user called "all" with the flag (case should matter).