| View previous topic :: View next topic |
| Author |
Message |
avatar132 Voice
Joined: 17 Dec 2005 Posts: 21
|
Posted: Sat Feb 04, 2006 1:24 pm Post subject: need help error for badchan script |
|
|
hi, i have badchan 1.0 by Bass and modified it to work with x, now i get errors and it for some reason doesnt let me exempt any hostmasks or channels like it was made to do. Any suggestions or fixes for the script would be great, thanks!
| Code: | [12:15pm] <CrystalX> [11:15] Tcl error in script for 'timer762':
[12:15pm] <CrystalX> [11:15] can't unset "bcqueue(r13-111.intnet.mu)": no such element in array |
here is the script in full:
| Code: | badchan 1.0 by Bass of Undernet's #eggdrop (bass@tclslave.net)
#
#This is a basic 'badchan' script to auto-ban ppl who are on other chans deemed 'bad'
#People are scanned on-join.
#
#Public commands:
#!gbclist --lists the contents of the Global BadChan list
#!bclist --lists the contents of the BadChan list for the current channel
#!gabc <mask> <reason> --adds an item to the Global BadChan list
#!grbc <mask> --removes an item from the Global BadChan list
#!abc <mask> <reason> --adds an item to the BadChan list for the current channel
#!rbc <mask> --removes an item from the BadChan list for the current channel
#
#eg: !abc *sex* No sex chans!
#
#Users need n|- to change the global settings.
#Users need o|o to change the channel settings.
#
#The script keeps a copy of the list in a file so that it can be reloaded
# the next time the bot is restarted.
if {[info exists bchan]} {unset bchan}
#minutes to wait before rescanning (so a join-part flood won't hurt)
set bchan(rescan) 2
#same as other flood-prot setting.
set bc_flood 3:10
#'ignored' channels. no scanning is done.
set bchan(exempt) "#mychannel"
#protected masks:
set bchan(protect-hosts) {
*!*@User1.users.undernet.org
*!*@User2.users.undernet.org
*!*@User3.users.undernet.org
}
### END OF CONFIG OPTIONS ###
if {[info exists bcqueue]} {unset bcqueue}
set bchan(chans) ""
proc bmaskhost {uhost} {
set uhost [lindex [split $uhost !] [expr [llength [split $uhost !]] -1]]
set temp [string range [lindex [split $uhost @] 0] [expr [string length [lindex [split $uhost @] 0]] - 8] e]
return "*!*$temp@[lindex [split [maskhost *!*@[lindex [split $uhost @] 1]] @] 1]"
}
proc bchan_read {} {
global bchan
set fd [open scripts/badchan.conf r]
while {![eof $fd]} {
set inp [gets $fd]
if {[string trim $inp " "] == ""} {continue}
set ban [lrange $inp 1 e]
set chan [string tolower [lindex $inp 0]]
if {[lsearch $bchan(chans) $chan] == -1} {lappend bchan(chans) $chan}
lappend bchan($chan) $ban
}
close $fd
putlog "badchan.conf loaded."
}
putlog "Bass's badchan.tcl 1.0 loaded"
if {[file exists scripts/badchan.conf]} {bchan_read} {putlog "badchan.conf not found!"}
proc bc_flood_init {} {
global bc_flood bc_flood_num bc_flood_time bc_flood_array
if {![string match *:* $bc_flood]} {putlog bchan: var bc_flood not set correctly. ; return 1}
set bc_flood_num [lindex [split $bc_flood :] 0]
set bc_flood_time [lindex [split $bc_flood :] 1]
set i [expr $bc_flood_num - 1]
while {$i >= 0} {
set bc_flood_array($i) 0
incr i -1
}
} ; bc_flood_init
proc bc_flood {nick uhost} {
global bc_flood_num bc_flood_time bc_flood_array
if {$bc_flood_num == 0} {return 0}
set i [expr $bc_flood_num - 1]
while {$i >= 1} {
set bc_flood_array($i) $bc_flood_array([expr $i - 1])
incr i -1
}
set bc_flood_array(0) [unixtime]
if {[expr [unixtime] - $bc_flood_array([expr $bc_flood_num - 1])] <= $bc_flood_time} {
putlog "bchan: Flood detected from $nick."
#newignore [join [maskhost *!*[string trimleft $uhost ~]]] bchan flood 2
return 1
} {return 0}
}
bind join -|- * bchan_join
proc bchan_join {nick uhost hand chan} {
global bchan bcqueue bcnicks botnick
if {[matchattr [nick2hand $nick $chan] bmnof|mnof $chan]} {return 0}
set host [string tolower [lindex [split $uhost @] 1]]
set chan [string tolower $chan]
set nick [string tolower $nick]
if {[lsearch $bchan(chans) $chan] == -1 && ([lsearch $bchan(chans) global] == -1 || [lsearch $bchan(exempt) $chan] > -1)} {return 0}
if {[string tolower $botnick] == [string tolower $nick]} {return 0}
if {![botonchan $chan]} {return 0}
if {$bchan(protect-hosts) != ""} {
foreach i $bchan(protect-hosts) {
if {[string match [string tolower $i] $host]} {return 0}
}
}
if {[info exists bcqueue($host)]} {return 0}
set bcqueue($host) 1
if {[bc_flood $nick $uhost]} {return 0}
set bcnicks($nick) $chan
putserv "whois $nick"
set i 0
set temp ""
while {$i < [string length $nick]} {
if {[string index $nick $i] == "\\"} {append temp "\\\\"} elseif {
[string index $nick $i] == "\["} {append temp "\\\["} elseif {
[string index $nick $i] == "\]"} {append temp "\\\]"} elseif {
[string index $nick $i] == "\{"} {append temp "\\\{"} elseif {
[string index $nick $i] == "\}"} {append temp "\\\}"} {
append temp [string index $nick $i]}
incr i
} ; set nick $temp
timer $bchan(rescan) "unset bcqueue($host) ; unset bcnicks($nick)"
}
bind raw - 319 bc_whois
proc bc_whois {from key args} {
global bchan bcqueue bcnicks
# putlog "319: $args"
set args [join $args]
set nick [string tolower [lindex $args 1]]
if {[info exists bcnicks($nick)]} {set chan $bcnicks($nick)} {return 0}
set chans [string tolower [lrange $args 2 e]]
if {[lsearch $bchan(exempt) $chan] == -1 && $bchan(global) != ""} {set bans $bchan(global)} {set bans ""}
if {[lsearch $bchan(chans) $chan] > -1} {set bans "$bans $bchan($chan)"}
foreach tok $chans {
set tok [string trimleft $tok ":@+"]
foreach ban $bans {
if {[string match [lindex $ban 0] $tok]} {
putlog "badchan: match! $nick k/b'd from $chan because [lrange $ban 1 e]"
putlog "args: $args, ban: $ban"
if {[onchan $nick $chan]} {putserv "PRIVMSG X : ban $chan $nick 1 75 \002\0034Offensive Channel \0036 <[lrange $ban 1 e]> \00314= 1 Hour Ban\002"} {badchan "[lrange $ban 1 e]" 10}
return 0
}
}
}
return 0
}
bind pub n|- !gbclist bc_glist
proc bc_glist {1 2 3 4 5} {bc_list $1 $2 $3 global $5}
bind pub o|o !bclist bc_list
proc bc_list {nick uhost hand chan args} {
global bchan
set chan [string tolower $chan]
if {[lsearch $bchan(chans) $chan] == -1} {puthelp "notice $nick :No badchans are registered for $chan." ; return 1}
set i 1
puthelp "notice $nick :BadChans for $chan..."
foreach ban $bchan($chan) {
puthelp "notice $nick :$i) $ban"
incr i
}
}
bind pub n|- !gabc bc_gadd
proc bc_gadd {1 2 3 4 5} {bc_add $1 $2 $3 global $5}
bind pub o|o !abc bc_add
proc bc_add {nick uhost hand chan args} {
global bchan
set chan [string tolower $chan]
if {![string match *\\\** [lindex $args 0]]} {puthelp "notice $nick :syntax is: !abc <chanmask> \[reason\]" ; return 1}
set args [string trimright "[string tolower [lindex $args 0]] [lrange $args 1 e]" " "]
if {[lsearch $bchan(chans) $chan]} {lappend bchan(chans) $chan}
lappend bchan($chan) $args
puthelp "notice $nick :[lindex $args 0] was added to $chan's badchan list."
bchan_save
return 1
}
bind pub n|- !grbc bc_grem
proc bc_grem {1 2 3 4 5} {bc_rem $1 $2 $3 global $5}
bind pub o|o !rbc bc_rem
proc bc_rem {nick uhost hand chan args} {
global bchan
set chan [string tolower $chan]
set args [string tolower [lindex [join $args] 0]]
if {[lsearch $bchan(chans) $chan] == -1} {puthelp "notice $nick :No badchans are registered for $chan." ; return 1}
if {![string match *\\\** $args]} {puthelp "notice $nick :syntax is: !rbc <chanmask>" ; return 1}
set i 0
set temp ""
foreach ban $bchan($chan) {
if {[string compare $args [lindex $ban 0]] == 0} {incr i} {lappend temp $ban}
}
if {$i > 0} {
if {$temp != ""} {set bchan($chan) $temp} {
unset bchan($chan)
set temp [lsearch $bchan(chans) $chan]
if {$temp == -1} {putlog "bchan: I'm confused." ; return 1}
set bchan(chans) [lreplace $bchan(chans) $temp $temp]
}
puthelp "notice $nick :$args was removed from $chan's badchan list."
bchan_save
} {puthelp "notice $nick :$args was not found in $chan's badchan list."}
return 1
}
proc bchan_save {} {
global bchan
set fd [open scripts/badchan.conf w]
foreach chan $bchan(chans) {
foreach ban $bchan($chan) {
puts $fd "$chan $ban"
}
}
close $fd
|
|
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sat Feb 04, 2006 3:04 pm Post subject: |
|
|
enclose that timer unset with [catch] _________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
avatar132 Voice
Joined: 17 Dec 2005 Posts: 21
|
Posted: Sat Feb 04, 2006 3:26 pm Post subject: |
|
|
i did as you said and changed:
| Code: | timer $bchan(rescan) "unset bcqueue($host) ; unset bcnicks($nick)"
|
to
| Code: | | [timer $bchan(rescan) "unset bcqueue($host) ; unset bcnicks($nick)"] |
then rehashed, and got a new error message:
| Code: | Tcl error [bchan_join]: invalid command name "timer1048"
Tcl error [bchan_join]: wrong # args: should be "timer minutes command"
|
Do you think this code is responsible for the exempt problem? |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sat Feb 04, 2006 4:13 pm Post subject: |
|
|
this script has a security hole and shouldn't be used
anyway:
| Code: |
timer $bchan(rescan) [list catch {unset bcqueue($host) bcnicks($nick)}]"
|
_________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
avatar132 Voice
Joined: 17 Dec 2005 Posts: 21
|
Posted: Sat Feb 04, 2006 5:45 pm Post subject: |
|
|
| what kind of security hole? |
|
| Back to top |
|
 |
avatar132 Voice
Joined: 17 Dec 2005 Posts: 21
|
Posted: Sat Feb 04, 2006 8:32 pm Post subject: |
|
|
| please let me know as to what kind of security hole we are talkin about here, so i know why im deleting the script and on a search for one that does the same thing |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sat Feb 04, 2006 8:55 pm Post subject: |
|
|
well my fix supposedly closes that hole _________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
avatar132 Voice
Joined: 17 Dec 2005 Posts: 21
|
Posted: Sat Feb 04, 2006 9:56 pm Post subject: |
|
|
Ohh, the way you said it sounded like it was hopeless! sorry for misunderstanding.. anyhow i just made the change and receviced a new error msg:
| Code: | Tcl error in script for 'timer1616':
extra characters after close-brace |
thank you for your time and effort,
avatar132 |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Feb 04, 2006 10:31 pm Post subject: |
|
|
Remove the quotation after the close bracket.
| Code: | | timer $bchan(rescan) [list catch {unset bcqueue($host) bcnicks($nick)}] |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
avatar132 Voice
Joined: 17 Dec 2005 Posts: 21
|
Posted: Sun Feb 05, 2006 11:56 am Post subject: |
|
|
worked perfectly, no errors thank you.. i havent tested the exempt hostmasks or channel yet, i'll let you know if your fix worked..
so am i clear as far as security goes? |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun Feb 05, 2006 12:31 pm Post subject: |
|
|
| demond wrote: | | well my fix supposedly closes that hole |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sun Feb 05, 2006 7:51 pm Post subject: |
|
|
<off topic>
Wow! demond haven't used the 'bloated' word nor he recommanded it's script! It's a mirracle!
</off topic> _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
avatar132 Voice
Joined: 17 Dec 2005 Posts: 21
|
Posted: Fri Feb 10, 2006 1:32 pm Post subject: |
|
|
| caesar wrote: | <off topic>
Wow! demond haven't used the 'bloated' word nor he recommanded it's script! It's a mirracle!
</off topic> |
caesar
Sir_Fz and demond were very helpfull in fixing the problem. and since they've helped me i havent had a problem!
true. it is a bloated script, its creation date speaks for itself, as new eggdrop verisons come out, less of the "bloated" form of script is needed.
but how i figure is, it if aint broke dont fix it.. meaning if i have a script that does exactly what i need it to do, why search for another one
thanks again everyone
Avatar132 |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sat Feb 11, 2006 12:02 am Post subject: |
|
|
actually I wouldn't call that particular script "bloated"; after all Bass is the author of most popular seen script which, despite of its somewhat overdone complexity, is rightfully considered among the best _________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sat Feb 11, 2006 7:22 am Post subject: |
|
|
My appologies if I was rude or something similar, I was just kidding, no harm intended. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
|