If I understand what you're saying now, you want to just have them reply the number without the 'voiceme' in front of that. If so, that makes it more complicated for your script, and also introduces the chance of a false positive match.
Without the 'voiceme' in front of it, you'll need to check all incoming query messages to see if any of them consist entirely of a 6 digit number. And you'll also need to check for even shorter numbers, because even though 10% of the time it will be a number with at least 1 leading zero, some people might just type the number without the leading zero(es).
But if you happen to be having an unrelated conversation with someone else, and they happen to type a numeric message such as a yymmdd style date, that could trigger this script to see that someone outside the channel is sending you a number, and your script is now styled to respond to that by putting them on your ignore list.
It's already pretty simple, because your text is showing up in their query window with you, so all they need to do is paste the line right back to you, so you can just have it be something like
.msg $nick Please reply by typing or pasting this text in this window and I will give you voice: voiceme $voicepassword($nick)
If you want to give them 3 chances, an easy way to do that is to create a hashtable containing their fail count. something like:
//hinc -mu10 voicefails $+($network,.,$nick)
... which will either create the item with value of 1, or will increment the prior value. The u10 makes the item go away after 10 seconds, which avoids the need to delete the item after they have success
You can then check their current count by checking $hget( voicefails, $+($network,.,$nick) )
Once they succeed, if you need to delete their item,
/hdel voicefails $+($network,.,$nick)
But the /hdel command halts your script if you try to delete something from a table that doesn't exist.
Also something I hadn't mentioned, was that this is keying off their nick, so someone who changes nick after they get their code will only have the 1 in a million chance that their code works. But at least with the new nick they get their 3 guesses