set dbfile "scripts/database.txt"
bind pub - !blg aleatory
proc aleatory {nick uhost hand chan arg} {
global dbfile
set r [lindex [set d [split [read [set f [open $dbfile]]] \n]] [rand [llength $d]]]
puthelp "PRIVMSG $chan :$r $nick"
close $f
}
putlog "blg loaded"
possible to add protection flood?
expl:
user> !blg
bot> blabla
user> !blg
bot> blabla
user> !blg
bot> blabla
user> !blg
the bot say /notice user you have been ignoring for 1 mns and set ignore user for 1 mns
...
variable pcount; variable pubflud
if {[info exists pcount]} {
set n [lindex $pcount 1]; incr n
set ts [lindex $pcount 0]
set pcount [list $ts $n]
scan $pubflud {%[^:]:%s} maxr maxt
if {$n >= $maxr} {
if {[unixtime] - $ts <= $maxt} {return}
set n 1; set ts [unixtime]
}
} {
set n 1; set ts [unixtime]
}
set pcount [list $ts $n]
...
this thing will ignore any command requests beyond M:N (at most M requests in N seconds), set in the global variable pubflood (of course, you need to replace variable with global since you don't use namespaces)
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use