mIRC Homepage

Joining several servers and channels upon launch

Posted By: mindcooler

Joining several servers and channels upon launch - 07/04/04 10:08 PM

Hello everyone! Right now I have set-up mIRC to, upon launch, connect to a server (which happens to be a server on the Undernet network). For every server I join, I always join the three same channels.
Since I always hang in three different networks (but the "same" channel in those networks), I would like mIRC to join these three networks upon launch (and the three channels for each network). Can I do this? The ultimate configuration is for mIRC to try a number of specified servers for each network in case a server is down. If this cannot be done through setting options in mIRC or through scripting, can it be done if I write a DLL?

Thanks for any replies
Posted By: Mentality

Re: Joining several servers and channels upon launch - 07/04/04 10:35 PM

This is only an example:

Code:
on *:start:{
  server [color:red]uk.undernet.org[/color]
  server -m [color:green]uk.quakenet.org[/color]
  server -m [color:purple]irc.demon.co.uk[/color]
}
on *:connect:{
  if ($network == [color:red]Undernet[/color]) {
    join [color:orange]#testgobbly,#munkytest,#cookiestest[/color] 
  }
  if ($network == [color:green]Quakenet[/color]) {
    join [color:orange]#testgobbly,#munkytest,#cookiestest[/color]
  }
  if ($network == [color:purple]IRCNet[/color]) {
    join [color:orange]#testgobbly,#munkytest,#cookiestest[/color] 
  }
}


The bits that are in colour can be changed to suit your needs. This is an example to show what you'd do if you wanted to join #testgobbly, #munkytest and #cookiestest on all 3 of Undernet, Quakenet and IRCnet.

