I'm working on an auto voice/devoice script snippet for an mIRC bot when a nick is lower case it'll voice the nick. Then when the nick is changed and it's upper it should devoice people or if there's an upper nick to lower case nick it voices them. My issue is it won't recognize nick changes to voice or devoice a user.
#lowercheck on
alias -l _c return #
alias startwithlower {
if ( $1 ) {
return $islower($left($regsubex($$1,/\W+/g,$null),1))
}
else return $false
}
on @*:JOIN:#Tristram_Halls:{
if ( $startwithlower($nick) == $true ) {
mode $_c +v $nick
}
}
on @*:NICK:{
if ( ( $startwithlower($newnick) == $false ) && ( $newnick !isvoice $_c ) ) {
mode $_c -v $newnick
}
elseif ( ( $startwithlower($newnick) == $true ) && ( $newnick isvoice $_c ) ) {
mode $_c +v $newnick
}
}
ON NICK
is action that happens on nick and execute for every channel, than if your bot should handle many channels it should change how you voice the user in every channel you want to grant him a voice.
If the bot only has OP+ control in 1 channel than the following will fix you issue (you switched between isvoice
for both cases):
on @*:NICK:{
if ( ( $startwithlower($newnick) == $false ) && ( $newnick isvoice $_c ) ) {
mode $_c -v $newnick
}
elseif ( ( $startwithlower($newnick) == $true ) && ( $newnick !isvoice $_c ) ) {
mode $_c +v $newnick
}
}
A nicer implementation will be:
#lowercheck on
alias -l _c return #
alias startwithlower {
return $1 && $islower($left($regsubex($$1,/\W+/g,$null),1))
}
on @*:JOIN:#Tristram_Halls:{
if ($startwithlower($nick)) {
mode $_c +v $nick
}
}
on @*:NICK:{
if ($startwithlower($newnick)) {
if ($newnick !isvoice $_c) {
mode $_c +v $newnick
}
}
else
{
if ($newnick isvoice $_c) {
mode $_c -v $newnick
}
}
}