Automated Undernet Login

By QueenElsa on Jun 19, 2016

So these are a dime a dozen, but one more can't hurt, right?
This does exactly what the title suggests. It automates your undernet login.

However, this one does have a few tricks up it's sleeve. It'll automatically change your nick on connect to something temporary. Once you've logged in and mode +x is set, it'll restore your last used nick. (There's a slight bug with this, but certain conditions need to be met.) If you're disconnected for any reason, it will part all channels.

Lastly, it's very simple to setup. After copying and pasting this into a new remotes file, just type /setup_cservice to begin.

NOTE: Some Undernet servers now have the ability to Login on Connect. It is highly recommended that you utilize that function instead of this script, as it is far more secure. If you are not a LoC user, but wish to use it, contact QueenElsa for assistance.

/* Script by: QueenElsa
You can find her in #development on the Undernet IRC Network */

; Create the setup dialog
dialog -l setup_cservice {
  title "Undernet IRC Network: CService Login"
  size -1 -1 160 65
  option dbu
  text "CService Username", 1, 3 5 48 8
  edit "", 2, 52 4 106 10
  text "CService Password", 3, 3 20 48 8
  edit "", 4, 52 19 106 10
  button "Save my credentials", 5, 4 34 72 12, default ok
  button "Delete my credentials", 6, 83 34 72 12 cancel
  text "Your credentials will only be saved on this PC.", 7, 2 56 156 8
}

; Command to open the setup dialog
alias setup_cservice {
  dialog -ma setup_cservice setup_cservice  
}

; Events to save username and password as variables
on *:dialog:setup_cservice:edit:*: {
  if ($did == 2) { .set %cservice_username $did(setup_cservice,2) }
  if ($did == 4) { .set %cservice_password $did(setup_cservice,4) }
}

; Event to save all variables
on *:dialog:setup_cservice:sclick:5:{ 
  .set %cservice_username $did(setup_cservice,2)
  .set %cservice_password $did(setup_cservice,4)
  .set %cservice_setup_complete YES
  .echo 10,1CService Login Setup: Your username and password has been saved.
  .echo 03,1Do you want to connect now?: type /undernet to connect now!
  .dialog -x setup_cservice
  halt
}

; Alias to connect to Undernet. Opens a new connection.
alias undernet { 
  .echo 12,1Alright, let's go!
  .server -m eu.undernet.org 
}

; Event to clear login data from variables.
on *:dialog:setup_cservice:sclick:6:{
  .set %cservice_username
  .set %cservice_password 
  .echo 10,1CService Login Setup: Your username and password have been deleted.
  halt
}

; Event to execute when connected to Undernet.
on *:connect: {
  if ($network = UnderNET) { 
    .echo -at [A message from QueenElsa] ** If you've encountered issue with this, join #development for assistance. 
    .echo -a 1,8Setting Temporary Nick: This is just to make sure no one knows you're online, until you're logged in.
     nick $rand(a,z) $+ $rand(0,9) $+ $rand(a,z) $+ $rand(0,9) $+ $rand(a,z) $+ $rand(0,9) $+ $rand(a,z) $+ $rand(0,9) $+ $rand(a,z) $+ $rand(0,9)
    .set %connectednetworkisundernet 1
    .echo -a 8,1CService Login Attempt: You are conencted to the Undernet IRC network. mIRC will now try to automatically log you into X. 
    .msg x@channels.undernet.org LOGIN %cservice_username %cservice_password 
    .mode $me +x
    halt 
  }
  ;Catch to ensure user's login is not compromised on third party networks. 
  else { echo YOU ARE NOT CONNECTED TO UNDERNET. CSERVICE LOGIN DISABLED. } 
}

; Event to execute when disconnected from Undernet. This stops users from seeing your real IP during a netsplit.
on *:disconnect: { 
  if (%connectednetworkisundernet = 1) { 
    .echo 4,1Disconnected: You were disconnected from the Undernet. As a safety precaution, you have been parted from all channels. 
  .timer 1 5 /partall 
  set %starting_nick $me }
  else { Halt } 
}

; Event to execute when script is installed.
on *:load: { 
  echo 0,13CService Login Script by QueenElsa
  if (%cservice_setup_complete != YES) { 
    echo 8,1CService Login Setup: Your CService Login information hasn't been set. Type /setup_cservice to fix this. 
  halt }
}

; Event to execute when client is started.
on *:start: { 
  set %starting_nick $me
  echo 0,13CService Login Script by QueenElsa
  if (%cservice_setup_complete != YES) { 
    echo 8,1CService Login Setup: Your CService Login information hasn't been set. Type /setup_cservice to fix this. 
  halt }
  else { server -m ix.undernet.org } 
}

; Event to search for successful login notice from X.
on 1:notice:AUTHENTICATION SUCCESSFUL as *:?:{
  if ($nick == X) {
    mode $me +x
    .echo -a 3,1CService Login Success: You have been automatically logged into X successfully. Your IP address is now hidden from regular users. Please keep in mind, CService Administrators and IRC Operators can see through X, and thus, can see your IP address. mIRC will now join your regular channels.
    .echo -a 1,8Restoring Last Used Nick and Joining Channels: To stop you from annoying people, your last used nick will be restored. You will then be joined back to #usa and #usa ops. NOTE: If your last used nick is in use, you will be joined to your channels with the temporary nick you're using now ( $+ $me $+ ). 
    .timer 1 1 /nick %starting_nick
    .timer 1 5 /join #undernet
  }
}

; Event to search for unsuccessful login notice from X.
on 1:notice:AUTHENTICATION FAILED as *:?:{
  .echo -a 4,1CService Login Error: For some reason, X has refused to let you login. Please check your username and password in setup by typing: 1,0/setup_cservice4,1 If your believe your username and password are correct, join #usernames and request assistance from an operator.
}

Comments

Sign in to comment.
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.