The if ($network== bit needs to be changed to whatever $network returns on the networks you join. To find out, simply connect to your networks as usual and type //echo -a $network. Alternatively, if you're connecting to individual servers, simply use if ($server == server.address) instead, again, just use //echo -a $server to find out what it is (to avoid ANY bugs, best not to leave it to assume!).

You need to put that code in your remotes, ALT+R.

For further understanding, see:

/help on start
/help on connect
/help if then else

Note: If you wish to copy that code, then due to the way Internet Explorer treats the text when you copy it, you'll need to first paste it in something such as Word Pad (type //run wordpad in mIRC) and then paste it into the mIRC scripts editor. If you don't, it'll paste it all in one line.

Hope this helps smile

Regards,
Posted By: mindcooler

Re: Joining several servers and channels upon launch - 07/04/04 11:00 PM

Thanks for thre quick reply. I added the following under remote:
Code:
on *:start:
{
  	server irc.efnet.nl
  	server -m stockholm.se.eu.undernet.org
  	server -m irc.freenode.net
}

on *:connect:
{  
  	if(($network == UnderNet) || ($network == EFNet) || ($network == freenode))
  	{    
  		join #bla,#blo
  	}
}


Then, I removed my old settings for connect on startup and removed the joining of channels under perform. But now, when I start mIRC it doesn't connect to any servers. What did I do wrong? Is there a log file I could check to see if mIRC complains about syntax errors in my script? Note that this code is not the only thing I have under remote. The channels #bla and #blo are only for testing purposes.

Thanks for any replies
Posted By: Mentality

Re: Joining several servers and channels upon launch - 07/04/04 11:10 PM

Code:
on *:start:{
  server irc.efnet.nl
  server -m stockholm.se.eu.undernet.org
  server -m irc.freenode.net
}
on *:connect:{
  if ($network == EFnet) {
  join #bla,#blo }
  if ($network == Undernet) {
  join #bla,#blo }
  if ($network == freenode) {
  join #bla,#blo }
}


Make a new remote file from the script editor, by going to File > New put the above code in that, and change #bla,#blo as necessary. If it's in a completely new file it should work, the reason it's not connecting is probably because it's conflicting with something else.

Perform would not affect the ON START event as Perform does its commands once you have connected. To make sure nothing interfers with the ON CONNECT event however, type /perform off.

Regards,
Posted By: mindcooler

Re: Joining several servers and channels upon launch - 07/04/04 11:23 PM

Thanks, I created a new file and added only the code we are working with to the remote section. The new file is called script1.ini. Then under options->options->perform I have:
/load -rs script1.ini
Nothing happens when I launch mIRC though. =( If I try to load the script manually, and dialog box pops up and says:
One or more scripts have been loaded the include initialization commands.

You should only allow the initialization commands to be run if you know
what this script does.

Run the initialization commands?

I select yes, but nothing happens but that is logical to me because now the start event has already happened so no servers are joined, and thus, no connect event takes place so no channels are joined either.

I got the same thing if I loaded my old script (with this code) manually.

Any ideas?

How do I enter an echo to my script so I can see when it's loaded?

/ mindcooler
Posted By: Mentality

Re: Joining several servers and channels upon launch - 07/04/04 11:26 PM

If you add it directly to the scripts editor via ALT+R and then press "OK" it will come up with that warning dialog. As before, press "Yes". There is no need to use //load, and it should put it in a .mrc file, not .ini.

Really you can then just type /exit and leave mIRC, however, whilst I was testing the code (and it worked) I just type //run mirc.exe and opened a new client - it should work, at least it did for me.

Regards,
Posted By: mindcooler

Re: Joining several servers and channels upon launch - 07/04/04 11:44 PM

Thanks, I re-did the procedure and for some reason it works now, lol. Don't know what I did different the first time but it must have been something because it didn't work then but it works now! mIRC, however, gives the files .ini-extension. Anyway, I copied the contents of my old script and removed the /load command from perform and everything seems to work. But why isn't the load command necessary? How does mIRC know it should load the file since it's completely new?

And, one more thing...being a programmer, I prefer writing the if-statement like this since the same code is executed for all three alternatives. Don't duplicate code unnecessarily. =)

Code:
on *:connect:{
  if (($network == EFNet) || ($network == UnderNet) || ($network == freenode)) {
  join #bla,#blo }
}


Thanks for all your help and your quick replies. Saved me a lot of time and made my mIRC experience alot smoother!!

/ mindcooler
Posted By: Mentality

Re: Joining several servers and channels upon launch - 07/04/04 11:54 PM

"But why isn't the load command necessary? How does mIRC know it should load the file since it's completely new?"

The /load command only puts files in your mIRC directory (or any other dir you specify) into the script editor. When you paste code straight into the script editor it's just the same as pasting it into a .ini file and using the /load command. When putting code straight into the script editor, /load is not needed because it's already loaded smile

And you are of course most welcome smile

Regards,
Posted By: milosh

Re: Joining several servers and channels upon launch - 08/04/04 12:14 AM

Hi, there. The code you wrote ( on *:connect:{ if (($network == EFNet) || ($network == UnderNet) || ($network == freenode)) { join #bla,#blo } } ) will join you in same channels #bla and #blo if you connect to any of those networks.
So, you must use the original code if you want to join diferent channels depending of your network.

This is just a little comment for those who wants to use diferent channels...
Posted By: mindcooler

Re: Joining several servers and channels upon launch - 08/04/04 12:47 AM

Umm, yes, but as I noted I wrote the code in that manner because that's precisely what I want. I think most people can figure out that you need separate if-statements if the code varies depending on which if statement evaluates to true or not.
Posted By: PastMaster

Re: Joining several servers and channels upon launch - 08/04/04 09:24 AM

Just a thought:

The only minor problem with all the scripts suggested so far is that not all servers actually return a value for $network.

Anyone facing this problem might like to consider using $server as the identifier to trigger the channel joins instead.

(Yes I *KNOW* that this can be very fiddly, especially if one doesn't always join the same server on a particular network...)

PM
Posted By: Mentality

Re: Joining several servers and channels upon launch - 08/04/04 01:34 PM

Put that in my first post wink

"Alternatively, if you're connecting to individual servers, simply use if ($server == server.address) instead, again, just use //echo -a $server to find out what it is (to avoid ANY bugs, best not to leave it to assume!).

However, a good point made for those people browsing this thread who aren't going to use the code for the listed networks. To those people, if it doesn't work, try $server and not using a networks round robin ("round robin" is an address like irc.network.net, aka server pool).

Regards,
Posted By: Hammer

Re: Joining several servers and channels upon launch - 08/04/04 06:44 PM

Minor addition:

on *:START:{
  • ; Connect to the first server, then join and minimize #chan on that server.
    ;

    server irc.server1.net -jn #chan

    ; Connect to the second server, then join #chan1, #chan2 and #chan3 (which is set +k keyword3) on that server.
    ;

    server -m irc.server2.net -jn #chan1,#chan2,#chan3 blank,blank,keyword3

    ; Connect to the third server, then join #mIRC and #Help on that server.
    ;

    server -m irc.server3.net -jn #mIRC,#Help
}
© 2020 mIRC Discussion Forums