Added 'addban' comand

The new `addban` command accepts any type of mask and doesn't make any checks to see if it is properly formatted, so users must check twice if the mask they're adding is correct.
This commit is contained in:
Teh PeGaSuS
2026-03-03 19:54:05 +01:00
parent 105e19afb0
commit 1dfcb61a53
+111 -5
View File
@@ -23,7 +23,7 @@ namespace eval cmgmt {
# Command to upload the file
# 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"
variable upCommand "curl -s -F file=@- https://hotpaste.0bin.xyz/"
# Set the banmask type to use in banning the user
# Available types are:
@@ -60,6 +60,7 @@ namespace eval cmgmt {
# Binds
# ----------
### Public
bind pub * ${::cmgmt::trigger}addban ::cmgmt::addban_pub
bind pub * ${::cmgmt::trigger}ban ::cmgmt::ban_pub
bind pub * ${::cmgmt::trigger}tban ::cmgmt::tban_pub
bind pub * ${::cmgmt::trigger}kick ::cmgmt::kick_pub
@@ -71,6 +72,7 @@ namespace eval cmgmt {
bind pub * ${::cmgmt::trigger}opcmds ::cmgmt::opcmds_pub
### Private
bind msg * addban ::cmgmt::addban_msg
bind msg * ban ::cmgmt::ban_msg
bind msg * tban ::cmgmt::tban_msg
bind msg * kick ::cmgmt::kick_msg
@@ -119,12 +121,60 @@ namespace eval cmgmt {
# ----------
# Script name and author
variable scriptName "Channel Management v1.0 \(03/03/2026-09:30\)"
variable scriptAuthor "PeGaSuS"
variable scriptName "Channel Management v1.0 \(03/03/2026-09:30\)"
variable scriptAuthor "PeGaSuS"
# ----------
# Public procs
# ----------
### Pub Addban - Be aware that this commands expects the mask to properly formatted
proc addban_pub {nick uhost hand chan text} {
if {![matchattr $hand o|o $chan]} {
putserv "NOTICE $nick :[format [::msgcat::mc error.no.access] $nick]"
return 0
}
set banmask [lindex [split $text] 0]
if {$banmask eq ""} {
putserv "PRIVMSG $chan :[format [::msgcat::mc error.syntax] $::cmgmt::trigger]addban <banmask>"
return 0
}
if {[matchstr $::botname $banmask] || [matchstr $banmask $::botname]} {
putkick $chan $nick [::msgcat::mc revenge.kick]
return 0
}
foreach pmask $::cmgmt::protectMasks {
if {[matchstr $pmask $banmask] || [matchstr $banmask $pmask]} {
putserv "PRIVMSG $chan :[::msgcat::mc prot.user.addban]"
return 0
}
}
foreach nmask $::cmgmt::noAddMasks {
if {[matchstr $nmask $banmask] || [matchstr $banmask $nmask]} {
putserv "PRIVMSG $chan :[::msgcat::mc prot.user.addban]"
return 0
}
}
foreach user [userlist] {
if {[matchattr $user mno|mno $chan]} {
foreach host [getuser $user HOSTS] {
if {[matchstr $target $host] || [matchstr $host $target]} {
putserv "PRIVMSG $chan :[::msgcat::mc prot.user.addban]"
return 0
}
}
}
}
newchanban $chan $banmask $nick [::msgcat::mc ban.reason] 0
pushmode $chan +b $banmask
return 0
}
### Pub Ban
proc ban_pub {nick uhost hand chan text} {
if {![matchattr $hand o|o $chan]} {
@@ -461,6 +511,62 @@ namespace eval cmgmt {
# ----------
# Private procs
# ----------
### PM Addban - Be aware that this commands expects the mask to properly formatted
proc addban_pub {nick uhost hand text} {
set chan [lindex [split $text] 0]
if {![matchstr "#*" $chan]} {
putserv "PRIVMSG $nick :[::msgcat::mc pm.error.syntax] addban <#chan> <banmask>"
return 0
}
if {![matchattr $hand o|o $chan]} {
putserv "NOTICE $nick :[format [::msgcat::mc error.no.access] $nick]"
return 0
}
set banmask [lindex [split $text] 1]
if {$banmask eq ""} {
putserv "PRIVMSG $chan :[format [::msgcat::mc error.syntax] $::cmgmt::trigger]addban <#chan> <banmask>"
return 0
}
if {[matchstr $::botname $banmask] || [matchstr $banmask $::botname]} {
putkick $chan $nick [::msgcat::mc revenge.kick]
return 0
}
foreach pmask $::cmgmt::protectMasks {
if {[matchstr $pmask $banmask] || [matchstr $banmask $pmask]} {
putserv "PRIVMSG $chan :[::msgcat::mc prot.user.addban]"
return 0
}
}
foreach nmask $::cmgmt::noAddMasks {
if {[matchstr $nmask $banmask] || [matchstr $banmask $nmask]} {
putserv "PRIVMSG $chan :[::msgcat::mc prot.user.addban]"
return 0
}
}
foreach user [userlist] {
if {[matchattr $user mno|mno $chan]} {
foreach host [getuser $user HOSTS] {
if {[matchstr $target $host] || [matchstr $host $target]} {
putserv "PRIVMSG $chan :[::msgcat::mc prot.user.addban]"
return 0
}
}
}
}
newchanban $chan $banmask $nick [::msgcat::mc ban.reason] 0
pushmode $chan +b $banmask
return 0
}
### PM Ban
proc ban_msg {nick uhost hand text} {
set chan [lindex [split $text] 0]
@@ -706,7 +812,7 @@ namespace eval cmgmt {
set chan [lindex [split $text] 0]
if {![matchstr "#*" $chan]} {
putserv "PRIVMSG $nick :[::msgcat::mc pm.error.syntax] unban <#chan> <nick>"
putserv "PRIVMSG $nick :[::msgcat::mc pm.error.syntax] unban <#chan> <banmask>"
return 0
}
@@ -723,7 +829,7 @@ namespace eval cmgmt {
set banmask [lindex [split $text] 1]
if {$banmask eq ""} {
putserv "PRIVMSG $nick :[::msgcat::mc pm.error.syntax] unban <#chan> <mask>"
putserv "PRIVMSG $nick :[::msgcat::mc pm.error.syntax] unban <#chan> <banmask>"
return 0
}