Update Chanban/chanban.tcl

Added ways to deal with UnrealIRCd extbans
This commit is contained in:
Teh PeGaSuS
2026-03-01 17:10:52 +01:00
parent 509369f59d
commit cce017f1d5
+57 -14
View File
@@ -1,5 +1,7 @@
# ----------
# Channel Management
#
# Detailed explanations: https://gitea.0bin.xyz/pegasus/tclscripts/src/branch/main/Chanban#readme
# ----------
namespace eval cmgmt {
# ----------
@@ -24,7 +26,8 @@ namespace eval cmgmt {
variable tBanDuration "30"
# Command to upload the file
# Be aware that we are doing `cat $filename |` so you must account for that
# The ban list file is piped into the command via stdin (with `cat $filename |`)
# so your command must read from stdin
variable upCommand "curl -s -F file=@- https://x0.at/"
# Set the banmask to use in banning the user
@@ -65,7 +68,7 @@ namespace eval cmgmt {
bind pub * ${::cmgmt::trigger}kick ::cmgmt::kick_pub
bind pub * ${::cmgmt::trigger}unban ::cmgmt::unban_pub
bind pub * ${::cmgmt::trigger}banlist ::cmgmt::banlist_pub
bind pub * ${::cmgmt::trigger}autoadd ::cmgmt::autoadd_pub
bind pub * ${::cmgmt::trigger}autoadd ::cmgmt::autoban_pub
bind pub * ${::cmgmt::trigger}opcmds ::cmgmt::opcmds_pub
### Private
@@ -74,14 +77,18 @@ namespace eval cmgmt {
bind msg * kick ::cmgmt::kick_msg
bind msg * unban ::cmgmt::unban_msg
bind msg * banlist ::cmgmt::banlist_msg
bind msg * autoadd ::cmgmt::autoadd_msg
bind msg * autoadd ::cmgmt::autoban_msg
bind msg * opcmds ::cmgmt::opcmds_msg
# ----------
# Auto add bans
# ----------
# Add bans
bind mode * * ::cmgmt::abans
# Remove bans
bind mode * * ::cmgmt::rabans
# ----------
# End of configuration
# ----------
@@ -100,14 +107,50 @@ namespace eval cmgmt {
set hostmask [maskhost ${nick}![getchanhost $nick $chan] 2]
set banReason "$::cmgmt::banReason \(auto-added\)"
if {$mode eq "+b" && [channel get $chan addBans]} {
if {$nick ne $::botnick && $nick ni $::cmgmt::noAddNicks && $hostmask ni $::cmgmt::noAddMasks && ![matchstr "~*" $target] && ![isban $target $chan]} {
newchanban $chan $target $nick $banReason 0
putserv "PRIVMSG $chan :$target auto-added to ${chan}'s ban list."
return 0
} else {
return 0
if {$nick ne $::botnick && $nick ni $::cmgmt::noAddNicks && $hostmask ni $::cmgmt::noAddMasks} {
if {[matchstr "~*" $target] && ![isban $target $chan]} {
newchanban $chan $target $nick $banReason 0 sticky
return 0
} else {
newchanban $chan $target $nick $banReason 0
putserv "PRIVMSG $chan :$target auto-added to ${chan}'s ban list."
return 0
}
}
}
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]} {
if {$nick ne $::botnick && [isban $target $chan]} {
if {[matchstr "~*" $target]} {
killchanban $chan $target
return 0
} else {
killchanban $chan $target
putserv "PRIVMSG $chan :$target auto-removed from ${chan}'s ban list."
return 0
}
}
}
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
proc addextbans {minute hour day month weekday} {
foreach chan [channels] {
foreach cban [chanbans $chan] {
set mask [lindex [split $cban] 0]
if {[matchstr "~*" $mask] && ![isban $mask $chan]} {
newchanban $chan $mask $::botnick EXTBAN 0 sticky
}
}
}
return 0
}
# ----------
@@ -294,7 +337,7 @@ namespace eval cmgmt {
}
### Auto add bans
proc autoadd_pub {nick uhost hand chan text} {
proc autoban_pub {nick uhost hand chan text} {
if {![matchattr $hand o|o $chan]} {
putserv "NOTICE $nick :ERROR! You don't have access, ${nick}."
return 0
@@ -313,7 +356,7 @@ namespace eval cmgmt {
return 0
}
}
off {
if {![channel get $chan addBans]} {
putserv "PRIVMSG $chan :ERROR! Automatic ban adding is already disabled on ${chan}."
@@ -597,7 +640,7 @@ namespace eval cmgmt {
}
### Auto add bans
proc autoadd_pub {nick uhost hand text} {
proc autoban_msg {nick uhost hand text} {
set chan [lindex [split $text] 0]
if {![matchstr "#*" $chan]} {
@@ -628,7 +671,7 @@ namespace eval cmgmt {
return 0
}
}
off {
if {![channel get $chan addBans]} {
putserv "PRIVMSG $nick :ERROR! Automatic ban adding is already disabled on ${chan}."
@@ -677,7 +720,7 @@ namespace eval cmgmt {
return 0
}
putserv "PRIVMSG $nick :Available commands ban, tban, kick, unban, banlist"
putserv "PRIVMSG $nick :Available commands ban, tban, kick, unban, banlist, autoadd"
return 0
}