Code: Select all
setudef flag voice-lower
proc voicelower:join {nick host hand chan} {
if {[channel get "$chan" "voice-lower"]} {
if {(![isbotnick "$nick"])&&(![regexp -- {[A-Z]} "$nick"])} {
pushmode $chan +v $nick
}
}
}
bind join -|- "*%*" voicelower:join
##
# Use: .chanset <#channel> +voice-lower To Enable
# Use: .chanset <#channel> -voice-lower TO Disable
##
Code: Select all
setudef flag voice-lower
proc voicelower:join {nick host hand chan} {
if {[channel get $chan voice-lower]} {
if {![isbotnick $nick] && [string equal $nick [string tolower $nick]]} {
pushmode $chan +v $nick
}
}
}
bind join - * voicelower:join
##
# Use: .chanset <#channel> +voice-lower To Enable
# Use: .chanset <#channel> -voice-lower TO Disable
##
Right.achilles1900 wrote:Hi TCL Community,
..., it does not, however, voice people who have capital letters in their lower case nicks
...
Code: Select all
[string equal $nick [string tolower $nick]
Code: Select all
proc voicelower:join {nick host hand chan} {
if {[channel get "$chan" "voice-lower"]} {
if {![isbotnick "$nick"]} {
set T [string bytelength $nick]
set U [regexp -all {[A-Z]} $nick]
if {$U < $T} {
pushmode $chan +v $nick
}
}
}
}
Code: Select all
nickname => will be voiced
nickNAME => will be voiced
NICKNAME => will not be voiced
Code: Select all
$ tclsh8.5
% regexp -- {^[A-Z]} "nickname"
0
% regexp -- {^[A-Z]} "Nickname"
1
Code: Select all
if {($U < $T)&&(![regexp -- {^[A-Z]} "$nick"])} {
Code: Select all
if {$U < $T} {
Code: Select all
proc voicelower:join {nick host hand chan} {
if {[channel get "$chan" "voice-lower"]} {
if {![isbotnick "$nick"]} {
# get rid of special characters in the nickname
regsub -all -- "(\\\\|\\\[|\\\]|\\\}|\\\{|_|-|`|\\\|)" "$nick" "" target
set T [string bytelength $target]
set U [regexp -all {[A-Z]} $target]
# dont voice if the first char in the nickname is a CAPITAL letter
if {($U < $T)&&(![regexp -- {^[A-Z]} "$target"])} {
pushmode $chan +v $target
}
}
}
}
Code: Select all
# get rid of special characters in the nickname
regsub -all -- "(\\\\|\\\[|\\\]|\\\}|\\\{|_|-|`|\\\|)" "$nick" "" target
Code: Select all
# get rid of special characters in the nickname
regsub -all -- "(\\\\|\\\[|\\\]|\\\}|\\\{|\\\^|_|-|`|\\\|)" "$nick" "" target
You can use regexp its pretty much the same with my usage of regsub. I've usedIs there a way where i can add special characters to ignore? I see that string there in your script, was wondering how could i modify it.
Code: Select all
... ![regexp -- {^[A-Z]} "$target"])} {
Code: Select all
(![regexp -- {\^} "$target"])
Code: Select all
regsub -all -- "(\\\\|\\\[|\\\]|\\\}|\\\{|_|-|`|\\\|)" "$nick" "" target
Code: Select all
setudef flag voice-lower
proc voicelower:join {nick host hand chan} {
if {[channel get "$chan" "voice-lower"]} {
if {![isbotnick "$nick"]} {
# get rid of special characters in the nickname
regsub -all -- "(\\\\|\\\[|\\\]|\\\}|\\\{|\\\^|``|\\\|)" "$nick" "" target
set T [string bytelength $target]
set U [regexp -all {[A-Z]} $target]
# dont voice if the first char in the nickname is a CAPITAL letter
if {($U < $T)&&(![regexp -- {^[A-Z]} "$target"])} {
pushmode $chan +v $target
}
}
}
}
bind join - * voicelower:join
##
# Use: .chanset <#channel> +voice-lower To Enable
# Use: .chanset <#channel> -voice-lower TO Disable
I dont understand this part, where do i insert the nickname characters in the code? ![regexp -- {^[A-Z]} {\^} "$target"])} { Like that?You can use regexp its pretty much the same with my usage of regsub. I've used
Code:
... ![regexp -- {^[A-Z]} "$target"])} {
to stop it from voicing people that have nickname that starts with a capital letter. And if you wanted to make sure it didn't voice anyone with a char in the nickname for example the ^ char again. you could add
Code:
(![regexp -- {\^} "$target"]
Code: Select all
if {($U < $T)&&(![regexp -- {^[A-Z]} "$target"])} {
Code: Select all
$ tclsh8.5
% set nick "nickname-with-<char to match>"
% regexp -- {<char to match>} "$nick"