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?
Code: Select all
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"
}
Code: Select all
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
}
Code: Select all
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
}