| View previous topic :: View next topic |
| Author |
Message |
demetrius_reis Halfop
Joined: 10 Aug 2010 Posts: 42
|
Posted: Wed Jun 29, 2011 12:38 am Post subject: what is the name of the tcl |
|
|
I'm looking for old tcl it worked like this:
When the user was banned, the BOT will automatically send a code to the user, use to unban yourself.
What is the name of the tcl? |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Jun 29, 2011 1:21 am Post subject: |
|
|
| Code: |
bind mode * "% +b" check:ban
proc check:ban {nick uhost handle channel change target} {
# check if the mask matches the bot's host and return if it doesn't
if {![string match -nocase $target $::botname]} return
# do what action/actions you wish as the mask matches his host
putserv "PRIVMSG $nick :your message in here"
}
|
This should do what you want. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Jun 29, 2011 11:42 am Post subject: |
|
|
I don't recall such a script, unfortunately..
I did put this little piece together this afternoon though..
Keep in mind, that the code has not been tested, so it might very well contain various bugs or issues. Also, it does a fair amount of list searches and keeps all codes in memory, so it might degrade performace in 600+ member channels.
The script is written for 1.6.20 eggdrops, if you're using older eggies, you'll have to find a replacement for the matchaddr command..
| Code: | bind mode - "% +b" checkBan
bind msg - !unban checkUnban
## Add a time or cron binding to purge old entries every 10 minutes..
#bind cron - "*/10 * * * *" cronPurgeBan
#bind time - "?0 *" cronPurgeBan
proc checkBan {nick host handle channel mode target} {
##Don't ban the bot, not explicitly requested but is a good precaution
if {[matchaddr $target $::botname]} {
pushmode $channel -b $target
return
}
foreach user [chanlist $channel] {
if {[matchaddr $target "${user}![getchanhost $user $channel]"]} {
set key [addUnban $user $channel $target]
puthelp "PRIVMSG $user :You have been banned! Please send \"!unban $channel $key\" to me to remove the ban"
}
}
}
proc generateRandomString {length} {
set string ""
while {[incr length -1] >= 0} {
append string [string index "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#" [rand 64]]
}
return $string
}
proc addUnban {nick channel banmask} {
set key [string tolower $nick]
set password [generateRandomString 8]
## Check to see if there's any data for the user already..
if {[info exists $::banKeys($key)]} {
## If we're using tcl 8.5, this speeds things up alot..
if {$::tcl_version >= 8.5} {
set index [lsearch -index 0 -exact -nocase $::banKeys($key) $channel
} else {
for {set i 0; set index -1} {$i < [llength $::banKeys($key)]} {incr i} {
if {[string equal -nocase [lindex $::banKeys($key) 0] $channel]} {
set index $i
break
}
}
}
## See if we found a match for this channel in the user's data...
if {$index >= 0} {
lset ::banKeys($key) $index [list $channel $banmask $password [clock seconds]]
return $password
}
}
lappend ::banKeys($key) [list $channel $banmask $password [clock seconds]]
return $password
}
proc checkUnban {nick host handle text} {
set key [string tolower $nick]
set data [split $text]
## Check to see if there's any data for the user already..
if {[info exists $::banKeys($key)]} {
## If we're using tcl 8.5, this speeds things up alot..
if {$::tcl_version >= 8.5} {
lassign $data bChan bKey
set index [lsearch -index 0 -exact -nocase $::banKeys($key) $bChan
} else {
foreach $data {bChan bKey} {}
for {set i 0; set index -1} {$i < [llength $::banKeys($key)]} {incr i} {
if {[string equal -nocase [lindex $::banKeys($key) 0] $bChan]} {
set index $i
break
}
}
}
## See if we found a match for this channel in the user's data...
if {$index >= 0} {
if {[clock seconds] - [lindex $::banKeys($key) $index 3] > 60} {
set ::banKeys($key) [lreplace $::banKeys($key) $index $index]
if {[llength $::banKeys($key)] == 0} {
unset ::banKeys($key)
}
} elseif {[string equal -nocase $bKey [lindex $::banKeys($key) $index 2]]} {
pushmode [lindex $::banKeys($key) $index 0] -b [lindex $::banKeys($key) $index 1]
}
}
}
}
proc purgeBan {{user *}} {
foreach key [array names ::banKeys -glob [string tolower $user]] {
set index 0
while {$i < [llength $::banKeys($key)]} {
if {[clock seconds] - [lindex $::banKeys($key) $index 3] > 60} {
set ::banKeys($key) [lreplace $::banKeys($key) $index $index]
} else {
incr index
}
}
if {[llength $::banKeys($key)] == 0} {
unset ::banKeys($key)
}
}
}
proc cronPurgeBan {minute hour day month weekday} {
purgeBan
} |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
demetrius_reis Halfop
Joined: 10 Aug 2010 Posts: 42
|
Posted: Wed Jun 29, 2011 9:25 pm Post subject: |
|
|
oh yes I understand
I will evaluate scripts
thanks! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Jun 30, 2011 1:27 am Post subject: |
|
|
Just ignore my first post as it won't do what exactly you needed, nml375's code on the other hand will.
/me takes hat down in front of nml375  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Thu Jan 21, 2021 6:27 pm Post subject: |
|
|
this is a bit of an old thread but i was curious about this code and tried it and
got: Tcl error [checkBan]: can't read "::banKeys(lilly)": no such variable
lilly being the banned nick |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Mon Jan 25, 2021 2:05 pm Post subject: |
|
|
with the help of SpiKe^^ who debugged it and took out all bugs it seems to work proper now, thanks again SpiKe^^ and nml375 ofcourse who wrote the original code,..... apreciated so ill post it here if someone might need it as well:
| Code: |
bind mode - "% +b" checkBan
bind msg - !unban checkUnban
## Add a time or cron binding to purge old entries every 10 minutes..
bind cron - "*/10 * * * *" cronPurgeBan
#bind time - "?0 *" cronPurgeBan
proc checkBan {nick host handle channel mode target} {
##Don't ban the bot, not explicitly requested but is a good precaution
if {[matchaddr $target $::botname]} {
pushmode $channel -b $target
return
}
foreach user [chanlist $channel] {
if {[matchaddr $target "${user}![getchanhost $user $channel]"]} {
set key [addUnban $user $channel $target]
puthelp "PRIVMSG $user :You have been banned! Please send \"!unban $channel $key\" to me to remove the ban"
}
}
}
proc generateRandomString {length} {
set string ""
while {[incr length -1] >= 0} {
append string [string index "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#" [rand 64]]
}
return $string
}
proc addUnban {nick channel banmask} {
set key [string tolower $nick]
set password [generateRandomString 8]
## Check to see if there's any data for the user already..
if {[info exists ::banKeys($key)]} {
## If we're using tcl 8.5, this speeds things up alot..
if {$::tcl_version >= 8.5} {
set index [lsearch -index 0 -exact -nocase $::banKeys($key) $channel]
} else {
for {set i 0; set index -1} {$i < [llength $::banKeys($key)]} {incr i} {
if {[string equal -nocase [lindex $::banKeys($key) 0] $channel]} {
set index $i
break
}
}
}
## See if we found a match for this channel in the user's data...
if {$index >= 0} {
lset ::banKeys($key) $index [list $channel $banmask $password [clock seconds]]
return $password
}
}
lappend ::banKeys($key) [list $channel $banmask $password [clock seconds]]
return $password
}
proc checkUnban {nick host handle text} {
set key [string tolower $nick]
set data [split $text]
## Check to see if there's any data for the user already..
if {[info exists ::banKeys($key)]} {
## If we're using tcl 8.5, this speeds things up alot..
if {$::tcl_version >= 8.5} {
lassign $data bChan bKey
set index [lsearch -index 0 -exact -nocase $::banKeys($key) $bChan]
} else {
foreach {bChan bKey} $data {}
for {set i 0; set index -1} {$i < [llength $::banKeys($key)]} {incr i} {
if {[string equal -nocase [lindex $::banKeys($key) 0] $bChan]} {
set index $i
break
}
}
}
## See if we found a match for this channel in the user's data...
if {$index >= 0} {
if {[clock seconds] - [lindex $::banKeys($key) $index 3] > 60} {
set ::banKeys($key) [lreplace $::banKeys($key) $index $index]
if {[llength $::banKeys($key)] == 0} {
unset ::banKeys($key)
}
} elseif {[string equal -nocase $bKey [lindex $::banKeys($key) $index 2]]} {
pushmode [lindex $::banKeys($key) $index 0] -b [lindex $::banKeys($key) $index 1]
}
}
}
}
proc purgeBan {{user *}} {
foreach key [array names ::banKeys -glob [string tolower $user]] {
set index 0
while {$index < [llength $::banKeys($key)]} {
if {[clock seconds] - [lindex $::banKeys($key) $index 3] > 60} {
set ::banKeys($key) [lreplace $::banKeys($key) $index $index]
} else {
incr index
}
}
if {[llength $::banKeys($key)] == 0} {
unset ::banKeys($key)
}
}
}
proc cronPurgeBan {minute hour day month weekday} {
purgeBan
}
|
|
|
| Back to top |
|
 |
|