mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#273252 03/03/25 01:17 PM
Joined: May 2022
Posts: 103
F
Fernet Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: May 2022
Posts: 103
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.

Code
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 nick

Any help please? Thanks

Last edited by Fernet; 03/03/25 02:48 PM.
Fernet #273253 03/03/25 03:11 PM
Joined: Jul 2006
Posts: 4,222
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,222
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.

Code
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

Code
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 $+ $2
You 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
Wims #273254 03/03/25 05:05 PM
Joined: May 2022
Posts: 103
F
Fernet Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: May 2022
Posts: 103
Is it right?

Code
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
}

Fernet #273256 04/03/25 12:10 AM
Joined: Nov 2021
Posts: 135
Vogon poet
Online
Vogon poet
Joined: Nov 2021
Posts: 135
you could try this

Code


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.... }  
}





Simo #273260 04/03/25 02:28 PM
Joined: May 2022
Posts: 103
F
Fernet Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: May 2022
Posts: 103
Thanks sir. Then can I add warning?

Code
 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
}

Fernet #273262 04/03/25 05:26 PM
Joined: Jul 2006
Posts: 4,222
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,222
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
Wims #273263 04/03/25 06:11 PM
Joined: May 2022
Posts: 103
F
Fernet Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: May 2022
Posts: 103
Originally Posted by Wims
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

Simo #273264 04/03/25 06:33 PM
Joined: May 2022
Posts: 103
F
Fernet Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: May 2022
Posts: 103
Originally Posted by Simo
you could try this

Code



    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...

Fernet #273265 04/03/25 08:31 PM
Joined: Nov 2021
Posts: 135
Vogon poet
Online
Vogon poet
Joined: Nov 2021
Posts: 135
i guess you could add your network in it.

Fernet #273266 04/03/25 09:49 PM
Joined: Jul 2006
Posts: 4,222
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,222
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:

Code
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
Wims #273269 05/03/25 05:35 PM
Joined: May 2022
Posts: 103
F
Fernet Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: May 2022
Posts: 103
Originally Posted by Wims
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:

Code
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?

Code
on @:join:#alessandra: {
if (($len($nick) < 3) || ($calc($regex($nick,/[A-Z]/g) * 100 / $len($nick)) > 30)) badnick_alias #alessandra $nick
}

Simo #273270 05/03/25 05:37 PM
Joined: May 2022
Posts: 103
F
Fernet Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: May 2022
Posts: 103
Originally Posted by Simo
i guess you could add your network in it.

I'll try again again sir. Thanks in advance for help of course

Fernet #273271 05/03/25 06:07 PM
Joined: Jul 2006
Posts: 4,222
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,222
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
Wims #273272 06/03/25 12:36 PM
Joined: May 2022
Posts: 103
F
Fernet Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: May 2022
Posts: 103
Originally Posted by Wims
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:

Code
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
}

Simo #273274 07/03/25 02:16 PM
Joined: May 2022
Posts: 103
F
Fernet Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: May 2022
Posts: 103
Originally Posted by Simo
you could try this

Code


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.

Wims #273275 07/03/25 02:26 PM
Joined: May 2022
Posts: 103
F
Fernet Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: May 2022
Posts: 103
Originally Posted by Wims
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.

Code
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

Code
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 $+ $2
You may restrict this to your channel only by setting %checknick $+ $chan only if you join your specific channel.

Doesn't work

Fernet #273276 07/03/25 06:57 PM
Joined: Jul 2006
Posts: 4,222
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,222
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
Wims #273280 09/03/25 05:14 PM
Joined: May 2022
Posts: 103
F
Fernet Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: May 2022
Posts: 103
Originally Posted by Wims
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:

Code
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)

Fernet #273281 10/03/25 02:00 PM
Joined: May 2022
Posts: 103
F
Fernet Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: May 2022
Posts: 103
Originally Posted by Fernet
Originally Posted by Wims
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:

Code
...........

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:
Code
on *:nick:if (($len($newnick) < 3)) badnick_alias #`Chandra_Area51 $newnick

Fernet #273282 10/03/25 04:55 PM
Joined: Nov 2021
Posts: 135
Vogon poet
Online
Vogon poet
Joined: Nov 2021
Posts: 135
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.

Code


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.... }  
}



Page 1 of 2 1 2

Link Copied to Clipboard