mIRC Homepage
Posted By: unworthy Unique nick/alternate for every network - 09/02/09 06:29 PM
I always use a unique nick/alternate for every network. Is this possible in mIRC without installing a copy into multiple folders?

-unworthy
Posted By: RusselB Re: Unique nick/alternate for every network - 09/02/09 11:36 PM
Yes.

The method I use, is to store the information in a custom ini file, although there may (and probably are) other options.

An example from my ini file:
Quote:

[network1]
mnick = main nick
anick = alt nick
password = password


The I use the following script
Code:
on *:connect:{
  if $ini(connections.ini,$network) {
    .mnick $readini(connections.ini,n,$network,mnick)
    .anick $readini(connections.ini,n,$network,anick)
  }
}
on ^*:notice:*This nickname is registered and protected.*:*:{
  if ($nick == nickserv) {
    .msg nickserv $readini(connections.ini,n,$network,password)
  }
  haltdef
}
on *:disconnect:{
  if !$ini(connections.ini,$network) {
    .writeini -n connections.ini $network mnick $mnick
    .writeini -n connections.ini $network anick $anick
    .writeini -n connections.ini $network password $$?="Enter nickserv password for $network"
  }
}

Additionally the /server command will allow you to specify the main and alternate nicks using the -i switch

See /help /server for more details.
Posted By: unworthy Re: Unique nick/alternate for every network - 10/02/09 02:50 PM
Perfect! Thank you so much, Russel!

Code:
.writeini -n connections.ini $network password $$?="Enter nickserv password for $network"


By the way, that line doesn't seem to be working, as I disconnected from several networks and it created mnick/anick, but never asked for password, nor did it create an entry in connections.ini.
Posted By: RusselB Re: Unique nick/alternate for every network - 11/02/09 12:13 AM
Regretfully I'm at a loss to understand why that part didn't work, as I have been using that script for the past couple of years.
Posted By: Wims Re: Unique nick/alternate for every network - 11/02/09 12:44 AM
How are you disconnecting from several network ? I've tried to use $? in a on disconnect event, and even when I disconnect from several network, it work, i've used :
Code:
on *:disconnect:echo -a $$?="test $network "
Posted By: DJ_Sol Re: Unique nick/alternate for every network - 11/02/09 12:56 AM
$$?="test $network "

This shows a message box and cannot be used in a script event. Best to just echo the window with normal text and identifiers. $nick . $network . $server . $me . $scid($cid).mnick

Also, right before you connect you can set nick. /nick newnick

Like,

server -n irc.server.net | nick <nickname> | server irc.server.net

This will open a new status window and crate a cid for the new connection but not connect to it. Then set nick and connect to server.
Posted By: Wims Re: Unique nick/alternate for every network - 11/02/09 01:10 AM
Tell me you have tested, before came here and say this...
It work perfectly fine, try it.
If you use //scid -at1 disconnect, it disconnect you from the first server connected, then waiting for the input request, then disconnect from the second server connect etc...
Also :

Originally Posted By: DJ_Sol
server -n irc.server.net | nick <nickname> | server irc.server.net

Originally Posted By: RusselB
Additionally the /server command will allow you to specify the main and alternate nicks using the -i switch
-m and -i could/should be used
Posted By: unworthy Re: Unique nick/alternate for every network - 11/02/09 01:35 AM
Originally Posted By: Wims
How are you disconnecting from several network ? I've tried to use $? in a on disconnect event, and even when I disconnect from several network, it work, i've used :
Code:
on *:disconnect:echo -a $$?="test $network "


Using /quit or the disconnect button. Neither prompted.
Posted By: Wims Re: Unique nick/alternate for every network - 11/02/09 02:17 AM
The problem is simple, what happen here is that $network" does not exists, mirc would said it if you have checked the "identifier warning option" in the mIRC script editor, but since there's a '.', it quiet the output and you don't see anything.
The question is why is there a dot since /writeini does not output a message that could be annoying (like /timer) ? I've seen so many script (whole script or not) do this on several command, always wondering why they wanted to hide errors...
Posted By: unworthy Re: Unique nick/alternate for every network - 11/02/09 03:13 AM
Originally Posted By: Wims
The problem is simple, what happen here is that $network" does not exists,


Ah, yes. So, mirc sees the ." as part of the variable name. I added a space and it works exactly as expected. That's definitely a bug, as mirc should know the ." isn't part of the name, once it finds that the character after the . isn't alphanumeric. Instead, mirc thinks it's looking for the " property of the $network variable!

Thanks to Wims, and everyone, for the help.
Posted By: unworthy Re: Unique nick/alternate for every network - 11/02/09 03:22 AM
Originally Posted By: RusselB
Regretfully I'm at a loss to understand why that part didn't work, as I have been using that script for the past couple of years.


Sure, but when was the last time you disconnected from a network that you'd never visited, or that wasn't already present in connections.ini? wink I'm thinking that doesn't happen very often. laugh
Posted By: Wims Re: Unique nick/alternate for every network - 11/02/09 03:30 AM
There's no bug.
The dot '.' is used to quiet output, this mean that nothing will be print out.
If for example you do //timer 1 1 noop, it will echo in you window :
Quote:
* Timer 1 activated
* Timer 1 halted
If now you do //.timer 1 1 noop, you won't see this message.
In the situation above, mirc parse $network" as an identifier and simply, either tell you that it does not exists if you have enabled the option "identifier warning" (as an error message), either it return the $null value.In both case, mirc will stop because it's either an error and mirc stop, either the double $ make mirc stop because he his seeing $$?="... (this return $null too).This is why RusselB never see any error, not because he doesn't use his feature often.
Posted By: RusselB Re: Unique nick/alternate for every network - 11/02/09 03:47 AM
You'd be right that it's been a while.. probably a year minimum.
Posted By: unworthy Re: Unique nick/alternate for every network - 11/02/09 05:10 AM
Originally Posted By: Wims
There's no bug.
The dot '.' is used to quiet output, this mean that nothing will be print out.
If for example you do //timer 1 1 noop, it will echo in you window


