Well the if part is OK as it is, otherwise it wouldnt make any output.
However this must be broken:
echo -s prebot\pre-commands.txt sockwrite -n $sock([ pre. [ $+ [ %group ] [ $+ .* ] ] ],%open)
Im 100% sure the problem is with
$sock([ pre. [ $+ [ %group ] [ $+ .* ] ] ],%open)
I just dont have a clue whats wrong with it...