From 1dfcb61a53c5c532b2d0e7db4a1bbd131570b9e6 Mon Sep 17 00:00:00 2001 From: Teh PeGaSuS Date: Tue, 3 Mar 2026 19:54:05 +0100 Subject: [PATCH] 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. --- Chanban/cmgmt.tcl | 116 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 5 deletions(-) diff --git a/Chanban/cmgmt.tcl b/Chanban/cmgmt.tcl index 63a9ff8..d7b25c7 100644 --- a/Chanban/cmgmt.tcl +++ b/Chanban/cmgmt.tcl @@ -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 " + 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> " + 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> " + 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> " + putserv "PRIVMSG $nick :[::msgcat::mc pm.error.syntax] unban <#chan> " 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> " + putserv "PRIVMSG $nick :[::msgcat::mc pm.error.syntax] unban <#chan> " return 0 }