View previous topic :: View next topic |
Author |
Message |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Mon Mar 23, 2015 6:58 pm Post subject: |
|
|
error is gone but still no effect |
|
Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3767 Location: Mint Factory
|
Posted: Tue Mar 24, 2015 3:02 am Post subject: |
|
|
Alright, corrected a few typos and rookie mistakes I've made in previous code. Now you need to get on DCC Chat to enable this for each individual channel with .chanset #channel +hashCheck
As always, haven't tested anything so report back if you get any issues.
Code: |
namespace eval hashCheck {
setudef flag hashCheck
bind pubm - * [namespace current]::hashCheck
set setup [dict create limit 3 time 10]
proc hashCheck {nick uhost hand chan text} {
if {![channel get $chan hashCheck]} return
variable setup
variable md5hashes
set hash [md5 [split $text]]
if {[info exists md5hashes]} {
if {[lsearch [dict keys [dict get $md5hashes $chan] $hash] != -1} {
set hosts [dict get $md5hashes $chan $hash]
if {[llength $hosts] > [dict get $setup limit]} {
hashPunish $chan $hosts
dict unset md5hashes $chan $hash
} else {
dict set md5hashes $chan $hash [list [dict get $md5hashes $chan $hash] $uhost]
utimer [dict get $setup time] [list [namespace current]::hashPurge $chan $hash $uhost]
}
}
} else {
dict set md5hashes $chan $hash $uhost
}
}
proc hashPurge {chan hash uhost} {
variable md5hashes
set hosts [dict get $md5hashes $chan $hash]
set pos [lsearch -nocase $hosts $uhost]
if {$pos!=-1} {
set hosts [lreplace $hosts $pos $pos]
dict set md5hashes $chan $hash $hosts
}
foreach key [dict keys [dict get $md5hashes $chan]] {
if {![llength [dict get $md5hashes $chan $key]]} {
dict unset md5hashes $chan $key
}
}
}
}
|
From here onwards will extend it to remove hashes upon kick, ban, quit, part, and so on. For now want to see if this is working or not.
Edit: Fixed typo. _________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Tue Mar 24, 2015 7:03 am; edited 1 time in total |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Tue Mar 24, 2015 4:28 am Post subject: |
|
|
after replacing it with your latest code it gives me this error
Quote: |
09:26:36 <SeCuRiTy> [04:13:44] Tcl error [::hashCheck::hashCheck]: missing close-bracket
09:26:36 <SeCuRiTy> in expression "[lsearch [dict keys [di..."
|
|
|
Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3767 Location: Mint Factory
|
Posted: Tue Mar 24, 2015 7:01 am Post subject: |
|
|
Replace:
Code: |
if {[lsearch [dict keys [dict get $md5hashes $chan]] $hash != -1} {
|
with:
Code: |
if {[lsearch [dict keys [dict get $md5hashes $clan]] $hash] != -1} {
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Tue Mar 24, 2015 7:06 am Post subject: |
|
|
after doing that it still doesnt trigger error is gone tho |
|
Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3767 Location: Mint Factory
|
Posted: Tue Mar 24, 2015 8:09 am Post subject: |
|
|
Got a testing bot up and running and realized that this isn't going to won't work as I hoped and found a couple of issues I'll try to correct. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Tue Mar 24, 2015 9:43 am Post subject: |
|
|
ok sir all your efforts are much apreciated |
|
Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 826 Location: Tennessee, USA
|
Posted: Wed Mar 25, 2015 12:05 am Post subject: |
|
|
Her ya go, untested, good luck, let me know:) Code: |
# multi-host-repeat.tcl v1.0 by SpiKe^^, closely based on
# repeat.tcl v1.1 (9 April 1999) by slennox <slenny@ozemail.com.au>
# Repeat flood, kick-ban on repeats:seconds #
set rp_bflood 5:60
# Repeat flood kick-ban reason #
set rp_breason "repeat flood"
# Length of time in minutes to ban Repeat flooders #
set rp_btime 60
# After a valid Repeat flood, script will continue to #
# kick-ban offenders for an additional 'x' seconds #
set rp_blinger 10
# END OF SETTINGS # Don't edit below unless you know what you're doing #
bind pubm - * rp_pubmsg
set rp_bflood [split $rp_bflood :]
proc rp_pubmsg {nick uhost hand chan text} {
global rp_bcount rp_bflood rp_breason rp_btime rp_blinger
set uhost [string tolower $nick!$uhost]
set chan [string tolower $chan]
set text [string map [list \017 ""] [stripcodes abcgru $text]]
set text [string tolower $text]
if {[isbotnick $nick]} { return 0 }
if {[matchattr $hand f|f $chan]} { return 0 }
set utnow [unixtime]
set target [lindex $rp_bflood 0]
if {[info exists rp_bcount($chan:$text)]} {
set uhlist [lassign $rp_bcount($chan:$text) cnt ut]
set utend [expr {$ut + [lindex $rp_bflood 1]}]
set expire [expr {$utend + $rp_blinger}]
if {$cnt < $target} {
if {$utnow > $utend} { unset rp_bcount($chan:$text) }
} elseif {$utnow > $expire} { unset rp_bcount($chan:$text) }
}
if {![info exists rp_bcount($chan:$text)]} {
set rp_bcount($chan:$text) [list 1 $utnow $uhost]
return 0
}
if {$utnow <= $utend} {
incr cnt
if {[lsearch $uhlist $uhost] == "-1"} { lappend uhlist $uhost }
set rp_bcount($chan:$text) [linsert $uhlist 0 $cnt $ut]
if {$cnt < $target} { return 0 }
if {$cnt == $target} { rp_dobans $chan $uhlist
} else { rp_dobans $chan [list $uhost] }
} elseif {$cnt >= $target} { rp_dobans $chan [list $uhost] }
return 0
}
proc rp_dobans {chan uhlist} {
global rp_breason rp_btime
set hslist ""
foreach uhost $uhlist {
foreach {nk un hs} [split $uhost !@] { break }
if {[botisop $chan] && [onchan $nk $chan]} {
putserv "KICK $chan $nk :$rp_breason"
}
if {[lsearch $hslist $hs] == "-1"} {
newchanban $chan *!*@$hs multi-host-repeat $rp_breason $rp_btime
lappend hslist $hs
}
}
}
proc rp_breset {} {
global rp_bcount rp_bflood rp_blinger
set utnow [unixtime]
set target [lindex $rp_bflood 0]
foreach {key val} [array get rp_bcount] {
lassign $val cnt ut
set utend [expr {$ut + [lindex $rp_bflood 1]}]
set expire [expr {$utend + $rp_blinger}]
if {$cnt < $target} {
if {$utnow > $utend} { unset rp_bcount($key) }
} elseif {$utnow > $expire} { unset rp_bcount($key) }
}
utimer 30 [list rp_breset]
}
if {![info exists rp_running]} {
utimer 30 [list rp_breset]
set rp_running 1
}
putlog "Loaded multi-host-repeat.tcl v1.0 by SpiKe^^"
|
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Wed Mar 25, 2015 4:06 am Post subject: |
|
|
it works excellent except it doesn't kick ban instant it takes time for it to ban and kick all text repeating flooding bots i would rather see it ban and kick instant and push as much mode settings in 1 line as possible other than that is works nicely good job sir |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Wed Mar 25, 2015 4:10 am Post subject: |
|
|
oh i forgot to mention i also would like it not to stickban just regular ban so the channel ops can remove if they see fit
tnx |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Wed Mar 25, 2015 4:34 am Post subject: |
|
|
this is what i have so far seems to work only it doesnt compress ban modes it does each ban seperate also when this type of flood accures how would we integrate for it also to lock channel for set amount of time
Code: |
# multi-host-repeat.tcl v1.0 by SpiKe^^, closely based on
# repeat.tcl v1.1 (9 April 1999) by slennox <slenny@ozemail.com.au>
# Repeat flood, kick-ban on repeats:seconds #
set rp_bflood 2:10
# Repeat flood kick-ban reason #
set rp_breason "repeat flood"
# Length of time in minutes to ban Repeat flooders #
set rp_btime 1
# After a valid Repeat flood, script will continue to #
# kick-ban offenders for an additional 'x' seconds #
set rp_blinger 10
# END OF SETTINGS # Don't edit below unless you know what you're doing #
bind pubm - * rp_pubmsg
set rp_bflood [split $rp_bflood :]
proc rp_pubmsg {nick uhost hand chan text} {
global rp_bcount rp_bflood rp_breason rp_btime rp_blinger
set uhost [string tolower $nick!$uhost]
set chan [string tolower $chan]
set text [string map [list \017 ""] [stripcodes abcgru $text]]
set text [string tolower $text]
if {[isbotnick $nick]} { return 0 }
if {[matchattr $hand f|f $chan]} { return 0 }
set utnow [unixtime]
set target [lindex $rp_bflood 0]
if {[info exists rp_bcount($chan:$text)]} {
set uhlist [lassign $rp_bcount($chan:$text) cnt ut]
set utend [expr {$ut + [lindex $rp_bflood 1]}]
set expire [expr {$utend + $rp_blinger}]
if {$cnt < $target} {
if {$utnow > $utend} { unset rp_bcount($chan:$text) }
} elseif {$utnow > $expire} { unset rp_bcount($chan:$text) }
}
if {![info exists rp_bcount($chan:$text)]} {
set rp_bcount($chan:$text) [list 1 $utnow $uhost]
return 0
}
if {$utnow <= $utend} {
incr cnt
if {[lsearch $uhlist $uhost] == "-1"} { lappend uhlist $uhost }
set rp_bcount($chan:$text) [linsert $uhlist 0 $cnt $ut]
if {$cnt < $target} { return 0 }
if {$cnt == $target} { rp_dobans $chan $uhlist
} else { rp_dobans $chan [list $uhost] }
} elseif {$cnt >= $target} { rp_dobans $chan [list $uhost] }
return 0
}
proc rp_dobans {chan uhlist} {
global rp_breason rp_btime
set hslist ""
foreach uhost $uhlist {
foreach {nk un hs} [split $uhost !@] { break }
if {[botisop $chan] && [onchan $nk $chan]} {
putserv "KICK $chan $nk :$rp_breason"
}
if {[lsearch $hslist $hs] == "-1"} {
putquick "MODE $chan +b *!*@$hs"
# newchanban $chan *!*@$hs multi-host-repeat $rp_breason $rp_btime
lappend hslist $hs
}
}
}
proc rp_breset {} {
global rp_bcount rp_bflood rp_blinger
set utnow [unixtime]
set target [lindex $rp_bflood 0]
foreach {key val} [array get rp_bcount] {
lassign $val cnt ut
set utend [expr {$ut + [lindex $rp_bflood 1]}]
set expire [expr {$utend + $rp_blinger}]
if {$cnt < $target} {
if {$utnow > $utend} { unset rp_bcount($key) }
} elseif {$utnow > $expire} { unset rp_bcount($key) }
}
utimer 30 [list rp_breset]
}
if {![info exists rp_running]} {
utimer 30 [list rp_breset]
set rp_running 1
}
putlog "Loaded multi-host-repeat.tcl v1.0 by SpiKe^^" |
|
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Wed Mar 25, 2015 4:44 am Post subject: |
|
|
i noticed it kicks first then it bans i would like it to see set ban first so they wont get choice to quik rejoin |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Wed Mar 25, 2015 6:22 am Post subject: |
|
|
also i noticed it doesnt excempt halfop and above from beeing effected |
|
Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3767 Location: Mint Factory
|
Posted: Wed Mar 25, 2015 6:24 am Post subject: |
|
|
Ahh, I see SpiKe beat me to the punch.
To be honest I would stick with hashing the texts rather than having to strip them out and so on.
You should take out
Code: |
# if the bot isn't OP then no point into continuing
if {[botisop $chan] && [onchan $nk $chan]} {
putserv "KICK $chan $nk :$rp_breason"
}
|
from the foreach loop. As for multiple kicks/bans in a single line I think this should do it.
Code: |
proc rp_dobans {chan uhlist} {
# if the bot isn't OP there's no point to continue
if {![botisop $chan]} return
set blist ""
set klist ""
# loop through uhosts
foreach uhost $uhlist {
# filter out any duplicates
if {[lsearch $blist $uhost] != -1} continue
# set the ban mask as you want
scan $uhost {%[^@]@%s} user host
# save the list with masks to ban
lappend blist "*!*@$host"
# save the list with masks to get nicks from later on cos we will destroy the $blist
lappend klist $uhost
}
# push 6 ban masks (or change to match how many bans per line the server you are on allows) at a time until the list is empty
while {[llength $blist] != 0} {
puthelp "MODE $chan +bbbbbb [join [lrange $blist 0 6] " "]"
set blist [lrange $blist 6 end]
}
# from the given uhosts we ban make a list of nicks to kick and again filter out duplicates
set nlist ""
set userlist [lreplace [chanlist $chan] 0 0]
foreach u [split $userlist] {
set uhost [getchanhost $user $chan]
scan $uhost {%[^@]@%s} user host
if {[lsearch $klist $uhost] != -1} continue
lappend nlist $u
}
# use putkick to do 6 kicks per a single line sent to server
while {[llength $nlist] != 0} {
putkick $chan [join [lrange $nlist 0 6] ","] "repeat flood"
set nlist [lrange $nlist 6 end]
}
}
|
Haven't tested anything.
Edit: Fixed missing variable. _________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Wed Mar 25, 2015 9:04 am; edited 1 time in total |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1027
|
Posted: Wed Mar 25, 2015 8:20 am Post subject: |
|
|
after changint that i get this error
Quote: |
13:18:42 <SeCuRiTy> [08:05:48] Tcl error [rp_pubmsg]: illegal channel: ChanServ,AmaziGH,Lilli,Avila,Orourke,Rima,Oglesby |
|
|
Back to top |
|
 |
|