:away logging
:module
:help.m misc.m
eval addhelp readlog&readlog&displays away log.
alias readlog {
	more $twiddle($(corepath)$(corelog))
	input "Clear logs? (y/n): " {
		if ([$0] == [y]) {
			@ rename($(corepath)$(corelog) $(corepath)$(corelog)~)
			xecho -b away logs cleared.
		}
	}
        ^restub readlog logging.m
}
on #-notice 2 "*" {
	if ([$awaylog] == [ON] && [$A] && match(*[*#*]* $1-) == [0]) {
	        @ time = strftime(%x at %X %p)
	        @ lfile = open($twiddle($(corepath)$(corelog)) W T)
	        @ write($lfile $(c4)[$(c3)NOTICE $(c4)]$(c3) $time $fparse(format_notice $time() $0 $userhost() $1-))
	        @ close($lfile)
	}
}

on -notice "*[*#*]*" {
        if ([$awaylog] == [ON] && [$A]) {
                @ time = strftime(%x at %X %p)                    
                @ lfile = open($twiddle($(corepath)$(corelog)) W T)
                @ write($lfile $(c4)[$(c3)NOTICE $(c4)]$(c3) $time $fparse(format_bwall $time() $0 $comchanop($0) $N $1-))
                @ close($lfile)                                                
        }                    
}
on #-msg 2 "*" {
        if ([$awaylog] == [ON] && [$A]) {
                @ time = strftime(%x at %X %p)                     
                @ lfile = open($twiddle($(corepath)$(corelog)) W T)
                @ write($lfile $(c4)[$(c3)MESSAGE$(c4)]$(c3) $time $fparse(format_msg $time() $0 $userhost() $1-))o
                @ close($lfile)
        }
}
on #-dcc_request 2 "*" {
        if ([$awaylog] == [ON] && [$A]) {
                @ time = strftime(%x at %X %p)                     
                @ lfile = open($twiddle($(corepath)$(corelog)) W T)
                @ write($lfile $(c4)[$(c3)REQUEST$(c4)]$(c3) $time $fparse(format_dcc_request $time() $1 $N $0 $userhost() $3 $4 $5 $6))
                @ close($lfile)
        }
}
on #-ctcp 2 "*" {
        if ([$awaylog] == [ON] && [$A]) {
	        if ([$2] == [PAGE]) { 
	                @ time = strftime(%x at %X %p)                                 
	                @ lfile = open($twiddle($(corepath)$(corelog)) W T)
	                @ write($lfile $(c4)[$(c3)REQUEST$(c4)]$(c3) $time $fparse(format_ctcp $time() $0 $userhost() $1 $2 $3-))
	                @ close($lfile)
			if (beeponpage == [on]) {
				@ :beepval = BEEP
		                ^set beep on
		                beep
				beep
				beep
				^set beep $beepval
			}
		}
        }
}