egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

protect flood

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
pilouuu
Halfop


Joined: 26 Dec 2005
Posts: 82

PostPosted: Mon Jan 16, 2006 11:44 pm    Post subject: protect flood Reply with quote

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
View user's profile Send private message
pilouuu
Halfop


Joined: 26 Dec 2005
Posts: 82

PostPosted: Mon Jan 16, 2006 11:51 pm    Post subject: Reply with quote

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 Very Happy i am lost after Smile error
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Jan 17, 2006 12:15 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
pilouuu
Halfop


Joined: 26 Dec 2005
Posts: 82

PostPosted: Tue Jan 17, 2006 12:42 am    Post subject: Reply with quote

ok thx my variable

set pubflud 5:30

it good?
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Jan 17, 2006 12:43 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
pilouuu
Halfop


Joined: 26 Dec 2005
Posts: 82

PostPosted: Tue Jan 17, 2006 12:55 am    Post subject: Reply with quote

lol the proc is good Smile lol Smile thx demond Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber