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 

script help and optimization help please

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


Joined: 15 Oct 2011
Posts: 7

PostPosted: Thu Oct 20, 2011 12:42 am    Post subject: script help and optimization help please Reply with quote

need a little help and optimization help please

i couldnt find a script to do this so i gave it a shot and tried to make one myself

what i want the script to do is count the number of excess floods a user does and temp ban after 3 in less then a minute
my script does this but i cant seem to make it include the channel and evaluate the channel on the count tried a few things but they havent worked out

my script works but if the users on multiple channels they get combined in the count

heres my hacked up code that works except for parsing channel in checks
Code:

#xs_flood.tcl

bind sign - * xs_flood
set xs_bantime 3

bind pub - .xs xs_flood

proc xs_flood {nick uhost hand chan arg} {
global xs_bantime xs_flooder
    if {![botisop $chan]} { return 0 }
    if {[string equal "Excess Flood" $arg]} {
    if {![info exists xs_flooder]} {
    set xs_flooder 0
    } else {
    incr xs_flooder
    putlog "xs_flooder = $nick $chan Flood count $xs_flooder"
    timer 1 "set xs_flooder 0"
    }
    if {$xs_flooder >= 3} {
    puthelp "PRIVMSG $chan :Temp Ban $nick $xs_bantime Min XS-Flood"
    putserv "MODE $chan +b *!$uhost"
    timer $xs_bantime "pushmode $chan -b *!$uhost"
    puthelp "PRIVMSG $nick :Temp Ban $xs_bantime Min on $chan XS-Flood"
    putlog "Temp Ban $xs_bantime Min $nick *!$uhost on $chan XS-Flood"
    timer 1 "set xs_flooder 0"
  return 0
  }
 }
}

putlog "XS-Flood Loaded Bantime $xs_bantime Min RaT"

tia for your help
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Thu Oct 20, 2011 4:50 am    Post subject: Reply with quote

I see your problem. You would have to somehow employ an array variable to keep track of the flood on a per channel basis xs_flooder($chan).

This script does such a thing to restrict channel access when a PART flood occurs WITH part messages. You may be able to adapt it.

Code:

# part.tcl
# profers channel protection for mass parts with part message

### ....................................................................... ###
### .......... configuration (edit as required) ........................... ###

# set here the bot channels you want part flood protection in
set vPartChannels "#channel1 #channel2"

# set here the number of parts in how many seconds for the script to react
set vPartLimit 4:8

# set here the channel throttle (joins per seconds) when channel is restricted
set vPartJoins 3:3

# set here the time in minutes for the channel to remain restricted
set vPartTime 5

# set here the modes to set to restrict channel (excluding throttle mode j)
set vPartModes mMR

### ....................................................................... ###
### .......... code (do not edit) ......................................... ###

set vPartChannels [split [string tolower $vPartChannels]]
scan $vPartLimit {%d:%d} vPartNumber vPartSeconds

bind PART - * pPartBind

proc pPartBind {nick uhost hand chan msg} {
    global vPartActive vPartChannels vPartData vPartJoins vPartModes vPartNumber vPartSeconds vPartTime
    if {[lsearch -exact $vPartChannels [string tolower $chan]] != -1} {
        if {![info exists vPartActive($chan)]} {set vPartActive($chan) 0}
        if {!$vPartActive($chan)} {
            if {[string length $msg] != 0} {
                lappend vPartData($chan) [clock seconds]
                set vPartData($chan) [lrange $vPartData($chan) end-[expr {$vPartNumber - 1}] end]
                if {[llength $vPartData($chan)] == $vPartNumber} {
                    set period [expr {[lindex $vPartData($chan) end] - [lindex $vPartData($chan) 0]}]
                    if {$period <= $vPartSeconds} {
                        set vPartActive($chan) 1
                        putquick "MODE $chan +${vPartModes}j $vPartJoins"
                        timer $vPartTime [list pPartCancel $chan]
                    }
                }
            }
        }
    }
    return 0
}

proc pPartCancel {chan} {
    global vPartActive vPartModes
    set vPartActive($chan) 0
    putquick "MODE $chan -${vPartModes}j"
    return 0
}

# eof

_________________
I must have had nothing to do
Back to top
View user's profile Send private message
BillTech
Voice


Joined: 15 Oct 2011
Posts: 7

PostPosted: Thu Oct 20, 2011 5:56 am    Post subject: Reply with quote

thanks for the responce still a lil bit over my head
i have tried xs_flooder($chan) i think i get an array error i couldnt track
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Thu Oct 20, 2011 8:45 am    Post subject: Reply with quote

Sorry, I didn't mean to imply that simply changing xs_flooder to xs_flooder($chan) would suffice.

I was generalising when pointing the way to using an array variable rather than a normal scalar variable to store information in a per channel way. There would be one array element per channel you wished the code to function in.

What I perhaps failed to explain is that this would inevitably require other changes in the code.

As far as I can see, there is also nothing in your code to indicate which nick has previously done the flooding. The variable xs_flooder is simply incremented, resulting in the last nick to contribute getting banned.

To correct this, you would have to emulate a two dimensional array. Say something like xs_flooder($uhost,$chan). My code doesn't require this because I don't ban a user, rather I regulate a channel.

In any event I would advise that what you are trying to do is somewhat more difficult than your original code.
_________________
I must have had nothing to do
Back to top
View user's profile Send private message
BillTech
Voice


Joined: 15 Oct 2011
Posts: 7

PostPosted: Fri Oct 21, 2011 12:49 am    Post subject: Reply with quote

think i got it
also seems i was having a issue with the _ in some of the variables
Back to top
View user's profile Send private message
BillTech
Voice


Joined: 15 Oct 2011
Posts: 7

PostPosted: Fri Oct 21, 2011 5:29 pm    Post subject: Reply with quote

heres what i have so far seems to work as needed

bind sign - * xs:flood
set xsbantime 3

bind pub - .xs xs:flood

proc xs:flood {nick uhost hand chan arg} {
global xsbantime xsflooder
if {![botisop $chan]} { return 0 }
if {![string equal "Excess Flood" $arg]} { return 0 }
if {![info exists xsflooder($chan:$uhost)]} {
set xsflooder($chan:$uhost) 1
putlog "No Info - $nick $chan Flood Count $xsflooder($chan:$uhost)"
utimer 30 "set xsflooder($chan:$uhost) 0"
} else {
incr xsflooder($chan:$uhost)
putlog "Add Flood Count - $nick $chan Flood Count $xsflooder($chan:$uhost)"
utimer 30 "set xsflooder($chan:$uhost) 0"
}
if {$xsflooder($chan:$uhost) >= 3} {
puthelp "PRIVMSG $chan :Temp Ban $nick $xsbantime Min XS-Flood"
putserv "MODE $chan +b *!$uhost"
timer $xsbantime "pushmode $chan -b *!$uhost"
puthelp "PRIVMSG $nick :Temp Ban $xsbantime Min on $chan XS-Flood"
putlog "Temp Ban $xsbantime Min $nick *!$uhost on $chan XS-Flood"
set xsflooder($chan:$uhost) 0"
putlog "Reset - $nick $chan Flood Count $xsflooder($chan:$uhost)"
}
}
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