Octave: How to attenuate all frequencies except one?
Think of the morse code as an OOK (on-off keying) modulated signal corrupted by additive noise. The optimal linear receiver that can maximize the SNR is matched filter. So "the best" filter you can choose is a filter matched to the frequency of $1$s. After doing that, you have a hypothesis test problem. So you need to choose a threshold (again, the optimal threshold is something known). 

If you decided to go that way, I can give you the details.



Before any details, your code appears to be just a pseudo code. It is really not clear what specific waveform you assume. So I try to give you a general answer.

How to do it:

1 - Find the frequency of the $1$s, using FFT or any other scheme. Let's say it is $f_0$.

2 - You should know the bit duration (i.e. the time each $1$ or $0$ takes). Assume it is $T$.

3 - If the waveform of $1$'s is $s(t)$, then your matched filter is $h(t)=s(T-t)$.

4 - Calculate $y(t)=\int_{0}^{t}r(\tau)h(t-\tau)d\tau$, where $r(t)$ is your noisy signal at each interval $T$. This will give you the output of matched filter. We will look at this output at $t=T$ in each timeslot. In other words, you will have discrete values $y_k$ corresponding to each timeslot.

5 - Now you need a threshold $\gamma$ to decide which part of $y_k$ corresponds to a $0$ and which one is $1$. There are a bunch of options, depending on what you want to achieve, the statistics of noise, and the prior probabilities of $0$s and $1$s. If you are not so strict about optimality, assume equiprobable bits. In AWGN you can assume you will expect equally likely $0$s and $1$s which simplifies your choice. So an option would be just $\gamma$ equal to half of the magnitude difference between $0$s and $1$s.