Add voice management and fixed some logic on the script
This commit is contained in:
+247
-2
@@ -76,7 +76,10 @@ namespace eval cmgmt {
|
||||
bind pub * ${::cmgmt::trigger}opcmds ::cmgmt::opcmds_pub
|
||||
bind pub * ${::cmgmt::trigger}addop ::cmgmt::addop_pub
|
||||
bind pub * ${::cmgmt::trigger}delop ::cmgmt::delop_pub
|
||||
bind pub * ${::cmgmt::trigger}addvoice ::cmgmt::addvoice_pub
|
||||
bind pub * ${::cmgmt::trigger}delvoice ::cmgmt::delvoice_pub
|
||||
bind pub * ${::cmgmt::trigger}ops ::cmgmt::chanops_pub
|
||||
bind pub * ${::cmgmt::trigger}voices ::cmgmt::chanvoices_pub
|
||||
|
||||
### Private
|
||||
bind msg * addban ::cmgmt::addban_msg
|
||||
@@ -91,7 +94,10 @@ namespace eval cmgmt {
|
||||
bind msg * opcmds ::cmgmt::opcmds_msg
|
||||
bind msg * addop ::cmgmt::addop_msg
|
||||
bind msg * delop ::cmgmt::delop_msg
|
||||
bind msg * addvoice ::cmgmt::addvoice_msg
|
||||
bind msg * delvoice ::cmgmt::delvoice_msg
|
||||
bind msg * ops ::cmgmt::chanops_msg
|
||||
bind msg * voices ::cmgmt::chanvoices_msg
|
||||
|
||||
# Channel flag to auto add bans to the bot ban list
|
||||
setudef flag addBans
|
||||
@@ -544,6 +550,7 @@ namespace eval cmgmt {
|
||||
return 0
|
||||
} else {
|
||||
chattr $target |+o $chan
|
||||
pushmode $chan +o $target
|
||||
putserv "PRIVMSG $chan :[::msgcat::mc added.chanop $target $chan]"
|
||||
return 0
|
||||
}
|
||||
@@ -551,6 +558,7 @@ namespace eval cmgmt {
|
||||
|
||||
adduser $target $opMask
|
||||
chattr $target |+o $chan
|
||||
pushmode $chan +o $target
|
||||
putserv "PRIVMSG $chan :[::msgcat::mc added.chanop $target $chan]"
|
||||
return 0
|
||||
}
|
||||
@@ -587,15 +595,104 @@ namespace eval cmgmt {
|
||||
|
||||
if {$visop == 0 && ![matchattr $user mno]} {
|
||||
deluser $user
|
||||
pushmode $chan -o $target
|
||||
putserv "PRIVMSG $chan :[::msgcat::mc op.deleted $target $chan]"
|
||||
putserv "NOTICE $nick :[::msgcat::mc db.user.deleted $target]"
|
||||
return 0
|
||||
} else {
|
||||
pushmode $chan -o $target
|
||||
putserv "PRIVMSG $chan :[::msgcat::mc op.deleted $target $chan]"
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
### Pub Addvoice
|
||||
proc addvoice_pub {nick uhost hand chan text} {
|
||||
set target [lindex [split $text] 0]
|
||||
|
||||
if {![matchattr $hand n]} {
|
||||
putserv "NOTICE $nick :[::msgcat::mc error.no.access $nick]"
|
||||
return 0
|
||||
}
|
||||
|
||||
if {$target eq ""} {
|
||||
putserv "PRIVMSG $chan :[::msgcat::mc error.syntax $::cmgmt::trigger]addvoice <nick>"
|
||||
return 0
|
||||
}
|
||||
|
||||
if {![onchan $target $chan]} {
|
||||
putserv "PRIVMSG $chan :[::msgcat::mc not.on.chan $target $chan]"
|
||||
return 0
|
||||
}
|
||||
|
||||
if {$target eq "$::botnick"} {
|
||||
return 0
|
||||
}
|
||||
|
||||
set voiceMask [maskhost ${target}![getchanhost $target $chan] $::cmgmt::addOpMask]
|
||||
|
||||
if {[validuser $target]} {
|
||||
if {[matchattr [nick2hand $target] mno|o $chan]} {
|
||||
putserv "PRIVMSG $chan :[::msgcat::mc got.oflag $target $chan]"
|
||||
return 0
|
||||
} else {
|
||||
chattr $target |+v $chan
|
||||
pushmode $chan +v $target
|
||||
putserv "PRIVMSG $chan :[::msgcat::mc added.chanvoice $target $chan]"
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
adduser $target $voiceMask
|
||||
chattr $target |+v $chan
|
||||
pushmode $chan +v $target
|
||||
putserv "PRIVMSG $chan :[::msgcat::mc added.chanvoice $target $chan]"
|
||||
return 0
|
||||
}
|
||||
|
||||
### Pub Delvoice
|
||||
proc delvoice_pub {nick uhost hand chan text} {
|
||||
set visvoice 0
|
||||
|
||||
if {![matchattr $hand n]} {
|
||||
putserv "NOTICE $nick :[::msgcat::mc error.no.access $nick]"
|
||||
return 0
|
||||
}
|
||||
|
||||
set target [lindex [split $text] 0]
|
||||
|
||||
if {$target eq ""} {
|
||||
putserv "PRIVMSG $chan :[::msgcat::mc error.syntax $::cmgmt::trigger]delvoice <nick>"
|
||||
return 0
|
||||
}
|
||||
|
||||
if {![validuser $target]} {
|
||||
putserv "PRIVMSG $chan :[::msgcat::mc inexistent.user $target]"
|
||||
return 0
|
||||
}
|
||||
|
||||
set user [nick2hand $target]
|
||||
chattr $user |-v $chan
|
||||
|
||||
foreach tc [channels] {
|
||||
if {[matchattr $user |vo $tc]} {
|
||||
incr visvoice
|
||||
}
|
||||
}
|
||||
|
||||
if {$visvoice == 0 && ![matchattr $user mno]} {
|
||||
deluser $user
|
||||
pushmode $chan -v $target
|
||||
putserv "PRIVMSG $chan :[::msgcat::mc voice.deleted $target $chan]"
|
||||
putserv "NOTICE $nick :[::msgcat::mc db.user.deleted $target]"
|
||||
return 0
|
||||
} else {
|
||||
pushmode $chan -v $target
|
||||
putserv "PRIVMSG $chan :[::msgcat::mc voice.deleted $target $chan]"
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
# Pub Ops
|
||||
proc chanops_pub {nick uhost hand chan text} {
|
||||
if {![matchattr $hand n]} {
|
||||
@@ -607,6 +704,17 @@ namespace eval cmgmt {
|
||||
return 0
|
||||
}
|
||||
|
||||
# Pub Voices
|
||||
proc chanvoices_pub {nick uhost hand chan text} {
|
||||
if {![matchattr $hand n]} {
|
||||
putserv "NOTICE $nick :[::msgcat::mc error.no.access $nick]"
|
||||
return 0
|
||||
}
|
||||
|
||||
putserv "PRIVMSG $chan :[::msgcat::mc chanvoice.list $chan] [join [userlist |v $chan] {, }]"
|
||||
return 0
|
||||
}
|
||||
|
||||
# ----------
|
||||
# Private procs
|
||||
# ----------
|
||||
@@ -1124,7 +1232,7 @@ namespace eval cmgmt {
|
||||
set target [lindex [split $text] 1]
|
||||
|
||||
if {$target eq ""} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc error.syntax $::cmgmt::trigger]addop <#chan> <nick>"
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc pm.error.syntax] addop <#chan> <nick>"
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -1145,6 +1253,7 @@ namespace eval cmgmt {
|
||||
return 0
|
||||
} else {
|
||||
chattr $target |+o $chan
|
||||
pushmode $chan +o $target
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc added.chanop $target $chan]"
|
||||
return 0
|
||||
}
|
||||
@@ -1152,6 +1261,7 @@ namespace eval cmgmt {
|
||||
|
||||
adduser $target $opMask
|
||||
chattr $target |+o $chan
|
||||
pushmode $chan +o $target
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc added.chanop $target $chan]"
|
||||
return 0
|
||||
}
|
||||
@@ -1179,7 +1289,7 @@ namespace eval cmgmt {
|
||||
set target [lindex [split $text] 1]
|
||||
|
||||
if {$target eq ""} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc error.syntax $::cmgmt::trigger]delop <#chan> <nick>"
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc pm.error.syntax] delop <#chan> <nick>"
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -1199,15 +1309,127 @@ namespace eval cmgmt {
|
||||
|
||||
if {$visop == 0 && ![matchattr $user mno]} {
|
||||
deluser $user
|
||||
pushmode $chan -o $target
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc op.deleted $target $chan]"
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc db.user.deleted $target]"
|
||||
return 0
|
||||
} else {
|
||||
pushmode $chan -o $target
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc op.deleted $target $chan]"
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
### PM Addvoice
|
||||
proc addvoice_msg {nick uhost hand text} {
|
||||
set chan [lindex [split $text] 0]
|
||||
|
||||
if {![matchstr "#*" $chan]} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc pm.error.syntax] addvoice <#chan> <nick>"
|
||||
return 0
|
||||
}
|
||||
|
||||
if {![validchan $chan]} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc bot.not.onchan $chan]"
|
||||
return 0
|
||||
}
|
||||
|
||||
if {![matchattr $hand n]} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc error.no.access $nick]"
|
||||
return 0
|
||||
}
|
||||
|
||||
set target [lindex [split $text] 1]
|
||||
|
||||
if {$target eq ""} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc pm.error.syntax] addvoice <#chan> <nick>"
|
||||
return 0
|
||||
}
|
||||
|
||||
if {![onchan $target $chan]} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc not.on.chan $target $chan]"
|
||||
return 0
|
||||
}
|
||||
|
||||
if {$target eq "$::botnick"} {
|
||||
return 0
|
||||
}
|
||||
|
||||
set voiceMask [maskhost ${target}![getchanhost $target $chan] $::cmgmt::addOpMask]
|
||||
|
||||
if {[validuser $target]} {
|
||||
if {[matchattr [nick2hand $target] mno|o $chan]} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc got.oflag $target $chan]"
|
||||
return 0
|
||||
} else {
|
||||
chattr $target |+v $chan
|
||||
pushmode $chan +v $target
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc added.chanvoice $target $chan]"
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
adduser $target $voiceMask
|
||||
chattr $target |+v $chan
|
||||
pushmode $chan +v $target
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc added.chanvoice $target $chan]"
|
||||
return 0
|
||||
}
|
||||
|
||||
### PM Delvoice
|
||||
proc delvoice_msg {nick uhost hand text} {
|
||||
set chan [lindex [split $text] 0]
|
||||
set visvoice 0
|
||||
|
||||
if {![matchstr "#*" $chan]} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc pm.error.syntax] delvoice <#chan> <nick>"
|
||||
return 0
|
||||
}
|
||||
|
||||
if {![validchan $chan]} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc bot.not.onchan $chan]"
|
||||
return 0
|
||||
}
|
||||
|
||||
if {![matchattr $hand n]} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc error.no.access $nick]"
|
||||
return 0
|
||||
}
|
||||
|
||||
set target [lindex [split $text] 1]
|
||||
|
||||
if {$target eq ""} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc pm.error.syntax] delvoice <#chan> <nick>"
|
||||
return 0
|
||||
}
|
||||
|
||||
if {![validuser $target]} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc inexistent.user $target]"
|
||||
return 0
|
||||
}
|
||||
|
||||
set user [nick2hand $target]
|
||||
chattr $user |-v $chan
|
||||
|
||||
foreach tc [channels] {
|
||||
if {[matchattr $user |vo $tc]} {
|
||||
incr visvoice
|
||||
}
|
||||
}
|
||||
|
||||
if {$visvoice == 0 && ![matchattr $user mno]} {
|
||||
deluser $user
|
||||
pushmode $chan -v $target
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc voice.deleted $target $chan]"
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc db.user.deleted $target]"
|
||||
return 0
|
||||
} else {
|
||||
pushmode $chan -v $target
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc voice.deleted $target $chan]"
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
# PM Ops
|
||||
proc chanops_msg {nick uhost hand text} {
|
||||
set chan [lindex [split $text] 0]
|
||||
@@ -1231,6 +1453,29 @@ namespace eval cmgmt {
|
||||
return 0
|
||||
}
|
||||
|
||||
# PM Voices
|
||||
proc chanvoices_msg {nick uhost hand text} {
|
||||
set chan [lindex [split $text] 0]
|
||||
|
||||
if {![matchstr "#*" $chan]} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc pm.error.syntax] voices <#chan>"
|
||||
return 0
|
||||
}
|
||||
|
||||
if {![validchan $chan]} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc bot.not.onchan $chan]"
|
||||
return 0
|
||||
}
|
||||
|
||||
if {![matchattr $hand n]} {
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc error.no.access $nick]"
|
||||
return 0
|
||||
}
|
||||
|
||||
putserv "PRIVMSG $nick :[::msgcat::mc chanvoice.list $chan] [join [userlist |v $chan] {, }]"
|
||||
return 0
|
||||
}
|
||||
|
||||
# ---------- DON'T TOUCH UNLESS YOU KNOW WHAT YOU'RE DOING ---------- #
|
||||
# ----------
|
||||
# Auto add bans binds
|
||||
|
||||
Reference in New Issue
Block a user