on *:start: {
if ($exists(users.hsh)) {
hmake users 100
hload -o users users.hsh
}
else { hmake users 100 }
}
alias users {
if ($1 == add) {
if ($hfind(users,$2)) {
echo -a $2 is already in the database.
halt
}
if (!$2) {
.echo -a No Account name specified. Access Denied.
halt
}
if ($2) && (!$3) {
.echo -a No Account password specified.
halt
}
if ($2) && ($3) {
if ($hget(users)) {
hadd users $2 $3
.echo -a Account name $2 with password $3 created.
if ($hget(users)) {
hsave -io users users.hsh
}
halt
}
else {
hmake users
.echo -a Account name $2 with password $3 created.
halt
}
}
}
if ($1 == del) {
if (!$2) { echo -a You didn't specify an account. | halt }
if (!$hfind(users,$2)) {
.echo -a $2 is not in the database and can't be removed.
halt
}
else {
.echo -a $2 has been removed from the database.
hdel -w users $2
.echo -a *** Now saving database.
hsave -io users users.hsh
.echo -a *** Database saved.
}
}
else {
halt
}
}
on 1:Text:login*:?: {
if (!$hfind(users, $nick)) {
.notice $nick Sorry, your nickname is not on my user database.
halt
}
if ($hfind(users, $2)) && (!$3) {
.notice $nick You didn't specify a password.
halt
}
if ($hfind(loggedin_nicks, $2)) {
.notice $nick You are already logged in.
halt
}
if ($hfind(users, $2)) && ($hget(users,$2) == $3) {
.notice $nick Authorization to your user " $+ $hfind(users,$2) $+ " with password $+ $3 $+ has been accepted.
.auser 100 $nick
hadd -m loggedin_nicks $2 Yes
hsave -i loggedin_nicks loggedin_nicks.hsh
halt
}
if ($hfind(users, $2)) && ($hget(users,$2) != $3) {
.notice $nick Password for account " $+ $hfind(users,$2) $+ " is incorrect.
halt
}
if ($hfind(users, $2)) && (!$3) {
.notice $nick You didn't specify a password.
halt
}
}
on 1:text:logout*:?: {
if ($hfind(loggedin_nicks, $nick)) {
hdel loggedin_nicks $nick
hsave -i loggedin_nicks loggedin_nicks.hsh
.ruser 100 $nick
.notice $nick You have successfully logged out.
halt
}
if (!$hfind(loggedin_nicks, $nick)) {
.notice $nick You are already logged out.
halt
}
if (!$hfind(loggedin_nicks, $nick) && $hfind(users,$nick)) {
.notice $nick You don't have an account so how can I log you out $nick $+ .
halt
}
}
on *:exit:{
hsave -io users users.hsh
}
on *:Text:changepass*:?: {
if (!$hfind(users,$nick)) {
.notice $nick You don't have an account.
halt
}
if (!$hfind(loggedin_nicks,$nick)) {
.notice $nick You are not logged in.
halt
}
if ($hfind(loggedin_nicks,$nick) && (!$2)) {
.notice $nick Usage: changepass <oldpass> <newpass>
halt
}
if ($hfind(loggedin_nicks,$nick)) && ($2 == $hget(users,$nick) && (!$3)) {
.notice $nick changepass $2 <new password>
halt
}
if ($hfind(loggedin_nicks,$nick)) && ($2 == $hget(users,$nick) && ($3)) {
.notice $nick Password changed to: $3
.notice $nick For a future login type /msg $me login $nick $3
hadd users $nick $3
halt
}
if ($hfind(loggedin_nicks,$nick)) && ($2 == $hget(users,$nick) && $3 == $hget(users,$nick)) {
.notice $nick your password is already $3
halt
}
}