:relay system
:module
:help.m
on -msg "*" {
	if (numitems(rmsg) >= [20]) {
		@ delitem(rmsg 0)
	}
	@ setitem(rmsg $numitems(rmsg) $fparse(format_msg $time() $0 $userhost() $1-))
}	
on -notice "*" {
	if (numitems(rnot) >= [20]) {
		@ delitem(rnot 0)
	}
	@ setitem(rnot $numitems(rnot) $fparse(format_notice $time() $0 $userhost() $1-))
}
on -send_msg "*" {
	if (numitems(smsg) >= [20]) {
		@ delitem(smsg 0)
	}	
	@ setitem(smsg $numitems(smsg) $fparse(format_send_msg $time() $0 $1-))
}	
on -send_notice "*" {
	if (numitems(snot) >= [20]) {
		@ delitem(snot 0)
	}	
	@ setitem(snot $numitems(snot) $fparse(format_send_notice $time() $0 $1-))
}	
on #-window 2 "*" {
	if (rstat == [0]) {
		if (numitems(rwin) >= winsize()) {
			@ delitem(rwin 0)
		}	
		@ setitem(rwin $numitems(rwin) $1-)
	}		
}
eval addhelp relm&relm $(c4)[$(c3)number$(c4)]&relays recieved message from buffer to active channel or query.
alias relm {
	if (isdigit($0) && [$0] < numitems(rmsg)) {
	        if (Q) {
	                msg $Q $getitem(rmsg $0)
	        }
	        {
	                ^say $getitem(rmsg $0)
	        }
	}		
	{
		for (@j=0,[$j] < [$numitems(rmsg)],@j++) {
			echo $(c4)[$(c3)$[-2]j$(c4)] $getitem(rmsg $j)
		}
		xecho -c $fparse(format_usage relm $(c4)[$(c3)num$(c4)]$(cl))
	}
        ^restub relm relay.m
}
eval addhelp reln&reln $(c4)[$(c3)number$(c4)]&relays recieved notice from buffer to active channel or query.
alias reln {
	if (isdigit($0) && [$0] < numitems(rnot)) {
	        if (Q) {
	                msg $Q $getitem(rnot $0)
	        } 
	        {
	                ^say $getitem(rnot $0)
	        }
	}		
	{
		for (@j=0,[$j] < [$numitems(rnot)],@j++) {
			echo $(c4)[$(c3)$[-2]j$(c4)] $getitem(rnot $j)
		}
		xecho -c $fparse(format_usage reln $(c4)[$(c3)num$(c4)]$(cl))
	}
        ^restub reln relay.m
}
eval addhelp relsm&relsm $(c4)[$(c3)number$(c4)]&relays sent message from buffer to active channel or query.
alias relsm {
        if (isdigit($0) && [$0] < numitems(smsg)) {
	        if (Q) {
	                msg $Q $getitem(smsg $0)
	        }
	        {
	                ^say $getitem(smsg $0)
	        }
        }               
        {
                for (@j=0,[$j] < [$numitems(smsg)],@j++) {
                        echo $(c4)[$(c3)$[-2]j$(c4)] $getitem(smsg $j)
                }
                xecho -c $fparse(format_usage relsm $(c4)[$(c3)num$(c4)]$(cl))
        }
        ^restub relsm relay.m
}
eval addhelp relsn&relsn $(c4)[$(c3)number$(c4)]&relays sent notice from buffer to active channel or query.
alias relsn {
        if (isdigit($0) && [$0] < numitems(snot)) {
	        if (Q) {
	                msg $Q $getitem(snot $0)
	        }
	        {
	                ^say $getitem(snot $0)
	        }
        }               
        {
                for (@j=0,[$j] < [$numitems(snot)],@j++) {
                        echo $(c4)[$(c3)$[-2]j$(c4)] $getitem(snot $j)
                }
                xecho -c $fparse(format_usage relsn $(c4)[$(c3)num$(c4)]$(cl))
        }
        ^restub relsn relay.m
}
eval addhelp relw&relw $(c4)[$(c3)number$(c4)]&relays window line from buffer to active channel or query.
alias relw {
	@ rstat = [1]
        for (@j=0,[$j] < [$numitems(rwin)],@j++) {
                echo $(c4)[$(c3)$[-2]j$(c4)] $getitem(rwin $j)
	}
	input "enter in which line(s) to paste (ie. 5 6 7): " {
	        if (isdigit($0) && [$0] < numitems(rwin)) {
	                if (Q) {
				fe ($0-) line {                           
	                        	msg $Q $getitem(rwin $0)
				}
	                }                               
	                {
				fe ($0-) line {
	                        	^say $getitem(rwin $0)
				}
	                }                             
	        }
	}
	@ rstat = [0]
        ^restub relw relay.m
}
alias paste { 
	relw $0- 
        ^restub paste relay.m
}