:misc functions
:base
:help.m


alias channame {
        if ([$[1]0]==[#]) {
                return $0
        }
        {
                return #$0
        }
        ^restub channame window.m
}
alias v { voice $0- }
eval addhelp refresh&refresh&refreshes screen to fix distortion.
alias refresh { 
	parsekey refresh_screen 
        ^restub refresh misc.m
}
alias quit {
	if ([$0]) { 
		eval //quit $qstr $*
	}	
	{	
		if (fexist(~/.BitchX/BitchX.quit) == 1) {
			eval //quit $qstr $getreason($N ~/.BitchX/BitchX.quit)
		}
		{	
			eval //quit $qstr $N has no reason.
		}
	}
        ^restub quit misc.m
}
alias rci {
	switch ($rand(8)) {
		(0) { ^set client_information  dead bodies everywhere }
		(1) { ^set client_information  segmentation fault, core dumped. }
		(2) { ^set client_information  all day i dream about fucking... }
		(3) { ^set client_information  i got your beans in my bag... }   
		(4) { ^set client_information  i'm known for eatin lil whiney chumps like you. }
		(5) { ^set client_information  suck my dick and fuckin like it }
		(6) { ^set client_information  kentucky fried kung pow clits... }
		(*) { ^set client_information  what if i should die... }
	}
        ^restub rci misc.m
}
on -ctcp * { 
	if ([$2]==[VERSION]) { rci } 
}
/*shade getuhost and ismask*/
alias getuhost
{
        wait for userhost $0 -cmd
        {
                return ${[$4] != [<UNKNOWN>] ? [$3@$4] :}
        }
        ^restub getuhost misc.m
}
alias isonline {
        wait for userhost $0 -cmd {
                return ${[$4] != [<UNKNOWN>] ? [1] : [0]}
        }
        ^restub isonline misc.m
}
alias ismask {return ${pass(!@ $0) ? 1 : 0}}
on ^timer "%:00*" { 
	if (left(1 $Z) == [0]) { 
		@ time = [$right(6 $Z)] 
	}
	{
		@ time = [$Z]
	}
	@ time = [$strip(amp $time)]
	xecho -b the time is now $(c2)$time$(c3) $right(2 $Z). 
} 
^on connect "*" { 
	^set mangle_inbound ANSI
	^set auto_away off
}
alias isonchan {
	if (match($1 $onchannel($0)) != [0]) {
		return 1
	}
        ^restub inonchan misc.m
}
alias comchan {
	^assign -comchans
	fe ($mychannels()) mychan {
		if (isonchan($mychan $0)) { push comchans $mychan }
	}
	return $comchans
        ^restub comchan misc.m
}
alias comchanop {
	^assign -comchans
        fe ($mychannels()) mychan {
                if (isonchan($mychan $0)) { 
			if (ischanop($N $mychan)) { push comchans $mychan }
		}
        }
        return $comchans
        ^restub comchanop misc.m
}
on ^channel_synch * {
	xecho -b Join to $0 was synced in $1 sec(s).
}
alias core {
	^assign -k
        fe ($glob($(corepath)ansi\/*)) ansi {
                @ k++   
        }
	@ ansfile = open($twiddle($(corepath)ansi/core.$(rand($k))) R T)
	        while (!eof($ansfile)) {
	                echo $read($ansfile)
	        }
	@ close($ansfile)
        ^restub core misc.m
}
#modified oweffs fix.size
alias fix.size {
        ^local _s
        @_s=[$0]
        ^stack push set floating_point_math_var
        ^set floating_point_math_var on
        if (_s <= 0) { @function_return=[0b] }
        if (_s > 0 && _s < 1024) { @function_return=[${_s}b] }
        if (_s >= 1024 && _s < 1048576) {
                @_fv=[$trunc(1 ${_s/1024})]
                @function_return=[${_fv}kb]
        }
        if (_s >= 1048576 && _s < 1073741824) {
                @_fvm=[$trunc(1 ${_s/1048576})]
                @function_return=[${_fvm}mb]
        }
        if (_s >= 1073741824 && _s < 1099511627776) {
                @_fvm=[$trunc(1 ${_s/1073741824})]
                @function_return=[${_fvm}gb]   
        }
        if (_s >= 1099511627776) {
                @_fvm=[$trunc(1 ${_s/1099511627776})]   
                @function_return=[${_fvm}tb]      
        }
        ^stack pop set floating_point_math_var
        ^restub fix.size misc.m
}
alias keybind {
        eval ^bind ^A parse_command dcc_get
        eval ^bind ^a parse_command dcc_get
        eval ^bind ^R parse_command dcc_rej
        eval ^bind ^r parse_command dcc_rej
        eval ^bind ^[[11~ parse_command $f1
        eval ^bind ^[[12~ parse_command $f2
        eval ^bind ^[[13~ parse_command $f3
        eval ^bind ^[[14~ parse_command $f4
        eval ^bind ^[[15~ parse_command $f5
        eval ^bind ^[[17~ parse_command $f6
        eval ^bind ^[[3~ delete_character
        eval ^bind META3-A parse_command $f1
        eval ^bind META3-B parse_command $f2
        eval ^bind META3-C parse_command $f3
        eval ^bind META3-D parse_command $f4
        eval ^bind META3-E parse_command $f5
        eval ^bind META3-7 parse_command $f6
        eval ^bind ^W meta5_character
        eval ^bind META5-1    PARSE_COMMAND win1
        eval ^bind META5-2    PARSE_COMMAND win2
        eval ^bind META5-3    PARSE_COMMAND win3
        eval ^bind META5-4    PARSE_COMMAND win4
        eval ^bind META5-5    PARSE_COMMAND win5
        eval ^bind META5-6    PARSE_COMMAND win6
        eval ^bind META5-7    PARSE_COMMAND win7
        eval ^bind META5-8    PARSE_COMMAND win8
        eval ^bind META5-9    PARSE_COMMAND win9
        eval ^bind META5-c    PARSE_COMMAND wc  
        eval ^bind META5-k    PARSE_COMMAND wk  
        eval ^bind META5-h    PARSE_COMMAND wh  
        eval ^bind META5-p    PARSE_COMMAND wp  
        eval ^bind META5-n    PARSE_COMMAND wn  
        ^restub keybind misc.m
}
