| View previous topic :: View next topic |
| Author |
Message |
pilouuu Halfop
Joined: 26 Dec 2005 Posts: 82
|
Posted: Mon Jan 16, 2006 11:44 pm Post subject: protect flood |
|
|
hi
| Code: | 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
thx |
|
| Back to top |
|
 |
pilouuu Halfop
Joined: 26 Dec 2005 Posts: 82
|
Posted: Mon Jan 16, 2006 11:51 pm Post subject: |
|
|
| Code: | # database
set dbfile "scripts/database.txt"
# bind
bind pub - !blg aleatory
# set flood
set fun(flood) 5:30
# Ignorer users after flood (0=no, 1=yes) :
set fun(ignore) 1
# Yes?,tine mns :
set fun(ignoretime) 1
# flags protect:
set fun(ignflags) "fmnov|fmnov"
proc fun:flood:init {} {
global fun funflood
set fun(floodnum) [lindex [split $fun(flood) :] 0]
set fun(floodtime) [lindex [split $fun(flood) :] 1]
set i [expr $fun(floodnum) - 1]
while {$i >= 0} {
set funflood($i) 0
incr i -1
}
}
fun:flood:init
proc fun:flood {nick uhost} {
global fun funflood botnick
if {$fun(floodnum) == 0} {
return 0
}
set i [expr $fun(floodnum) - 1]
while {$i >= 1} {
set funflood($i) $funflood([expr $i - 1])
incr i -1
}
set funflood(0) [unixtime]
if {[expr [unixtime] - $funflood([expr $fun(floodnum) - 1])] <= $fun(floodtime)} {
if {$fun(ignore)} {
newignore [join [maskhost *!*[string trimleft $uhost ~]]] $botnick "Flood" $fun(ignoretime)
}
return 1
} {
return 0
}
}
proc aleatory {nick uhost hand chan arg} {
if ![matchattr $nick $fun(ignflags) $channel] {
if {[fun:flood $nick $uhost]} {
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" |
help me please i am lost after error |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Tue Jan 17, 2006 12:15 am Post subject: |
|
|
here's how to do that (code from my rssnews script) inside your public cmd proc:
| Code: |
...
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 [code] tag when posting logs, code |
|
| Back to top |
|
 |
pilouuu Halfop
Joined: 26 Dec 2005 Posts: 82
|
Posted: Tue Jan 17, 2006 12:42 am Post subject: |
|
|
ok thx my variable
set pubflud 5:30
it good? |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Tue Jan 17, 2006 12:43 am Post subject: |
|
|
noone could possibly know that but you _________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
pilouuu Halfop
Joined: 26 Dec 2005 Posts: 82
|
Posted: Tue Jan 17, 2006 12:55 am Post subject: |
|
|
lol the proc is good lol thx demond  |
|
| Back to top |
|
 |
|