Update Chanban/chanban.tcl

Fixed auto-adding and removing bans after fixing flawed binds and code logic
This commit is contained in:
Teh PeGaSuS
2026-03-01 20:18:52 +01:00
parent 60ec5476c5
commit 15157bbeb0
+28 -14
View File
@@ -8,7 +8,7 @@ namespace eval cmgmt {
# Configuration
# ----------
# trigger to be used
variable trigger "!"
variable trigger "@"
# Ban reason
variable banReason "User has been banned from the channel."
@@ -84,10 +84,8 @@ namespace eval cmgmt {
# Auto add bans
# ----------
# Add bans
bind mode * * ::cmgmt::abans
# Remove bans
bind mode * * ::cmgmt::rabans
bind mode * "*+b*" ::cmgmt::abans
bind mode * "*-b*" ::cmgmt::rbans
# ----------
# End of configuration
@@ -98,20 +96,22 @@ namespace eval cmgmt {
#
# If you touch the code below and then complain the script "suddenly stopped working" I'll touch you at night.
# ----------
variable scriptName "Channel Management v01.03.2026 by PeGaSuS"
variable scriptName "Channel Management v1.0 \(01/03/2026-18:21\) by PeGaSuS"
# ----------
# Auto add bans
# ----------
proc abans {nick uhost hand chan mode target} {
putlog "DEBUG autobans: nick=$nick chan=$chan mode=$mode target=$target"
set hostmask [maskhost ${nick}![getchanhost $nick $chan] 2]
set banReason "$::cmgmt::banReason \(auto-added\)"
if {$mode eq "+b" && ![channel get $chan addBans]} {
if {![channel get $chan addBans]} {
return 0
}
if {$nick ne $::botnick && $nick ni $::cmgmt::noAddNicks && $hostmask ni $::cmgmt::noAddMasks} {
if {$nick ne "$::botnick" && $nick ni $::cmgmt::noAddNicks && $hostmask ni $::cmgmt::noAddMasks} {
# We also need to deal with the addition of extbans, since we don't deal with them internally
if {[matchstr "~*" $target] && ![isban $target $chan]} {
newchanban $chan $target $nick EXTBAN 0 sticky
return 0
@@ -124,14 +124,14 @@ namespace eval cmgmt {
return 0
}
# We also need to deal with the removal of extbans, since we don't deal with them internally
proc rabans {nick uhost hand chan mode target} {
if {$mode eq "-b" && ![channel get $chan addBans]} {
proc rbans {nick uhost hand chan mode target} {
putlog "DEBUG autobans: nick=$nick chan=$chan mode=$mode target=$target"
if {![channel get $chan addBans]} {
return 0
}
if {$nick ne $::botnick && [isban $target $chan]} {
if {[matchstr "~*" $target]} {
if {$nick ne "$::botnick"} {
if {[matchstr "~*" $target] && ![isban $target $chan]} {
killchanban $chan $target
return 0
} else {
@@ -143,6 +143,8 @@ namespace eval cmgmt {
return 0
}
# Lets check for existing extbans and add them to our ban list
# and make them sticky so the bot doesn't remove them
bind cron * "*/5 * * * *" ::cmgmt::addextbans
@@ -315,10 +317,16 @@ namespace eval cmgmt {
foreach botban $cbans {
set banmask [lindex $botban 0]
set reason [lindex $botban 1]
if {[isbansticky $banmask $chan]} {
set freason "$reason \(sticky\)"
} else {
set freason "$reason"
}
set tstamp [lindex $botban 3]
set date [clock format $tstamp -format "%d/%m/%Y - %H:%M:%S"]
set creator [lindex $botban end]
puts $blist "\[${i}\] Banmask: $banmask :: Added by: $creator :: Date: $date"
puts $blist "\[${i}\] Banmask: $banmask :: Reason: $freason :: Added by: $creator :: Date: $date"
puts $blist ""
incr i
}
@@ -618,6 +626,12 @@ namespace eval cmgmt {
foreach botban $cbans {
set banmask [lindex $botban 0]
set reason [lindex $botban 1]
if {[isbansticky $banmask $chan]} {
set freason "$reason \(sticky\)"
} else {
set freason "$reason"
}
set tstamp [lindex $botban 3]
set date [clock format $tstamp -format "%d/%m/%Y - %H:%M:%S"]
set creator [lindex $botban end]