Auto Connect/Join/Identify v2.1

By bigrat2 on Mar 10, 2009

Auto Connect/Join/Identify v1.0 [ source: http://www.hawkee.com/snippet/565/ ] had a lot of features and was easy to use, but unfortunately it had a lot of bugs and was written REALLY badly (Sorry to the author, but come on, hard coding 50 join statements for 5 servers each with 10 channels each is absurd).

By right clicking on a Status, Query or Channel, you'll have the option of popping up the dialog for the script. There are five tabs, one for each server, each with the ability of storing channels to autojoin, a primary and secondary nick and a nickserv password.
You have the option of setting to automatically join each independent server, to automatically be named the nicks supplied, to automatically ident, and even to automatically ghost your primary nick if it is already in use.

Bug fixes:

  • Autoident worked erratically, depended on which tab was last visited
  • If you closed the dialog while not on tab 2-5, when reopened, being on tab 1, would show the wrong information and would delete previous information if you clicked save
  • Not really a bug fix, but there were some spelling mistakes in the help
  • The tickboxes would always be shown as ticked, even if the option was not actually on
    Improvements:
  • Primary and Secondary nicks for each server, with autoghost option:
    [list]* If autoghost is on, and primary nick is already in use, your nick will be automatically ghosted, and you will take it
  • If autoghost is off, you will connect with secondary nick[]The nick and server fields were too small and didn't have horizontal scrolling (autohs), therefore wouldn't accept long strings
    [
    ]Channels are now stored in a combo box, and not in individual editboxes. This means you can now store as many channels as you like per server.
    []Now uses $network to keep track of which server you're connecting to, don't need to enter a subserver into the server field anymore
    [
    ]v1.0 was 24kb - This script is only 10kb. No loss to functionality, few bug fixes and some new stuff.
    [/list]

Image

;Shows a link to the script when you right click a status, query or channel window
menu status,query,channel {
  Auto Connect/Join/Identify v2.1:/sci01
}

;Calls the dialog window initialisation and loads the first tab
alias sci01 { dialog -m scd01 scd01 | set %tab.scd01 1 }

;Initialises the dialog window
dialog scd01 {
  title "Auto Connect/Join/Identify v2.1"
  size -1 -1 355 390
  tab "Server 1", 1, 5 5 345 265
  tab "Server 2", 2
  tab "Server 3", 3
  tab "Server 4", 4
  tab "Server 5", 5

  text "Servers address", 6, 15 30 160 12
  edit "", 7, 15 45 160 20, autohs
  text "Server network", 43, 180 30 160 12
  edit "", 44, 180 45 160 20, autohs

  text "Primary nick", 8, 22 80 75 12
  edit "", 9, 20 94 85 20, autohs
  text "Password", 10, 112 80 75 12
  edit "", 11, 110 94 60 20, autohs
  text "Secondary nick", 40, 22 117 75 12
  edit "", 41, 20 132 85 20, autohs
  box "Nicknames", 48, 15 65 160 100

  text "Add channel to this server", 49, 22 180 140 20
  edit "", 50, 20 194 155 21, autohs
  button "Add Channel", 51, 20 220 155 25
  text "View/delete existing channels", 46, 182 180 150 20
  combo 45, 180 194 155 20, drop
  button "Delete", 52, 180 220 155 25
  box "Channels", 47, 15 165 325 90

  check "A Conn/Join", 33, 188 83 80 12
  check "A Nickname", 34, 188 103 88 12
  check "A Identify", 35, 188 123 80 12
  check "A Ghost", 42, 188 143 80 12
  box "Options", 32, 180 65 100 100

  button "SET", 36, 285 70 55 35
  button "CLOSE", 37, 285 110 55 35, cancel

  box "Help", 38, 5 270 345 110
  text "", 39, 10 283 325 92, multi
}

;On initialisation, display default help text and load first tab
on 1:dialog:scd01:init:*: {
  did -ra $dname 39 Please hover over a button, checkbox or Edit box for help.
  scd01.loadgui 1
}

;loads the gui with the information for the required tab ( called with $1 being tab number )
alias scd01.loadgui { 
  if ($rs($1, AC) == 1) { did -c scd01 33 } 
  else { did -u scd01 33 }
  if ($rs($1, AN) == 1) { did -c scd01 34 } 
  else { did -u scd01 34 }
  if ($rs($1, AP) == 1) { did -c scd01 35 } 
  else { did -u scd01 35 }
  if ($rs($1, AG) == 1) { did -c scd01 42 } 
  else { did -u scd01 42 }
  did -ra scd01 7 $rs($1, Server)
  did -ra scd01 44 $rs($1, Network)
  did -ra scd01 9 $rs($1, Nick)
  did -ra scd01 41 $rs($1, Nick2)
  if ($rs($1, Password) != $null) { did -ra scd01 11 [Hidden] }
  else did -ra scd01 11 [None]

  did -r scd01 45   
  set %rid 0 
  while (%rid < $rs($1,Channels)) {
    did -a scd01 45 $rs($1, Room $+ %rid)
    inc %rid
  }
  unset %rid
}

;When hovering over any of the edit boxes, check boxes or buttons, the help label will display help information for that element
on 1:dialog:scd01:mouse:*: {
  if ($did == 7) { did -ra $dname 39 Enter the server address here. e.g. irc.gamesurge.net }
  elseif ($did == 9) { did -ra $dname 39 Enter the primary Nickname you would like to use on this server. Your nick will automatically be set to what is entered here if you have the Auto Nickname option selected. $crlf $+ If it's already in use, and the Auto-ghost option is ticked, the nick will be ghosted and you will be set to this nick. }
  elseif ($did == 41) { did -ra $dname 39 Enter the secondary Nickname you would like to use on this server. If your Primary nick is already in use, and Auto-ghost is not enabled, your nick will automatically be set to this. }
  elseif ($did == 11) { did -ra $dname 39 Here you will enter the password to the nickname to the left if your nickname is registered and you selected the auto nickname option. Will automatically identify you when nickserv asks for the password }
  elseif ($did == 13) || ($did == 15) || ($did == 17) || ($did == 19) || ($did == 21) || ($did == 23) || ($did == 25) || ($did == 27) || ($did == 29) || ($did == 31) { did -ra $dname 39 If Auto connect is selected, you will join these channels when you connect to this server. }
  elseif ($did == 32) { did -ra $dname 39 Choose which options you would like for this server. Auto connect will automatically connect you to the server and the listed channels. Auto nick will automatically set your nick. Auto Password will automatically identify you when needed. Auto Ghost will ghost your primary nick if it is already in use. If not selected, your secondary nick will be used. $crlf $+ Auto-ghost requires a secondary nick active. }
  elseif ($did == 36) { did -ra $dname 39 By clicking this button all the info in the edit boxes will be saved for this server. }
  elseif ($did == 37) { did -ra $dname 39 By clicking this button all changes will be lost. Be sure to click the Set button is you want to save this configuration. }
  elseif ($did == 44) { did -ra $dname 39 Enter the servers network here. $crlf $+ Find this out by typing '//echo -a $network' whilst connected the the server. eg. GameSurge }
  elseif ($did == 50) || ($did == 51) { did -ra $dname 39 Enter a channel name and then click the Add button to add that channel to this servers autojoin list. If the channel has a password, enter it after the channel. $crlf e.g. #channelwithpassword password }
  elseif ($did == 45) || ($did == 52) { did -ra $dname 39 Use the dropdown menu to view the channels set to automatically join when this server starts. If you wish to delete one, pick it from the list then click the Delete button. }
}

;Listens for clicks on the tabs and set button
on 1:dialog:scd01:sclick:*: {
  ;If a tab is clicked, load that information into the editable fields and textboxes
  if (($did == 1) || ($did == 2) || ($did == 3) || ($did == 4) || ($did == 5)) {
    set %tab.scd01 $did
    scd01.loadgui $did
  }

  ;If the set button is clicked, save all information into the Settings.ini file
  if ($did == 36) {
    if ($did($dname, 7).text != $null) { $ws(%tab.scd01, Server, 7) }
    else { $rms(%tab.scd01, Server) }
    if ($did($dname, 44).text != $null) { $ws(%tab.scd01, Network, 44) }
    else { $rms(%tab.scd01, Network) }
    if ($did($dname, 9).text != $null) { $ws(%tab.scd01, Nick, 9) }
    else { $rms(%tab.scd01, Nick) }
    if ($did($dname, 41).text != $null) { $ws(%tab.scd01, Nick2, 41) }
    else { $rms(%tab.scd01, Nick2) }
    if (($did($dname, 11).text != $null) && ($did($dname, 11).text != [hidden]) && ($did($dname, 11).text != [none])) { $ws(%tab.scd01, Password, 11) }
    if ($did($dname, 11).text == $null) { $rms(%tab.scd01, Password) }

    if ($did($dname, 33).state == 1) { $ws(%tab.scd01, AC, 33) }
    else { $rms(%tab.scd01, AC) }
    if ($did($dname, 34).state == 1) { $ws(%tab.scd01, AN, 34) }
    else { $rms(%tab.scd01, AN) }
    if ($did($dname, 35).state == 1) { $ws(%tab.scd01, AP, 35) }
    else { $rms(%tab.scd01, AP) }
    if ($did($dname, 42).state == 1) { $ws(%tab.scd01, AG, 42) }
    else { $rms(%tab.scd01, AG) }
  }

  ;If the add channel button is clicked, add a channel to the current server in the Settings.ini file
  if ($did == 51) {
    if ($did($dname, 50).text != $null) { 

      if ($rs(%tab.scd01, Channels) != $null) {
        set %channels $rs(%tab.scd01, Channels)
      }
      else set %channels 0

      $ws(%tab.scd01, Room $+ %channels, 50) 
      did -a scd01 45 $rs(%tab.scd01, Room $+ %channels)
      inc %channels
      writeini Settings.ini Server $+ %tab.scd01 Channels %channels
      did -r scd01 50
      unset %channels
    }
  }

  ;If the delete channel button is clicked, delete the current channel in the combo box from the Settings.ini file
  if ($did == 52) {
    if ($did($dname, 45) != $null) {
      set %channels $rs(%tab.scd01, Channels)
      set %n $did($dname, 45).sel
      dec %n
      $rms(%tab.scd01, Room $+ %n)
      did -d scd01 45 $did($dname, 45).sel
      dec %channels
      set %s %n
      while (%n < %channels) {
        inc %s
        writeini Settings.ini Server $+ %tab.scd01 Room $+ %n $rs(%tab.scd01, Room $+ %s)
        inc %n
      }
      $rms(%tab.scd01, Room $+ %n)
      unset %s
      writeini Settings.ini Server $+ %tab.scd01 Channels %channels
      unset %channels
      unset %n
    }
  }
}

;When mIRC starts, connect to each of the servers in the Settings.ini file with the primary nick supplied, if there is one.
on *:Start: {
  if ($rs(1, AC) == 1) { server $rs(1, Server) $iif($rs(1, AN) == 1 && $rs(1, nick) != $null, -i $rs(1, Nick),) }
  set %servc 2
  while (%servc <= 5) {
    if ($rs(%servc, AC) == 1) { 
      server -m $rs(%servc, Server) $iif($rs(%servc, AN) == 1 && $rs(%servc, nick) != $null, -i $rs(%servc, Nick),)
    }
    inc %servc
  }
  unset %servc
}

;When you connect to a server, check that it's one in the Settings.ini file and then connect to the supplied channels
on *:Connect: {
  set %servc 1
  while (%servc <= 5) {
    if (($rs(%servc, Network) == $network) && ($rs(%servc, AC) == 1)) { 
      ;channel counter
      set %chanc 0
      while (%chanc < $rs(%servc, Channels)) {
        join $rs(%servc, Room $+ %chanc)
        inc %chanc
      }
      unset %chanc
      if (($rs(%servc, Password) != $null) && ($rs(%servc, AP) == 1) && ($rs(%servc, nick) == $me)) { nickserv identify $rs(%servc, Password) }
    }
    inc %servc
  }
  unset %servc
}

;When nickserv asks to identify, do so with the supplied password from the Settings.ini file
on *:notice:*:?: {
  if (($nick == nickserv) && (identify isin $1-)) { 
    set %servc 1
    while (%servc <= 5) {
      if (($rs(%servc, AP) == 1) && ($server == $rs(%servc, Server))) {
        nickserv identify $rs(%servc, Password) 
      }
      inc %servc
    }
    unset %servc
  }
}

;When mIRC tells you that your primary nickname is already in use, change to your secondary nick, ghost the primary, and then change to it
raw 433:*:{ 
  autoghost $1-
}
alias autoghost {
  set %servc 1
  while (%servc <= 5) {
    if ($server == $rs(%servc, Server)) && ($rs(%servc, AG) == 1) {
      nick $rs(%servc, Nick2)
      timerghost1 1 2 nickserv ghost $2 $rs(%servc, Password)
      timerghost2 1 3 nick $2
    }
    inc %servc
  }
  unset %servc
}

;called by $rs(server number, item)
alias rs {
  return $readini(Settings.ini, Server $+ $1, $2)
}

;called by $ws(server number, item, id to read from)
alias ws {
  ;if it's a check box, write the checkboxes state, else write the editboxes text
  if ($3 == 33) || ($3 == 34) || ($3 == 35) || ($3 == 42) writeini Settings.ini Server $+ $1 $2 1
  else writeini Settings.ini Server $+ $1 $2 $did($dname,$3).text
}

;called by $rms(server number, item)
alias rms {
  remini Settings.ini Server $+ $1 $2
}

Comments

Sign in to comment.
Rei   -  Mar 01, 2014

Script still works a charm, even on the latest mIRC (7.32). Would be nice if we could save more than 5 servers though

 Respond  
GTAXL   -  Aug 20, 2011

Can you add more than just 5 servers (like unlimited amount) and add an Oper Up on connect command? Thanks.

 Respond  
blitzz   -  May 22, 2010

@Simpuhl

Click Select Code above then copy it and paste it to your remote on mIRC. Press Alt + R to open your remote and make sure your remote is ON by typing /remote on into your mIRC.

 Respond  
Simpuhl   -  May 21, 2010

how exactly do i install this

 Respond  
kakoura69   -  Feb 24, 2010

nickserv password doesnt work if nickserv wants : -NickServ- nick, type /msg NickServ IDENTIFY password.
please show me what to change for it to work

 Respond  
PuNkTuReD   -  Nov 16, 2009

divine devil -
in your mirc press alt + r
that will open your "script editor" to a "remote" file,
if you see existing code, goto
file - new
and paste there.

 Respond  
Abtehi   -  Nov 16, 2009

What about this:

/mode nick +x

this will make your a hidden hostmask after logged in.

 Respond  
DIVINE DEVIL   -  Mar 30, 2009

where do you put this at

 Respond  
bigrat2   -  Mar 25, 2009

Or not <.< Never got around to it, too busy. Sorry!

 Respond  
bigrat2   -  Mar 15, 2009

K, bug fixed. combobox for servers will be up tonight.

Also, I opted for having the channel password just after the channel. Channel security can be a bit more lax, nickserv passwords are the only one that matter imo :)

 Respond  
bigrat2   -  Mar 15, 2009

Thanks to Sasza, I know what the bug is xD Silly mistake with the very first channel you put in. I'll edit a bugfix and let you know tonight.

@Firstmate: Yep. I'm working on that too. That's actually a really easy one to write up. :)

As for passwords to channel, just put them in the channel editbox after the channel name.

e.g. #channelwithpassword password

If you add that, it will work.

Quick question for other lurkers, should I bother making a password field for channels? Or just keep it like that (And edit the hover-over help so it actually says to do that.)

 Respond  
Firstmate   -  Mar 15, 2009

Again, instead of allowing a maximum of X option.
Make a combo and then load the settings from whatever you choose

e..g take out tabs, put a combo at the top. if User clicks Server 1. Load all the options from server 1.

 Respond  
bigrat2   -  Mar 15, 2009

Hmm, i've done a fair bit of bugtesting, but it's kind of hard because we all have our clients set up differently. Shouldn't make much of a problem though.

Could you copypaste the ini file it made here? If you can't find it, it's in the mirc settings folder. Like... Documents and settings/application data/mirc/.

Also, I haven't coded in a password for the channel... I'll add that tomorrow after uni =) Kinda tired and working on something else now, should probably get some sleep T__T

