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 

Flood proc, Consecutive trigger

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


Joined: 22 May 2005
Posts: 15

PostPosted: Mon Dec 26, 2005 4:33 pm    Post subject: Flood proc, Consecutive trigger Reply with quote

hi demond, u asked me to post it here.

Here is a sample flood proc which triggers for only consecutive joins of unresolved idents. I'm interested to make this an universal consecutive detection type proc. So that the same proc is used for different types of consecutive join patterns. Guide me to make it more advanced, faster, dynamic and also with out using timers.

Code:

# Consecutive Unresolved Host Flood x(joins):y(secs)
# ~blah@example.net, ~swooozy@ex.net.com , ~whoreee@me.tk.in

set uh 2:2

proc unresolved:flood {n u h c} {
  global fldmr uh urhf curhf
  # uh = x:y ; urhf = unresolved host flood ; curh = consecutive urhf

  if {(![botisop $c]) || ([matchattr $h of|of])} {return}
  if {![info exists fldmr($c)]} {set fldmr($c) 0}
  # This is to check if the channel is already locked (+MR)

  scan $u %\[^@\]@%s ident host
  set urh [string match "~*" "$ident"]

  if {($urh == 0)||([string match "Guest?????" "$n"])} {
  # if the idents are resolved or if the nick is guest, set curhf var to 0
  # curhf is used to incr the main flood join times, if {curfh >= y(secs)}
 
    set curhf($c) 0
    } else {

    if {![info exists urhf($c)]} {set urhf($c) ""}

    if {$urh == $urhf($c)} {
    # if urh == temp urhf, this the actual consecutive check procedure
    # if urh != temp urhf, then it will "set urhf($c) $urh"
      incr curhf($c)
      utimer [lindex [split $uh :] 1] [list curhf:dec $c]

      if {$curhf($c) >= [lindex [split $uh :] 0]} {

        if {$fldmr($c) == "0"} {
          putquick "MODE $c +MR-k unresolved.host.flood" -next
          utimer 60 [list flood:unlock $c]
          set fldmr($c) 1
          return 0
        }

      }
      } else {
      set urhf($c) $urh
      set curhf($c) 1
      utimer [lindex [split $uh :] 1] [list curhf:dec $c]
    }
  }
}

proc curhf:dec {c} {
  global curhf
  incr curhf($c) -1
  if {$curhf($c) < 0} {set curhf($c) 0}
  return 0
}
proc flood:unlock {chan} {
  global fldmr
  set cmode [getchanmode $chan]
  set fldmr($chan) 0
  if {[string match "*R*M*" "$cmode"]} {putserv "MODE $chan -MR" ; return 0}
  if {[string match "*M*" "$cmode"]} {putserv "MODE $chan -M" ; return 0}
  if {[string match "*R*" "$cmode"]} {putserv "MODE $chan -R" ; return 0}
  return 0
}

foreach t [utimers] {
  if {[lindex $t 1] == "flood:unlock"} {killutimer [lindex $t end]}
  if {[lindex $t 1] == "curhf:dec"} {killutimer [lindex $t end]}
}

set chans [channels]
set chans [split [string tolower $chans]]
foreach c $chans {
  set fldmr($c) 0

  set urhf($c) ""
  set curhf($c) 0
}

Quote:

Wanna make it universal proc (consecutive match pattern) (i.e)
proc flood:proc {description $chan x_times in_y_secs} {...}



These are some sample logs: (description)
% alphanumeric host flood
% unresolved ident/host flood
% alphanumeric nick flood

[25/12 02:53:58] • (JOINS) Nova29 (~pHRDhIBn@36.Red-80-39-227.dynamicIP.rima-tde.net)
[25/12 02:53:59] • (JOINS) Nora29 ( ~XqUIhtgs@tvn95-1-82-229-101-13.fbx.proxad.net)
[25/12 02:53:59] • Skipper sets mode: +MR-k alphanumeric.host.flood
---
[25/12 03:27:31] • (JOINS) tary921 (~j4n867074@12.144.115.136)
[25/12 03:27:31] • (JOINS) fjil0r (~r62s6332@209.161.218.85 )
[25/12 03:27:31] • (JOINS) uuvn378- (~h23c04614@208.164.114.85)
[25/12 03:27:31] • Skipper sets mode: +MR-k unresolved.host.flood
[25/12 03:27:31] • (JOINS) eoys318 ( ~c1u88uu1n@12.144.115.136)
[25/12 03:27:32] • (JOINS) mmoj505 (~m4186388p@61.244.116.229)
[25/12 03:27:31] • (JOINS) xdanyie ( ~eg7988gt4@12.144.115.136)
---
[25/12 03:35:21] • (JOINS) Pa|nT (~Nazim@as13-143.qualitynet.net)
[25/12 03:35:22] • (JOINS) pinky4 (pinky4@ip70-190-9-16.ph.ph.cox.net )
[25/12 03:35:23] • Skipper sets mode: +MR-k alphanumeric.host.flood
---
[25/12 07:15:19] • (JOINS) Pando-987 (~xgron-@af14-173.qualitynet.net)
[25/12 07:15:19] • (JOINS) pi-nky42 (pinky4@12.144.116.200 )
[25/12 07:15:20] • Skipper sets mode: +MR-k alphanumeric.nick.flood
Back to top
View user's profile Send private message
demond
Revered One


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

PostPosted: Mon Dec 26, 2005 7:31 pm    Post subject: Reply with quote

Alchera might beat me up for this, but nevertheless:

the best example I know of for proc re-use and generally clean, elegant, simple yet functional script design is xchannel

it does exactly what you need: handles more different flood types with less procs
_________________
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
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