on *:text:*:*:{
  var %t = $left($1,1),%1 = $right($1,-1)
  if (!$chan) close -m $nick
  if (%t !isalnum) {
    if ($hget($nick)) || ($ulevel == admin) {
      if (%1 == amsg) amsgx $+(<,$nick,>) $($2-,2)
      elseif (%1 == qadd) { q.add $2- | _msg $nick Added quote $chr(35) $+ $lines(quotes.txt) }
      elseif (%1 == qdel) _msg $nick $q.del($2-)
      elseif (%1 == qread) _msg $nick $q.read($2-)
      elseif (%1 == qinfo) _msg $nick Quote Information: Total quotes: $iif($lines(quotes.txt),$v1,None! Be the first to add one!)
    }
  }
}
alias amsgx var %msg = $1- | scid -at1 _amsg % $+ msg
alias amex var %msg = $1- | scid -at1 .ame % $+ msg
alias q.start {
  if (!$isfile(quotes.txt)) write quotes.txt
}
alias q.add {
  write quotes.txt $1-
}
alias q.del {
  if ($1 isnum) {
    if ($read(quotes.txt,$1)) { write $+(-dl,$1) quotes.txt | return Deleted line $1 in the quote list. }
    else _msg $nick Invalid line number. 
  }
  elseif ($1 === -s) { 
    if ($read(quotes.txt,s,$2,1)) { write -ds quotes.txt $2 | return Deleted line beginning with $qt($2) }
    else return Not matches of $qt($2) found!
  }
  elseif ($1 === -w) { 
    if ($read(quotes.txt,w,$2-,1)) { write -dw1 quotes.txt $2- | return Deleted every line containing $qt($2-) }
    else return No matches of $qt($2-) found!
  }
  else return what the fuck
}
alias q.read {
  if ($1 isnum $+(1-,$lines(quotes.txt)) ) return $+($chr(35),$1) $read(quotes.txt,$1)
  elseif ($1 === -s) if ($read(quotes.txt,s,$2,1)) return $+($chr(35),$readn) $v1
  elseif ($1 === -w) if ($read(quotes.txt,w,$2-,1)) return $+($chr(35),$readn) $v1
  else { var %q = $read(quotes.txt) | return $+($chr(35),$readn) %q }
}