EDIT: Actually. Probably best if you didn't. Send it via personal message with server and password fields removed :)

 Respond  
sasza101   -  Mar 14, 2009

This looks very good, and in fact, I'm very much in need of such thing, but I can't make it work. I've configured it all properly (at least I think I have), but I keep on getting the

  • /join: insufficient parameters (line 190, autojoin.txt)

message :(

What should be done to make it work?
And btw - if the channel is password protected (the channel as such, not a nick via nickserv) where would I put the channels pwd?

TIA.

:sasza:

 Respond  
bigrat2   -  Mar 11, 2009

Thanks :)

 Respond  
Aucun50   -  Mar 11, 2009

Nice good job btw.

 Respond  
bigrat2   -  Mar 11, 2009

Okay, updated with the code that keeps the channels in the same order as before when deleting a channel in the middle of the list.

 Respond  
Aucun50   -  Mar 11, 2009

Delete the 5th one, move all lower channels up one spot.

Sounds better to me.

 Respond  
bigrat2   -  Mar 11, 2009

If I get another person to say that keeping the order is more important, i'll chuck it into the actual snippet. Should be obvious which part to substitute for the following code.

;If the delete channel button is clicked, delete the current channel in the combo box from the Settings.ini file
if ($did == 52) {
  if ($did($dname, 45) != $null) {
    set %channels $rs(%tab.scd01, Channels)
    set %n $did($dname, 45).sel
    dec %n
    $rms(%tab.scd01, Room $+ %n)
    did -d scd01 45 $did($dname, 45).sel
    dec %channels
    set %s %n
    while (%n < %channels) {
      inc %s
      writeini Settings.ini Server $+ %tab.scd01 Room $+ %n $rs(%tab.scd01, Room $+ %s)
      inc %n
    }
    $rms(%tab.scd01, Room $+ %n)
    unset %s
    writeini Settings.ini Server $+ %tab.scd01 Channels %channels
    unset %channels
    unset %n
  }
}
 Respond  
