A password manager script that allows you to store your passwords for your nicknames and channels. Can store for multiple networks, but not for multiple nicknames. This script's auto identification feature assumes you only use one password for the entire network, meaning only one group of nicknames.
However, you may add and auto identify for multiple channels. It's basic for what it was meant to do. Nothing big, I made it because I was lazy and didn't want to keep identifying and forgetting channel passwords.
Just copy the snippet into your remotes section and you should be good. Make sure it's a new file!
Alt + R -> File -> New -> Copy/Paste -> Ok
Please rate, comment, report any bugs. Thank you. Enjoy.
/*
unRealIRC
Password Manager
Scripted by: DarkWarrior
Version: 1.0
*/
alias pwmngr dialog -m pwmngr pwmngr
dialog pwmngr {
title "Password Manager"
size -1 -1 125 144
option dbu
tab "Network/Nickname", 1, 1 0 121 127
list 4, 5 28 53 83, tab 1 size
text "Networks:", 5, 5 17 51 8, disable tab 1
button "Add Password*", 6, 68 32 40 10, tab 1
text "*for active network", 7, 68 42 49 8, disable tab 1
button "Edit Password", 8, 68 50 40 10, tab 1
button "Del Password", 9, 68 68 40 10, tab 1
check "Enable AutoID", 10, 68 89 50 10, tab 1
tab "Channels", 3
list 11, 5 46 52 75, tab 3 size
text "Channels:", 12, 5 37 27 8, disable tab 3
combo 13, 5 25 52 50, tab 3 size drop
text "Networks:", 14, 5 15 25 8, disable tab 3
button "Add*", 15, 61 25 20 10, tab 3
button "Del", 16, 81 25 20 10, tab 3
text "*active network", 17, 60 35 46 8, disable tab 3
button "Add Password", 18, 65 50 40 10, tab 3
button "Del Password", 19, 65 65 40 10, tab 3
button "Edit Password", 20, 65 80 40 10, tab 3
button "Identify*", 21, 65 100 40 10, tab 3
check "Enable AutoID", 22, 65 111 50 10, tab 3
button "Close", 2, 84 131 37 9, ok cancel
}
on *:connect: {
if (!$read($qt($scriptdirpasswords.pwn),s,$network)) {
var %password = $$input(Enter the password you are/will be using for this server.,op)
write $qt($scriptdirpasswords.pwn) $network %password
if (%autoid.net) { ns identify %password }
if ($dialog(pwmngr)) {
did -r pwmngr 4
var %n = 1
while (%n <= %lines) {
did -a pwmngr 4 $gettok($read($qt($scriptdirpasswords.pwn),%n),1,32)
inc %n
}
}
}
}
alias -l retry {
var %retry = $input(Nickname password incorrect. Click retry to try again or cancel to change the password.,r)
if (%retry == $true) {
ns identify $read($qt($scriptdirpasswords.pwn),s,$network)
}
elseif (%retry == $false) {
var %newpassword = $network $$input(Enter the new password you are/will be using for this server.,op)
write -s [ $+ [ $network ] ] $qt($scriptdirpasswords.pwn) %newpassword
nickserv identify $gettok(%newpassword,2,32)
}
}
on *:NOTICE:*:*: {
if ($nick == Nickserv) {
if (%autoid.net) {
if ($1- == This nickname is registered and protected. If it is your) { ns identify $read($qt($scriptdirpasswords.pwn),s,$network) }
if ($1- == Password incorrect.) { if ($read($qt($scriptdirpasswords.pwn),s,$network)) { .timerretry 1 1 retry } }
if ($1- == Password accepted - you are now recognized.) {
if (%autoid.chan) {
var %i = 1, %lines = $lines($qt($scriptdir [ $+ [ $network ] $+ .pwc ]))
while (%i <= %lines) {
chanserv identify $read($qt($scriptdir [ $+ [ $network ] $+ .pwc ]), %i)
inc %i
}
nickserv update
}
}
}
}
}
on *:dialog:pwmngr:init:*: {
var %f = $+(",$scriptdirpasswords.pwn,"), %n = 1, %lines = $lines(%f)
while (%n <= %lines) {
did -a $dname 4 $gettok($read(%f,%n),1,32)
inc %n
}
noop $findfile($scriptdir, *.pwc, 0, did -a $dname 13 $left($nopath($1-), -4))
if (%autoid.net) did -c $dname 10
if (%autoid.chan) did -c $dname 22
}
on *:dialog:pwmngr:sclick:*: {
if ($did == 6) {
if (!$read($qt($scriptdirpasswords.pwn),s,$network)) {
var %password = $$input(Enter the password you are/will be using for this server.,op)
write $qt($scriptdirpasswords.pwn) $network %password
did -r $dname 4
var %n = 1, %lines = $lines($qt($scriptdirpasswords.pwn))
while (%n <= %lines) {
did -a $dname 4 $gettok($read($qt($scriptdirpasswords.pwn),%n),1,32)
inc %n
}
}
}
if ($did == 8) {
if ($did(4).sel) {
var %newpassword = $gettok($read($qt($scriptdirpasswords.pwn),$did(4).sel),1,32) $$input(Enter the new password you are/will be using for this server.,op)
write -l [ $+ [ $did(4).sel ] ] $qt($scriptdirpasswords.pwn) %newpassword
did -r $dname 4
var %n = 1, %lines = $lines($qt($scriptdirpasswords.pwn))
while (%n <= %lines) {
did -a $dname 4 $gettok($read($qt($scriptdirpasswords.pwn),%n),1,32)
inc %n
}
}
}
if ($did == 9) {
if ($did(4).seltext) {
write -dl [ $+ [ $did(4).sel ] ] $qt($scriptdirpasswords.pwn)
did -r $dname 4
var %n = 1, %lines = $lines($qt($scriptdirpasswords.pwn))
while (%n <= %lines) {
did -a $dname 4 $gettok($read($qt($scriptdirpasswords.pwn),%n),1,32)
inc %n
}
}
}
if ($did == 10) { $iif($did(10).state == 0, unset %autoid.net, set %autoid.net on) }
if ($did == 13) && ($did(13).seltext) {
did -r $dname 11
var %n = 1,%lines = $lines($qt($scriptdir [ $+ [ $did(13) ] $+ .pwc ]))
while (%n <= %lines) {
did -a $dname 11 $gettok($read($qt($scriptdir [ $+ [ $did(13) ] $+ .pwc ]), %n), 1, 32)
inc %n
}
}
if ($did == 15) {
if (!$exists($qt($scriptdir [ $+ [ $network ] $+ .pwc ]))) {
write $qt($scriptdir [ $+ [ $network ] $+ ] .pwc ]))
did -r $dname 13
noop $findfile($scriptdir, *.pwc, 0, did -a $dname 13 $left($nopath($1-), -4))
did -c $dname 13 $network
}
}
if ($did == 16) {
if ($did(13)) {
.remove $qt($scriptdir [ $+ [ $did(13) ] $+ .pwc ])
did -r $dname 11
did -r $dname 13
noop $findfile($scriptdir, *.pwc, 0, did -a $dname 13 $left($nopath($1-), -4))
}
}
if ($did == 18) {
if ($did(13)) {
var %chan = $$input(Enter the channel you are adding a password for., oe)
if ($read($qt($scriptdir [ $+ [ $did(13) ] $+ .pwc ]),s,$ifchan(%chan))) { var %input = $input(Channel already exists!,wo) | halt }
var %pass = $$input(Enter the password for $ifchan(%chan), op)
write $qt($scriptdir [ $+ [ $did(13) ] $+ .pwc ]) $ifchan(%chan) %pass
did -r $dname 11
var %n = 1, %lines = $lines($qt($scriptdir [ $+ [ $did(13) ] $+ .pwc ]))
while (%n <= %lines) {
did -a $dname 11 $gettok($read($qt($scriptdir [ $+ [ $did(13) ] $+ .pwc ]), %n), 1, 32)
inc %n
}
}
}
if ($did == 19) {
if ($did(13)) && ($did(11).seltext) {
write -dl [ $+ [ $did(11).sel ] ] $qt($scriptdir [ $+ [ $did(13) ] $+ .pwc ])
did -r $dname 11
var %n = 1, %lines = $lines($qt($scriptdir [ $+ [ $did(13) ] $+ .pwc ]))
while (%n <= %lines) {
did -a $dname 11 $gettok($read($qt($scriptdir [ $+ [ $did(13) ] $+ .pwc ]), %n), 1, 32)
inc %n
}
}
}
if ($did == 20) {
if ($did(13)) && ($did(11).sel) {
var %input = $gettok($read($qt($scriptdir [ $+ [ $did(13) ] $+ .pwc ]), $did(11).sel), 1, 32) $$input(Enter a the new password for the selected channel.,op)
write -l [ $+ [ $did(11).sel ] ] $qt($scriptdir [ $+ [ $did(13) ] $+ .pwc ]) %input
}
}
if ($did == 21) {
var %i = 1, %lines = $lines($qt($scriptdir [ $+ [ $did(13) ] $+ .pwc ]))
while (%i <= %lines) {
chanserv identify $read($qt($scriptdir [ $+ [ $network ] $+ .pwc ]), %i)
inc %i
}
nickserv update
}
if ($did == 22) { $iif($did(22).state == 0, unset %autoid.chan, set %autoid.chan on) }
}
menu channel,menubar,status,query {
Password Manager:pwmngr
}
alias -l ifchan {
if ($left($1,1) == $chr(35)) { return $1 }
else { return $chr(35) $+ $1 }
}
Thanks for the constructive criticism, I really appreciate it. I'll look into what you told me and see how it works. However, with your comment about the evaluation brackets: I did originally not have any. However, the script wasn't reading what I had correctly and would not work. After putting in the evaluation brackets it worked how I intended. So I don't know why that is, but I know you're right that I don't need them which has always been weird to me. Ever since I upgraded both my OS and to mIRC 6.35 I've had issues I use to not have.
the rating of 1.0 seems a bit unfair. it looks reasonably useful but i do have some constructive criticism to offer on the quality of the code that could help you (or anyone reading this) improve their scripting techniques and general thought process.
while (%n <= $lines($scriptdirpasswords.pwn)) {
did -a pwmngr 4 $gettok($read($scriptdirpasswords.pwn,%n),1,32)
inc %n
}
be weary of using functions that involve intensive operations in the condition of a while loop. each call to $lines() requires mIRC to read the file from disk and run through it in its entirety to count the total lines. this occurs in each iteration of the loop and is largely unnecessary seeing as the file isn't modified while the loop runs. a quick and simple optimization would be store $lines($scriptdirpasswords.pwn) in a %variable before the loop executes, and refer to the variable in the loop condition. there also exists a command that lets you handle lines in a file, window or dialog quite easily, usually much quicker than a looping equivalent; see /help /filter.
similarly, the following loop also involves much unnecessary computation:
while (%x <= $findfile($scriptdir,*.pwc,0)) {
did -a $dname 13 $remove($nopath($findfile($scriptdir,*.pwc,%x)),.pwc)
inc %x
}
if your script directory contains N pwc files, this block of code will access your hard disk 2N times and a perform a total of (3N^2 + N)/2 iterations through your directory. you can cut this down to 1 single disk access and N total iterations by taking advantage of $findfile()'s command parameter:
noop $findfile($scriptdir, *.pwc, 0, did -a $dname 13 $left($nopath($1-), -4))
being aware of these methods might not seem important now, but their utility will become increasingly apparent as you involve yourself in larger and more demanding projects.
also, you use evaluation brackets [] very often but i can't spot one example in this code where it is necessary to do so. you can, as far as i can see, remove every instance of them and the resulting code will still work correctly and be a little cleaner and easier to follow. evaluation brackets are indeed powerful and have a very specific purpose, you can check out an article of mine on them at http://www.xise.nl/mirc/wiki/doku.php?id=eval if you wish to learn how to use them to great effect
lastly, #$1 can be used to prefix $1 with # if it isn't already so.