Also, I found a bug though. If you are not away and then you enter /away, you'll get the output of > [Away] I have returned from: (0secs)So you need to make the else an elseif to check that if you are in fact away instead:
elseif ($away) {
nick $mnick
msg $active [Away] I have returned from: $awaymsg ( $+ $duration($awaytime) $+ )
away
halt
}
This also ensures that you don't start the nick $mnick change and /away routine for nothing upon entering /away when you aren't away by accident.