Skip to content

Instantly share code, notes, and snippets.

/-

Created January 15, 2018 20:21
Show Gist options
  • Save anonymous/2a5d393e6fd49680dee05c0f41835e59 to your computer and use it in GitHub Desktop.
Save anonymous/2a5d393e6fd49680dee05c0f41835e59 to your computer and use it in GitHub Desktop.
# Info
# Author: MeTroiD
# Channel: #v1per on Quakenet
set mute(version) "1.0"
set mute(author) "MeTroiD - #v1per on Quakenet"
# This script is made by request to "mute" people you don't want talking.
# This script stores the nickname and hostname in a channel variable so if he rejoins he won't be voiced like the others.
# Also if the muted changes his nick it will be stored so he won't be voiced the next time.
# This might be usefull for channels that don't like people that spam and keep spamming.
# There is no need to put an escape in it for example \$. Just the character and it should work ;)
set mute(trigger) "!"
# Flags and strings - Don't touch this!
setudef flag autovoice
setudef flag muted
setudef str muteinfo
#
# Binds - Don't touch this!
bind PUB m|m ${mute(trigger)}mute mute:mute
bind PUB m|m ${mute(trigger)}av mute:av
bind PUB m|m ${mute(trigger)}unmute mute:umute
bind NICK -|- * mute:nick
bind JOIN -|- * mute:join
#
proc mute:join { nickname hostname handle channel } {
if {[channel get $channel muteinfo] == ""} {
if {[channel get $channel autovoice]} {
putquick "MODE $channel +v $nickname"
}
}
if {[channel get $channel muteinfo] != ""} {
set mute(nick) [lindex [split [channel get $channel muteinfo]] 0]
set mute(host) [lindex [split [channel get $channel muteinfo]] 1]
set host [lindex [split $hostname @] 1]
if {[string equal -nocase $nickname "$mute(nick)"] && [string equal -nocase "$host" $mute(host)]} {
putquick "NOTICE $nickname :Why are you rejoining after being muted?"
return 0
} elseif {[string equal -nocase "$host" $mute(host)]} {
putquick "NOTICE $nickname :Why are you rejoining after being muted?"
return 0
}
}
if {![channel get $channel autovoice] && [channel get $channel muted]} {
pushmode $channel +v $nickname
} elseif {![channel get $channel autovoice]} {
return 0
}
}
proc mute:av { nickname hostname handle channel arguments } {
set mode [lindex [split $arguments] 0]
switch $mode {
on {
if {[channel get $channel "autovoice"]} {
putquick "NOTICE $nickname :autovoice is already enabled for $channel."
return 0
}
channel set $channel +autovoice
putquick "NOTICE $nickname :autovoice has been enabled for $channel."
}
off {
if {![channel get $channel "autovoice"]} {
putquick "NOTICE $nickname :autovoice is already disabled for $channel."
return 0
}
channel set $channel -autovoice
putquick "NOTICE $nickname :autovoice has been disabled for $channel."}
default {
if {[channel get $channel "autovoice"]} {
putquick "NOTICE $nickname :autovoice is currently enabled for $channel."
} else {
putquick "NOTICE $nickname :autovoice is currently disabled for $channel."
}
}
}
}
proc mute:mute { nickname hostname handle channel arguments } {
set target [lindex [split $arguments] 0]
if {$target == ""} {
putquick "NOTICE $nickname :Please choose a target to mute."
return 0
}
if {![onchan $target $channel]} {
putquick "NOTICE $nickname :$target is not on $channel."
return 0
}
if {[isvoice $target $channel]} {
putquick "MODE $channel +m-v $target"
} else {
putquick "MODE $channel +m"
}
channel set $channel -autovoice
channel set $channel +muted
set host [lindex [split [getchanhost $target $channel] @] 1]
channel set $channel "muteinfo" "$target $host"
}
proc mute:umute { nickname hostname handle channel arguments } {
set target [lindex [split $arguments] 0]
if {$target == ""} {
putquick "NOTICE $nickname :Please choose a target to unmute."
return 0
}
if {![onchan $target $channel]} {
putquick "NOTICE $nickname :$target is not on $channel."
return 0
}
if {![isvoice $target $channel] && [regexp -- {m} [getchanmode $channel]]} {
putquick "MODE $channel +v $target"
channel set $channel +autovoice
channel set $channel -muted
channel set $channel "muteinfo" ""
return 0
} else {
channel set $channel +autovoice
channel set $channel -muted
channel set $channel "muteinfo" ""
return 0
}
}
proc mute:nick { nickname hostname handle channel newnick } {
if {[string match -nocase "*$nickname*" [lindex [split [channel get $channel mute]] 0]]} {
channel set $channel "muteinfo" "$newnick [lindex [split $hostname @] 1]"
putquick "NOTICE $newnick :You cannot escape mute by changing your nickname."
return 0
}
}
putlog "Mute $mute(version) by $mute(author)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment