All pastes #829503 Raw Edit

Untitled

public text v1 · immutable
#829503 ·published 2007-12-23 06:13 UTC
rendered paste body
alias loggedon {
  if ($1 !isnum) {
    if ($prop == account) return $hget(users,$address($1,2))
    elseif ($prop == access) return $hget($hget(users,$address($1,2)),access)
    else return $iif($hfind(users,$address($1,2),0,w),$true,$false)
  }
  elseif ($1 isnum) {
    if (!$prop) return $hget(users,$1).item
    elseif ($prop == account) return $hget(users,$1).data
    elseif ($prop == access) return $hget($hget(users,$1).data,access)
  }
}
on *:text:register*:?: {
  if ($loggedon($nick)) .notice $nick Error! You are already logged on.
  elseif ($hget($+(acc_,$2))) .notice $nick Error! $2 is already an account.
  elseif ($0 != 4) .notice $nick Error! Insufficient parameters. Please use /msg $me register account password email
  else {
    var %reg ^[_\.0-9a-zA-Z]+@([.-0-9a-zA-Z][.-0-9a-zA-Z]+\.)+[a-zA-Z]{2,3}$
    if (!$regex($4,%reg)) .notice $nick Error! Please use a proper email.
    else {
      hmake $+(acc_,$2) 10
      hadd $+(acc_,$2) Password $encode($3,m)
      hadd $+(acc_,$2) Email $4
      hadd $+(acc_,$2) Hostmask $mask($fulladdress,2)
      hadd $+(acc_,$2) Ctime $ctime
      hadd $+(acc_,$2) Nick $nick
      hadd $+(acc_,$2) access default
      hadd $+(acc_,$2) hideemail 0
      hadd -m users $mask($fulladdress,2) $+(acc_,$2)
      .notice $nick Registration successful. You have automatically been logged on to account  $+ $2 $+ .
    }
  }
}
on *:text:unregister*:?: {
  if (!$loggedon($nick)) .notice $nick Error! Please login before trying to access that command.
  elseif ($loggedon($nick).access != leader) .notice $nick Error! You lack sufficient access to use that command.
  elseif ($0 != 2) .notice $nick Error! Insufficient parameters. Please use /msg $me unregister nick|*account
  elseif ($left($2,1) != $chr(42)) && (!$loggedon($2)) .notice $nick Error! $2 is not logged on. Please use *account.
  else {
    if ($left($2,1) != $chr(42)) && (!$loggedon($2)) .notice $nick Error!: $2 is not logged on. Please use *account.
    elseif ($left($2,1) == $chr(42)) && (!$hget($+(acc_,$right($2,-1)))) .notice $nick Error! Account $right($2,-1) does not exist.
    else {
      if ($left($2,1) == $chr(42)) {
        var %nick. [ $+ [ $2 ] ] $hget($+(acc_,$right($2,-1)),nick)
        if ($hfind(users,$+(acc_,$right($2,-1)),1).data) .notice %nick. [ $+ [ $2 ] ] Your account ( $+ $right($2,-1) $+ ) has been deleted by  $+ $nick $+ . If you think the deletion was a mistake, please msg $nick $+ .
        .hfree $+(acc_,$right($2,-1))
        .remove $+(databases\,$+(acc_,$right($2,-1)),.dbu)
        .notice $nick Account  $+ $right($2,-1) $+  has been deleted.
        if ($hfind(users,$+(acc_,$right($2,-1)),0).data) .hdel users $hfind(users,$+(acc_,$right($2,-1)),1).data
      }
      elseif ($left($2,1) != $chr(42)) {
        .var %account. [ $+ [ $2 ] ] $right($loggedon($2).account,-4)
        .hfree $loggedon($2).account
        .remove $+(databases\,$loggedon($2).account,.dbu)
        if ($loggedon($2)) .notice $2 Your account ( $+ %account. [ $+ [ $2 ] ] $+ ) has been deleted by  $+ $nick $+ . If you think the deletion was a mistake, please msg $nick $+ .
        .notice $nick Account  $+ %account. [ $+ [ $2 ] ] $+  has been deleted.
        if ($hfind(users,$+(acc_,%account. [ $+ [ $2 ] ]),0).data) .hdel users $hfind(users,$+(acc_,%account. [ $+ [ $2 ] ]),1).data
      }
    }
  }
}
on *:text:auth*:?: {
  if ($loggedon($nick)) .notice $nick Error! You are already logged on.
  elseif ($0 != 3) .notice $nick Error! Insufficient parameters. Please use /msg $me auth account password
  elseif (!$hget($+(acc_,$2))) .notice $nick Error! That account does not exist.
  elseif ($3 != $decode($hget($+(acc_,$2),password),m)) .notice $nick Error! The password you supplied does not match the one I have stored.
  else {
    if ($mask($fulladdress,2) != $hget($+(acc_,$2),Hostmask)) hadd $+(acc_,$2) Hostmask $mask($fulladdress,2)
    elseif ($nick != $hget($+(acc_,$2),Nick)) hadd $+(acc_,$2) Nick $nick
    hadd $+(acc_,$2) Ctime $ctime
    hadd -m users $mask($fulladdress,2) $+(acc_,$2)
    .notice $nick Welcome back, $nick $+ .
  }
}
on *:text:users:?: {
  .notice $nick Accounts on  $+ $me $+ :
  var %i 1
  var %accounts 0
  while ($hget(%i)) {
    if (acc_* iswm $hget(%i)) {
      .notice $nick $remove($hget(%i),acc_) ( $+ $hget(%i,access) $+ )
      inc %accounts
    }
    inc %i
  }
  .notice $nick Totalling  $+ %accounts $+  $iif(%accounts == 1,account,accounts) $+ .
}
on *:text:accountinfo*:?: {
  if (!$2) && ($loggedon($nick)) {
    .notice $nick Account info for  $+ $nick $+ :
    .notice $nick Account: $right($loggedon($nick).account,-4)
    .notice $nick Password: $decode($hget($loggedon($nick).account,password),m)
    .notice $nick Email: $hget($loggedon($nick).account,email) (Hide email: $hget($loggedon($nick).account,hideemail) $+ )
    .notice $nick Access: $loggedon($nick).access
    .notice $nick Last Used Hostmask: $hget($loggedon($nick).account,hostmask)
    .notice $nick Logged On For: $iif(!$hget($loggedon($nick).account,ctime),$+($chr(40),not logged on,$chr(41)),$duration($calc($ctime - $hget($loggedon($nick).account,ctime))))
    .notice $nick Infoline: $iif($hget($loggedon($nick).account,info),$hget($loggedon($nick).account,info),$+($chr(40),none,$chr(41))))
  }
  elseif (!$2) && (!$loggedon($nick)) .notice $nick Error! You are not logged on.
  elseif ($left($2,1) == $chr(42)) {
    if ($hget($+(acc_,$right($2,-1)))) {
      .notice $nick Account info for  $+ $right($2,-1) $+ :
      .notice $nick Account: $right($2,-1)
      if ($loggedon($nick).account == $+(acc_,$right($2,-1))) .notice $nick Password: $decode($hget($+(acc_,$right($2,-1)),password),m)
      if ($loggedon($nick).account == $+(acc_,$right($2,-1))) || (!$hget($+(acc_,$right($2,-1)),hideemail)) .notice $nick Email: $hget($+(acc_,$right($2,-1)),email) $iif($loggedon($nick).account == $+(acc_,$right($2,-1)),$+($chr(40),Hide email: $hget($loggedon($nick).account,hideemail),$chr(41)))
      .notice $nick Access: $hget($+(acc_,$right($2,-1)),access)
      .notice $nick Last Used Hostmask: $hget($+(acc_,$right($2,-1)),hostmask)
      .notice $nick Logged On For: $iif(!$hget($+(acc_,$right($2,-1)),ctime),$+($chr(40),not logged on,$chr(41)),$duration($calc($ctime - $hget($+(acc_,$right($2,-1)),ctime))))
      .notice $nick Infoline: $iif($hget($+(acc_,$right($2,-1)),info),$hget($+(acc_,$right($2,-1)),info),$+($chr(40),none,$chr(41)))
    }
    elseif (!$hget($+(acc_,$right($2,-1)))) .notice $nick Error! Unknown account. ( $+ $right($2,-1) $+ )
  }
  elseif ($left($2,1) != $chr(42)) {
    if (!$loggedon($2)) .notice $nick Error! $2 is not logged on.
    elseif ($loggedon($2)) {
      .notice $nick Account info for  $+ $2 $+ :
      .notice $nick Account: $right($loggedon($2).account,-4)
      if ($nick == $2) .notice $nick Email: $hget($loggedon($2).account,email) (Hide email: $hget($loggedon($2).account,hideemail) $+ )
      elseif ($nick != $2) && (!$hget($loggedon($2).account,hideemail)) .notice $nick Email: $hget($loggedon($2).account,email)
      .notice $nick Access: $loggedon($2).access
      .notice $nick Last Used Hostmask: $hget($loggedon($2).account,hostmask)
      .notice $nick Logged On For: $iif(!$hget($loggedon($2).account,ctime),$+($chr(40),not logged on,$chr(41)),$duration($calc($ctime - $hget($loggedon($2).account,ctime))))
      .notice $nick Infoline: $iif($hget($loggedon($2).account,info),$hget($loggedon($2).account,info),$+($chr(40),none,$chr(41)))
    }
  }
}


on *:text:access*:?: {
  if (!$2) {
    if (!$loggedon($nick)) .notice $nick Error! Log in or specify a nickname/account to check.
    elseif ($loggedon($nick)) {
      .notice $nick $nick has the access level  $+ $loggedon($nick).access $+ .
    }
  }
  elseif ($2) {
    if ($left($2,1) == $chr(42)) {
      if ($hget($+(acc_,$right($2,-1)))) {
        .notice $nick $right($2,-1) has the access level  $+ $loggedon($nick).access $+ .
      }
      elseif (!$hget($+(acc_,$right($2,-1)))) .notice $nick Error! Account doesn't exist. ( $+ $right($2,-1) $+ )
    }
    else {
      if (!$loggedon($2)) .notice $nick Error! $2 is not logged on. Please use *account.
      elseif ($loggedon($2)) {
        .notice $nick $2 ( $+ $right($loggedon($2).account,-4) $+ ) has the access level  $+ $loggedon($2).access $+ .
      }
    }
  }
}
on *:text:-access*:#: {
  if (!$2) {
    if (!$loggedon($nick)) .notice $nick Error! Log in or specify a nickname/account to check.
    elseif ($loggedon($nick)) {
      .notice $nick $nick has the access level  $+ $loggedon($nick).access $+ .
    }
  }
  elseif ($2) {
    if ($left($2,1) == $chr(42)) {
      if ($hget($+(acc_,$right($2,-1)))) {
        .notice $nick $right($2,-1) has the access level  $+ $loggedon($nick).access $+ .
      }
      elseif (!$hget($+(acc_,$right($2,-1)))) .notice $nick Error! Account doesn't exist. ( $+ $right($2,-1) $+ )
    }
    else {
      if (!$loggedon($2)) .notice $nick Error! $2 is not logged on. Please use *account.
      elseif ($loggedon($2)) {
        .notice $nick $2 ( $+ $right($loggedon($2).account,-4) $+ ) has the access level  $+ $loggedon($2).access $+ .
      }
    }
  }
}
on *:text:clvl*:?: {
  if (!$loggedon($nick)) .notice $nick Error! Please login before trying to access that command.
  elseif (!$regex($loggedon($nick).access,(leader|coleader))) .notice $nick Error! You lack sufficient access to use that command.
  elseif ($0 != 3) .notice $nick Error! Insufficient parameters. Please use /msg $me clvl nick|*account newlevel
  elseif ($left($2,1) != $chr(42)) && (!$loggedon($2)) .notice $nick Error! $2 is not logged on. Please use *account.
  elseif (!$hget($iif($left($2,1) == $chr(42),$+(acc_,$right($2,-1)),$loggedon($2).account))) .notice $nick Error!: Account $2 doesn't exist.
  elseif ($loggedon($nick).access == coleader) && ($hget($iif($left($2,-1) == $chr(42),$+(acc_,$right($2,-1)),$loggedon($2).account),access) == leader) .notice $nick Error! You cannot clvl the leader!
  else {
    if ($left($2,1) == $chr(42)) {
      if ($hget($+(acc_,$right($2,-1)),access) == $3-) .notice $nick Error! $2 already has the access level  $+ $3- $+ .
      elseif ($hget($+(acc_,$right($2,-1)),access) != $3-) {
        var %access. [ $+ [ $2 ] ] $hget($+(acc_,$right($2,-1)),access)
        hadd $+(acc_,$right($2,-1)) access $3-
        .notice $nick $+($2,'s) access level is now  $+ $3- $+ . (It was: %access. [ $+ [ $2 ] ] $+ )
      }
    }
    else {
      if ($loggedon($2).access == $3-) .notice $nick Error! $2 already has the access level  $+ $3- $+ .
      else {
        var %access. [ $+ [ $2 ] ] $loggedon($2).access
        hadd $loggedon($2).account access $3-
        .notice $nick $+($2,'s) access level is now  $+ $3- $+ . (It was: %access. [ $+ [ $2 ] ])
      }
    }
  }
}
on *:text:uset*:?: {
  if (!$loggedon($nick)) .notice $nick Error! Please login before trying to access that command.
  else {
    if (!$2) {
      .notice $nick Possible user settings:
      .notice $nick /msg $me uset email <email@host.com> (Sets your email)
      .notice $nick /msg $me uset password <password> (Sets your password)
      .notice $nick /msg $me uset hideemail <1 or 0> (Hide your email from others with 1, don't hide it with 0)
      .notice $nick /msg $me uset info <info> (Set your infoline)
    }
    elseif ($0 == 3) {
      if ($2 == hideemail) {
        if ($3 == $hget($loggedon($nick).account,hideemail)) .notice $nick The setting hide email is already set to $3 $+ .
        elseif ($3 !isnum 0-1) .notice $nick Error! Please use 1 or 0 as the setting value. (eg. /msg $me uset hideemail 1)
        else {
          hadd $loggedon($nick).account hideemail $3
          .notice $nick The user setting hide email is now set to $3 $+ .
        }
      }
      elseif ($2 == info) {
        if ($3- == $hget($loggedon($nick).account,info)) .notice $nick The setting infoline is already set to $3- $+ .
        else {
          hadd $loggedon($nick).account info $3-
          .notice $nick The user setting infoline is now set to $3- $+ .
        }
      }
      elseif ($2 == email) {
        var %reg ^[_\.0-9a-zA-Z]+@([0-9a-zA-Z][0-9a-zA-Z]+\.)+[a-zA-Z]{2,3}$
        if (!$regex($3,%reg)) .notice $nick Error! Please insert a correct email. (email@host.com)
        elseif ($3 == $hget($loggedon($nick).account,email)) .notice $nick The setting email is already set to $3 $+ .
        else {
          hadd $loggedon($nick).account email $3
          .notice $nick The user setting email is now set to $3 $+ .
        }
      }
      elseif ($2 == password) {
        if ($encode($3,m) == $hget($loggedon($nick).account,password)) .notice $nick Error! The user setting password is already set to $3 $+ .
        else {
          hadd $loggedon($nick).account password $encode($3,m)
          .notice $nick The uset setting password is now set to $3 $+ .
        }
      }
    }
  }
}
on *:text:forceleader:?: {
  if (!$loggedon($nick)) .notice $nick Error! Please login before trying to access that command.
  elseif ($loggedon($nick).access == leader) .notice $nick Error! You are already the leader.
  elseif ($loggedon($nick)) && ($loggedon($nick).access != leader) {
    var %i 1, %i2
    while ($hget(%i)) {
      if (acc_* iswm $hget(%i)) && ($hfind(%i,leader,0).data) inc %i2
      inc %i
    }
    if (%i2 >= 1) .notice $nick Error! There is already a leader.
    elseif (!%i2) {
      .notice $nick Success! You are now a leader.
      hadd $loggedon($nick).account access leader
    }
  }
}
on *:nick: {
  if ($loggedon($nick)) hadd $loggedon($nick).account nick $newnick
}
on *:quit: {
  if ($loggedon($nick)) {
    hdel $loggedon($nick).account ctime
    hdel users $mask($fulladdress,2)
  }
}