PuNkTuReD   -  Mar 11, 2009

my vote

Delete the 5th one, move all lower channels up one spot.

 Respond  
bigrat2   -  Mar 11, 2009

K done. :)

For deleting channels, which do you guys think is better?

Lets say you have 10 channels. You wish to delete the 5th channel.

  • Delete the 5th one, then get the 10th channel and place it as the 5th
    [list] Faster, but you lose the order of your channels. I know some people like to have their channels in a particular order.
    [list]
    This is what I implemented.
    [*]Delete the 5th one, move all lower channels up one spot.
  • Slower, but you keep the order of the channels.
    [list]* I have this also coded, just not in the snippet above.[/list][/list][/list]

Let me know if someone would like the other option, i'll paste it here, letting you know what part to swap out.

 Respond  
bigrat2   -  Mar 10, 2009

v2.1 will have a combo box for the channels. I've also thought of a few other changes, i'll do those tonight too.

Punktured: I sent you a PM asking for more info. :)

 Respond  
PuNkTuReD   -  Mar 10, 2009

a neat way around the subservers , is to use "$network" in the on connect event
so you add your server and network
then once connected to the server
if $network == SAVED_NETWORK
join channels

 Respond  
Firstmate   -  Mar 10, 2009

You should consider using a combo box for the room to join. Would allow more.

 Respond  
bigrat2   -  Mar 10, 2009

True; will skip later if's if there's an early match. Ty.

 Respond  
Aucun50   -  Mar 10, 2009

For your "on 1:dialog:scd01:mouse:*: {" you can have one if then elseif to speed it up.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.