Coders-IRC


IRC for Coders

Auto Connect/Join/Identify v2.1


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
}


Auto Connect/Join/Identify v1.0

Comments 0