I think you've misunderstood what I wrote. I realize that the '.' in front of writeini silences the output, however, that isn't the problem to which I'm referring. The '.' at the very end of the line is the problem.

By adding a space after the 2nd $network, and before the '.' at the very end, the line works exactly as expected, because $network is defined, but $network[size:14pt].
isn't defined. (Notice the trailing period?)

That's the bug, (in my opinion), because mirc shouldn't see the '.' as being part of the variable name unless an alphanumeric character follows it.[/size]
Posted By: RusselB Re: Unique nick/alternate for every network - 11/02/09 06:03 AM
This is not a bug, but, imo, expected behaviour.

It is possible to set up an alias called network. and call it as an identifier (see /help $isid)

In the code I provided $network exists but $network. does not
(ie: there is no trailing period with the $network identifier anywhere in the code I provided).

If you alter a working code and it stops working, then the problem is with the alteration of the code, not with mIRC.
Posted By: DJ_Sol Re: Unique nick/alternate for every network - 11/02/09 10:47 AM
Yeah, teh identifier is $network, not $network. The bug is yours. smile Typo's are my bane!



$?*!="message"

Note: This identifier cannot be used in a script event.

So why does it work in the disconnect event then?
Posted By: Wims Re: Unique nick/alternate for every network - 11/02/09 01:51 PM
I was beleived this note was for $input but indeed, don't know why.
Posted By: unworthy Re: Unique nick/alternate for every network - 11/02/09 02:42 PM
Originally Posted By: RusselB
This is not a bug, but, imo, expected behaviour.

It is possible to set up an alias called network. and call it as an identifier (see /help $isid)


Alright, let's call it a feature. It is possible, but that doesn't give it an established purpose or make it especially useful. On the other hand, the purpose of a leading period in an identifier is well established. (e.g. echo -q) Of course, I may have forgotten, or missed, something in the docs, so don't hesitate to correct any mistake on my part.

Quote:
In the code I provided $network exists but $network. does not
(ie: there is no trailing period with the $network identifier anywhere in the code I provided).


Hm, nor is there one in my reply. I must be suffering from some form of dementia or senility in my old age crazy, because I don't remember making alterations. blush In fact, that must have been the only alteration, because the rest of the script matches verbatim. shocked

Quote:
If you alter a working code and it stops working, then the problem is with the alteration of the code, not with mIRC.


I couldn't agree more, except for the last three words. The usefulness of a trailing period in an identifier is somewhat debatable, imo.

In any case, thanks again for sharing the wonderful script! Huzzah!
Posted By: DJ_Sol Re: Unique nick/alternate for every network - 11/02/09 04:26 PM
Many times Ive hit a ket without knowing while the script editor was open. Lol, or start typing somewhere else but the cursor was in the remote editor?? I can't be alone on this.
Posted By: unworthy Re: Unique nick/alternate for every network - 12/02/09 03:16 PM
I'd like to alter this script to update the e-mail address, as well, however, the connect event doesn't occur until after the connection is already made, and thus, uses the previous emailaddr setting. What's the best method of scripting an update to the setting just prior to connection?

Originally Posted By: RusselB

The I use the following script
Code:
on *:connect:{
  if $ini(connections.ini,$network) {
    .mnick $readini(connections.ini,n,$network,mnick)
    .anick $readini(connections.ini,n,$network,anick)
  }
}
on ^*:notice:*This nickname is registered and protected.*:*:{
  if ($nick == nickserv) {
    .msg nickserv $readini(connections.ini,n,$network,password)
  }
  haltdef
}
on *:disconnect:{
  if !$ini(connections.ini,$network) {
    .writeini -n connections.ini $network mnick $mnick
    .writeini -n connections.ini $network anick $anick
    .writeini -n connections.ini $network password $$?="Enter nickserv password for $network"
  }
}

Posted By: RusselB Re: Unique nick/alternate for every network - 12/02/09 03:31 PM
You could try using /emailaddr
If this doesn't work directly, you could also force a disconnect then a reconnect using a combination of the ON DISCONNECT and an offline timer.
Posted By: unworthy Re: Unique nick/alternate for every network - 12/02/09 03:34 PM
Originally Posted By: RusselB
/help /emailaddr


I know how to change the e-mail address. That wasn't the question.
Posted By: RusselB Re: Unique nick/alternate for every network - 12/02/09 03:37 PM
read edited post
Posted By: argv0 Re: Unique nick/alternate for every network - 14/02/09 04:55 AM
see /help ON LOGON, you can hook into the connection process before mIRC sends out user info.

Just as a note by the way, you mentioned something about how mIRC should differentiate a variable from punctuation because it's "not alphanumeric". There is no rule that variables are only made up of alphanumeric characters. In reality, any of the 255 characters except $chr(32) and a few other specials can be used in a variable name: //set %x $+ $chr(9) xyz | echo -a $($+(%,x,$chr(9)),2) (chr9 is the tab character by the way) -- there is no way for mIRC to differentiate in this case.
Posted By: RusselB Re: Unique nick/alternate for every network - 14/02/09 01:50 PM
In addition to argv0's post regarding the variables, I have yet to see a program that doesn't accept the . as an alphanumeric character, as it is used on a numeric basis as a decimal for numbers that could be displayed as a fraction, rather than a whole number.
© mIRC Discussion Forums