miaowware / qrm2

A discord bot with ham radio functions
Other
19 stars 13 forks source link

Callsign validity checker command #75

Closed classabbyamp closed 3 years ago

classabbyamp commented 4 years ago

I'm half-thinking that we should make a callsign validator when the command is provided with a call after the country

>>> ?pfx us
[us table]
>>> ?pfx us N0CALL
Invalid format: 1x4

does that means that pfx is a group or we parse that as an optional arg?

Could use my callsign.me project as a jumping off point (requires finishing callsign.me)

0x5c commented 4 years ago

But callsign.me does not do simple validation, unless I misunderstood And a request to an api for that seems a bit futile to me

classabbyamp commented 4 years ago

the intent of the project is to do validation, so that code could be re-used for the bot. no api request.

0x5c commented 4 years ago

ah ok, that makes sense

classabbyamp commented 4 years ago

ITU callsign rules: https://www.itu.int/en/ITU-R/terrestrial/fmd/Documents/fxm-art19-sec3.pdf

classabbyamp commented 3 years ago

I have a callsign regex here: ([0-9A-Z]+/)?([BFGIKMNRW]|[0-9A-Z]{2,3})[0-9][0-9A-Z]*[A-Z](/[0-9A-Z]+)? that should work for matching callsigns, including PFX/CALL/SFX

0x5c commented 3 years ago

That regex could also capture the groups and allow for the result to have info about the parts, ie country prefix, area number, suffix, if the call is special long format, etc