| | 
 
| 
| 
|  |  
| 
Joined:  May 2022 Posts: 136 Vogon poet |  
| OP   Vogon poet Joined:  May 2022 Posts: 136 | 
I wish to have an addon that on join, check the user nick. I already have the one that invite to change nick in case of BADNICK (using BADWORD) Now I wish this addon also to check if: - Nick letters are less than 3 - Nick letters are more than 30% upper case. ON @*:JOIN:#channel: { if (LETTERS < 3) && ([UPPER LETTERS > 30%) badnick_alias $unsafe($chan $nick) }
ON *:NICK: { if (LETTERS < 3) && (UPPER LETTERS > 30%) && ($me isop #channel) && ($newnick ison #channel)) badnick_alias $unsafe(#channel $newnick) }
alias badnick_alias {
  var %chan $1 , %nick $2
  if ((MindUser* !iswm %nick) || (%nick !ison %chan)) return
  if (!$3) {
    .notice %nick Please change your nick within 2 minutes, or you will be kicked.
    .timer 1  30 badnick_alias $unsafe($1-2  30)
    .timer 1  90 badnick_alias $unsafe($1-2  90)
    .timer 1 120 badnick_alias $unsafe($1-2 120)
    return
  }
  elseif ($3 == 30) /notice %nick This is your second warning change your nick or be kicked 1 minute remaining!!
  elseif ($3 == 90) /notice %nick This is your LAST warning change your nick or be kicked 30 seconds remaining!!
  elseif ($3 == 120) kick %chan %nick Please change your nickAny help please? Thanks
Last edited by Fernet; 03/03/25 02:48 PM.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2006 Posts: 4,032 Hoopy frood |  
|   Hoopy frood Joined:  Jul 2006 Posts: 4,032 | 
If you want to use && on the two conditions length of nick < 3 and % of uppercase in nick > 30% that makes no sense as you're really checking at best nickname of 2 character, aka either 100% or 50% which is then equivalent to checking if there's any uppercase at all. $unsafe should only be used on command which double evaluate, aka the typical /timer or /scid or /scon otherwise you'll be passing incorrect value to the alias. I'll use || which makes more sense for the condition. on *:nick:if (($len($nick) < 3) || ($calc($regex($nick,/[A-Z]/g) * 100 / $len($nick)) > 30)) && ($me isop #Alessandra) && ($newnick ison #Alessandra) badnick_alias #alessandra $newnick
For on join it is not so easy because when you join a channel, mIRC does not know the users on the channel yet. For that you must use raw 353 on *:join:#:set %checknick $+ $chan 1
raw 353:*:{
  if ($($+(%,checknick,$3),2)) { 
    var %chan $3
    tokenize 32 $regsubex($regsubex($4-,^:,),/(?:[ $+ $prefix $+ ]*)([^ !]+)\S+/g,\1 $+ $chr(32))
    echo -ag $1-
    scon -r if ($len( $* ) < 3) || ($calc($regex( $* ,/[A-Z]/g) * 100 / $!len( $* )) > 30) badnick_alias $unsafe(%chan) $*
  }
}
raw 366:*:if ($($+(%,checknick,$2),2)) unset %checknick $+ $2You may restrict this to your channel only by setting %checknick $+ $chan only if you join your specific channel. 
 #mircscripting @ irc.swiftirc.net == the best mIRC help channel
 |  |  |  
| 
| 
|  |  
| 
Joined:  May 2022 Posts: 136 Vogon poet |  
| OP   Vogon poet Joined:  May 2022 Posts: 136 | 
Is it right? 
on *:join:#channel:set %checknick $+ $chan 1
raw 353:*:{
  if ($($+(%,checknick,$3),2)) { 
    var %chan $3
    tokenize 32 $regsubex($regsubex($4-,^:,),/(?:[ $+ $prefix $+ ]*)([^ !]+)\S+/g,\1 $+ $chr(32))
    echo -ag $1-
    scon -r if ($len( $* ) < 3) || ($calc($regex( $* ,/[A-Z]/g) * 100 / $!len( $* )) > 30) badnick_alias $unsafe(%chan) $*
  }
}
raw 366:*:if ($($+(%,checknick,$2),2)) unset %checknick $+ $2
alias badnick_alias {
  var %chan $1 , %nick $2
  if ((MindUser* !iswm %nick) || (%nick !ison %chan)) return
  if (!$3) {
    .notice %nick Please change your nick within 2 minutes, or you will be kicked.
    .timer 1  30 badnick_alias $unsafe($1-2  30)
    .timer 1  90 badnick_alias $unsafe($1-2  90)
    .timer 1 120 badnick_alias $unsafe($1-2 120)
    return
  }
  elseif ($3 == 30) /notice %nick This is your second warning change your nick or be kicked 1 minute remaining!!
  elseif ($3 == 90) /notice %nick This is your LAST warning change your nick or be kicked 30 seconds remaining!!
  elseif ($3 == 120) kick %chan %nick Please change your nick
}
 |  |  |  
| 
| 
|  |  
| 
Joined:  Nov 2021 Posts: 166 Vogon poet |  
|   Vogon poet Joined:  Nov 2021 Posts: 166 | 
you could try this  
ON *:nick:{
  haltdef
  var %whloop = 1
  while ( $comchan($newnick,%whloop) != $null )  {
    var %chan $v1
    if ($istok(Dalnet undernet,$network,32) && $istok(#chan,%chan,32)) {
      if ($nick(%chan,$newnick,@&~%) || !$nick(%chan,$me,@&~%)) { halt } 
      badnick_alias %chan $newnick 
    }
    inc %whloop
  }
  halt
}
on !*:JOIN:#:{
  if ($istok(Dalnet undernet,$network,32) && $istok(#chan,$chan,32)) {
    if (!$Timer($+(CheckNicks,.,$network,.,$chan,.,$nick))) {  .Timer $+ $+(CheckNicks,.,$network,.,$chan,.,$nick)  -md 1 750 badnick_alias $unsafe($chan) $nick  } 
  }
}
alias badnick_alias {
  var %chan $1 , %nick $2
   if (MindUser* !iswm %nick || %nick !ison %chan || $nick( %chan , %nick ,@&~%)) { halt }
   if ($len( %nick ) > 3 || ($calc($regex(%nick,/[A-Z]/g) * 100 / $len(%nick)) > 30)) { kick %chan %nick please change your nick thanks you.... }  
}
 |  |  |  
| 
| 
|  |  
| 
Joined:  May 2022 Posts: 136 Vogon poet |  
| OP   Vogon poet Joined:  May 2022 Posts: 136 | 
Thanks sir. Then can I add warning? 
 if (!$3) {
    .notice %nick Please change your nick within 2 minutes, or you will be kicked.
    .timer 1  30 badnick_alias $unsafe($1-2  30)
    .timer 1  90 badnick_alias $unsafe($1-2  90)
    .timer 1 120 badnick_alias $unsafe($1-2 120)
    return
  }
  elseif ($3 == 30) /notice %nick This is your second warning change your nick or be kicked 1 minute remaining!!
  elseif ($3 == 90) /notice %nick This is your LAST warning change your nick or be kicked 30 seconds remaining!!
  elseif ($3 == 120) kick %chan %nick Please change your nick
}
 |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2006 Posts: 4,032 Hoopy frood |  
|   Hoopy frood Joined:  Jul 2006 Posts: 4,032 | 
Yes, there's a small error with the on join event (my mistake), it must only trigger when you join the channel, not for others:
 on me:*:join:#channel:set %checknick $+ $chan 1
 
 #mircscripting @ irc.swiftirc.net == the best mIRC help channel
 |  |  |  
| 
| 
|  |  
| 
Joined:  May 2022 Posts: 136 Vogon poet |  
| OP   Vogon poet Joined:  May 2022 Posts: 136 | 
Yes, there's a small error with the on join event (my mistake), it must only trigger when you join the channel, not for others:
 on me:*:join:#channel:set %checknick $+ $chan 1
Doesn't work on join. On an user nick change, it works, warn included. On nick jooin, it doesn't work |  |  |  
| 
| 
|  |  
| 
Joined:  May 2022 Posts: 136 Vogon poet |  
| OP   Vogon poet Joined:  May 2022 Posts: 136 | 
you could try this  
    if ($istok(Dalnet undernet,$network,32) && $istok(#chan,%chan,32)) 
  if ($istok(Dalnet undernet,$network,32) && $istok(#chan,$chan,32)) {
I'm on another net. This doesn't work for me. I dunno if is just a matter of net... |  |  |  
| 
| 
|  |  
| 
Joined:  Nov 2021 Posts: 166 Vogon poet |  
|   Vogon poet Joined:  Nov 2021 Posts: 166 | 
i guess you could add your network in it. |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2006 Posts: 4,032 Hoopy frood |  
|   Hoopy frood Joined:  Jul 2006 Posts: 4,032 | 
I misunderstood, you may keep the current code for when YOU (the bot) rejoin the channel to do a one time scan on all nick. You then need to add an on join event which trigger for others only which would be a copy of the on nick event: on @:join:#alessandra:if (($len($nick) < 3) || ($calc($regex($nick,/[A-Z]/g) * 100 / $len($nick)) > 30)) badnick_alias #alessandra $nick
The @ event prefix should ensure that the event only triggers for others (you are not op when you join) 
 #mircscripting @ irc.swiftirc.net == the best mIRC help channel
 |  |  |  
| 
| 
|  |  
| 
Joined:  May 2022 Posts: 136 Vogon poet |  
| OP   Vogon poet Joined:  May 2022 Posts: 136 | 
I misunderstood, you may keep the current code for when YOU (the bot) rejoin the channel to do a one time scan on all nick. You then need to add an on join event which trigger for others only which would be a copy of the on nick event: on @:join:#alessandra:if (($len($nick) < 3) || ($calc($regex($nick,/[A-Z]/g) * 100 / $len($nick)) > 30)) badnick_alias #alessandra $nick
The @ event prefix should ensure that the event only triggers for others (you are not op when you join)No need brackets? 
on @:join:#alessandra: {
if (($len($nick) < 3) || ($calc($regex($nick,/[A-Z]/g) * 100 / $len($nick)) > 30)) badnick_alias #alessandra $nick
}
 |  |  |  
| 
| 
|  |  
| 
Joined:  May 2022 Posts: 136 Vogon poet |  
| OP   Vogon poet Joined:  May 2022 Posts: 136 | 
i guess you could add your network in it.I'll try again again sir. Thanks in advance for help of course |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2006 Posts: 4,032 Hoopy frood |  
|   Hoopy frood Joined:  Jul 2006 Posts: 4,032 | 
No, brackets can be omitted when the commands associated to the alias/event are on a single line separated by |, and for conditional statement when there's only a single command associated to that condition.Though, one may note that mIRC has issues parsing certain keywords (reserved words for statement such as "if" or "while", these statement cannot be overrided with aliases) when they are chained together  without bracket, it's pretty rare to be in such situation even for bracketless lovers like me but for example "//if (a) while (1) echo -ag test" will not result in an infinite loop, which it should.
 
 edit: I forgot the * access level after the @ event prefix.
 
Last edited by Wims; 05/03/25 10:01 PM.
 
 #mircscripting @ irc.swiftirc.net == the best mIRC help channel
 |  |  |  
| 
| 
|  |  
| 
Joined:  May 2022 Posts: 136 Vogon poet |  
| OP   Vogon poet Joined:  May 2022 Posts: 136 | 
No, brackets can be omitted when the commands associated to the alias/event are on a single line separated by |, and for conditional statement when there's only a single command associated to that condition.Though, one may note that mIRC has issues parsing certain keywords (reserved words for statement such as "if" or "while", these statement cannot be overrided with aliases) when they are chained together  without bracket, it's pretty rare to be in such situation even for bracketless lovers like me but for example "//if (a) while (1) echo -ag test" will not result in an infinite loop, which it should.
 
 edit: I forgot the * access level after the @ event prefix.
What do You think with this: 
on @*:join:#channel:if (($len($nick) < 3) || ($calc($regex($nick,/[A-Z]/g) * 100 / $len($nick)) > 30)) badnick_alias #channel $nick
on *:nick:if (($len($nick) < 3) || ($calc($regex($nick,/[A-Z]/g) * 100 / $len($nick)) > 30)) && ($me isop #channel) && ($newnick ison #channel) badnick_alias #channel $newnick
alias badnick_alias {
  var %chan $1 , %nick $2
  if ((MindUser* !iswm %nick) || (%nick !ison %chan)) return
  if (!$3) {
    .notice %nick WARN
    .timer 1  30 badnick_alias $unsafe($1-2  30)
    .timer 1  45 badnick_alias $unsafe($1-2  45)
    .timer 1 60 badnick_alias $unsafe($1-2 60)
    return
  }
  elseif ($3 == 30) /notice %nick SECOND WARN
  elseif ($3 == 45) /notice %nick LAST WARN
  elseif ($3 == 60) kick %chan %nick KICK
}
 |  |  |  
| 
| 
|  |  
| 
Joined:  May 2022 Posts: 136 Vogon poet |  
| OP   Vogon poet Joined:  May 2022 Posts: 136 | 
you could try this  
ON *:nick:{
  haltdef
  var %whloop = 1
  while ( $comchan($newnick,%whloop) != $null )  {
    var %chan $v1
    if ($istok(Dalnet undernet,$network,32) && $istok(#chan,%chan,32)) {
      if ($nick(%chan,$newnick,@&~%) || !$nick(%chan,$me,@&~%)) { halt } 
      badnick_alias %chan $newnick 
    }
    inc %whloop
  }
  halt
}
on !*:JOIN:#:{
  if ($istok(Dalnet undernet,$network,32) && $istok(#chan,$chan,32)) {
    if (!$Timer($+(CheckNicks,.,$network,.,$chan,.,$nick))) {  .Timer $+ $+(CheckNicks,.,$network,.,$chan,.,$nick)  -md 1 750 badnick_alias $unsafe($chan) $nick  } 
  }
}
alias badnick_alias {
  var %chan $1 , %nick $2
   if (MindUser* !iswm %nick || %nick !ison %chan || $nick( %chan , %nick ,@&~%)) { halt }
   if ($len( %nick ) > 3 || ($calc($regex(%nick,/[A-Z]/g) * 100 / $len(%nick)) > 30)) { kick %chan %nick please change your nick thanks you.... }  
}
Doesn't work. Non error in status. |  |  |  
| 
| 
|  |  
| 
Joined:  May 2022 Posts: 136 Vogon poet |  
| OP   Vogon poet Joined:  May 2022 Posts: 136 | 
If you want to use && on the two conditions length of nick < 3 and % of uppercase in nick > 30% that makes no sense as you're really checking at best nickname of 2 character, aka either 100% or 50% which is then equivalent to checking if there's any uppercase at all. $unsafe should only be used on command which double evaluate, aka the typical /timer or /scid or /scon otherwise you'll be passing incorrect value to the alias. I'll use || which makes more sense for the condition. on *:nick:if (($len($nick) < 3) || ($calc($regex($nick,/[A-Z]/g) * 100 / $len($nick)) > 30)) && ($me isop #Alessandra) && ($newnick ison #Alessandra) badnick_alias #alessandra $newnick
For on join it is not so easy because when you join a channel, mIRC does not know the users on the channel yet. For that you must use raw 353 on *:join:#:set %checknick $+ $chan 1
raw 353:*:{
  if ($($+(%,checknick,$3),2)) { 
    var %chan $3
    tokenize 32 $regsubex($regsubex($4-,^:,),/(?:[ $+ $prefix $+ ]*)([^ !]+)\S+/g,\1 $+ $chr(32))
    echo -ag $1-
    scon -r if ($len( $* ) < 3) || ($calc($regex( $* ,/[A-Z]/g) * 100 / $!len( $* )) > 30) badnick_alias $unsafe(%chan) $*
  }
}
raw 366:*:if ($($+(%,checknick,$2),2)) unset %checknick $+ $2You may restrict this to your channel only by setting %checknick $+ $chan only if you join your specific channel.Doesn't work |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2006 Posts: 4,032 Hoopy frood |  
|   Hoopy frood Joined:  Jul 2006 Posts: 4,032 | 
I tested this code with the non event prefixed on join and the raw events with both a nickname of 2 characters and a nickname with more than 30% of uppercase and it triggered a badnick_alias alias I had created to test the code. Feel free to join the channel in my signature if you want further help as there could be any kind of reason as to why it's not working for you, and figuring it out on a forum is more complicated than on IRC. 
 #mircscripting @ irc.swiftirc.net == the best mIRC help channel
 |  |  |  
| 
| 
|  |  
| 
Joined:  May 2022 Posts: 136 Vogon poet |  
| OP   Vogon poet Joined:  May 2022 Posts: 136 | 
I tested this code with the non event prefixed on join and the raw events with both a nickname of 2 characters and a nickname with more than 30% of uppercase and it triggered a badnick_alias alias I had created to test the code. Feel free to join the channel in my signature if you want further help as there could be any kind of reason as to why it's not working for you, and figuring it out on a forum is more complicated than on IRC.I decided to split the addon. So maybe I'll make 2 differents (one for upper and one for letters). This is the one if letters < 3: 
on *:JOIN:#channel:{
  if (($len($nick) < 3) { /badnick_alias $chan $nick }
}
on *:nick:if (($len($nick) < 3)) badnick_alias #channel $nick
alias badnick_alias {
  var %chan $1 , %nick $2
  if (%nick !ison %chan) return
  if (!$3) {
    notice %nick FIRST WARN
    .timer 1 30 badnick_alias %chan %nick 30
    .timer 1 45 badnick_alias %chan %nick 45
    .timer 1 60 badnick_alias %chan %nick 60
    return
  }
  elseif ($3 == 30) notice %nick SECOND WARN
  elseif ($3 == 45) notice %nick LAST WARN
  elseif ($3 == 60) kick %chan %nick KICK
}
And doesn't work. I forgot to tell: mIRC is 7.78 and no other addons loaded (so no conflict) |  |  |  
| 
| 
|  |  
| 
Joined:  May 2022 Posts: 136 Vogon poet |  
| OP   Vogon poet Joined:  May 2022 Posts: 136 | 
I tested this code........I decided to split the addon. So maybe I'll make 2 differents (one for upper and one for letters). This is the one if letters < 3: 
...........
on *:nick:if (($len($nick) < 3)) badnick_alias #channel $nick
............
And doesn't work. I forgot to tell: mIRC is 7.78 and no other addons loaded (so no conflict)I solved with: 
on *:nick:if (($len($newnick) < 3)) badnick_alias #`Chandra_Area51 $newnick
 |  |  |  
| 
| 
|  |  
| 
Joined:  Nov 2021 Posts: 166 Vogon poet |  
|   Vogon poet Joined:  Nov 2021 Posts: 166 | 
ive tested this and it all works for me Note: ive used a stacked nicks in the on op event if your networks allows stacked kicks and modes kick #channel nick,nick,nick,nick,nick,nick  not sure on what network you are gonna use this as some networks allow stacked kicks. 
ON *:nick:{
  haltdef
  var %whloop = 1
  while ( $comchan($newnick,%whloop) != $null )  {
    var %chan $v1
    if (!$nick(%chan,$newnick,@&~%) && $nick(%chan,$me,@&~%)) { badnick_alias %chan $newnick  }
    inc %whloop
  }
  halt
}
ON *:op:#:{
  if ($opnick == $me) {
    var %loop = 1, %nick , %kickmsg = please change your nick thanks you.... 
    while (%loop <= $nick($chan,0)) {
      %nick = $nick($chan,%loop)
      if ($len( %nick ) < 3 || ($calc($regex(%nick,/[A-Z]/g) * 100 / $len(%nick)) > 30)) { 
        if (!$nick( %chan , %nick ,~&@%)) { var %kick = $addtok(%kick,%nick,44) }
        if ($numtok(%kick,44) == 4) { kick $chan %kick %kickmsg | unset %kick }      
      }  
      inc %loop 1
    }
  }
  if (%kick) { kick $chan %kick %kickmsg }
}
on !*:JOIN:#test:{
  if (!$Timer($+(CheckNicks,.,$network,.,$chan,.,$nick))) {   .Timer $+ $+(CheckNicks,.,$network,.,$chan,.,$nick)  -md 1 750 badnick_alias $unsafe($chan) $nick  } 
}
alias badnick_alias {
  var %chan $1 , %nick $2
  if (%nick !ison %chan || $nick( %chan , %nick ,@&~%)) { halt }
  if ($len( %nick ) < 3 || ($calc($regex(%nick,/[A-Z]/g) * 100 / $len(%nick)) > 30)) { kick %chan %nick please change your nick thanks you.... }  
}
 |  |  |  
 | 
 |