add command to display vanity callsign rules (#69)

* add command to display vanity callsign rules

* store callsign info in a separate file for extensibility

* Update callsign_info.py

* Update callsign_info.py

* fix gitignore, make pfx command extensible, fix US formatting
This commit is contained in:
Abigail Gold 2019-11-28 23:48:11 -05:00 committed by GitHub
parent 0b93e642d8
commit f821a2e2f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 86 additions and 0 deletions

View File

@ -13,6 +13,8 @@ from datetime import datetime
import discord
import discord.ext.commands as commands
from resources import callsign_info
class HamCog(commands.Cog):
def __init__(self, bot: commands.Bot):
@ -73,6 +75,33 @@ class HamCog(commands.Cog):
icon_url=str(ctx.author.avatar_url))
await ctx.send(embed=embed)
@commands.command(name="vanities", aliases=["vanity", "pfx", "prefixes", "prefix"])
async def _vanity_prefixes(self, ctx: commands.Context, country: str = None):
'''Lists valid prefixes for countries.'''
if country is None:
await ctx.send_help(ctx.command)
return
if country.lower() not in callsign_info.options:
embed = discord.Embed(title=f'{country} not found!',
description=f'Valid countries: {", ".join(callsign_info.options.keys())}',
colour=self.gs.colours.bad,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
await ctx.send(embed=embed)
return
embed = discord.Embed(title=callsign_info.options[country.lower()][0],
description=callsign_info.options[country.lower()][1],
colour=self.gs.colours.good,
timestamp=datetime.utcnow())
embed.set_footer(text=ctx.author.name,
icon_url=str(ctx.author.avatar_url))
for name, val in callsign_info.options[country.lower()][2].items():
embed.add_field(name=name, value=val, inline=False)
await ctx.send(embed=embed)
def setup(bot: commands.Bot):
bot.add_cog(HamCog(bot))

View File

@ -0,0 +1,57 @@
"""
Information about callsigns for the vanity prefixes command in hamcog.
---
Copyright (C) 2019 Abigail Gold, 0x5c
This file is part of discord-qrmbot and is released under the terms of the GNU
General Public License, version 2.
"""
from collections import OrderedDict
us_calls_title = "Valid US Vanity Callsigns"
us_calls_desc = ('#x# is the number of letters in the prefix and suffix of a callsign.'
'E.g., WY4RC would be a 2x2 callsign, with prefix WY and suffix RC.')
us_calls = OrderedDict([('**Group A** (Extra Only)', ('**Any:** K, N, W (1x2)\n'
' AA-AL, KA-KZ, NA-NZ, WA-WZ (2x1)\n'
' AA-AL (2x2)\n'
'*Except*\n'
'**Alaska:** AL, KL, NL, WL (2x1)\n'
'**Caribbean:** KP, NP, WP (2x1)\n'
'**Pacific:** AH, KH, NH, WH (2x1)')),
('**Group B** (Advanced and Extra Only)', ('**Any:** K, N, W (1x2)\n'
' AA-AL, KA-KZ, NA-NZ, WA-WZ (2x1)\n'
' AA-AL (2x2)\n'
'*Except*\n'
'**Alaska:** AL, KL, NL, WL (2x1)\n'
'**Caribbean:** KP, NP, WP (2x1)\n'
'**Pacific:** AH, KH, NH, WH (2x1)')),
('**Group C** (Technician, General, Advanced, Extra Only)', ('**Any Region:** K, N, W (1x3)\n'
'*Except*\n'
'**Alaska:** KL, NL, WL (2x2)\n'
'**Caribbean:** NP, WP (2x2)\n'
'**Pacific:** KH, NH, WH (2x2)')),
('**Group D** (Any License Class)', ('**Any Region:** KA-KZ, WA-WZ (2x3)\n'
'*Except*\n'
'**Alaska:** KL, WL (2x3)\n'
'**Caribbean:** KP, WP (2x3)\n'
'**Pacific:** KH, WH (2x3)')),
('**Unavailable**', ('- KA2AA-KA9ZZ: US Army in Japan\n'
'- KC4AAA-KC4AAF: NSF in Antartica\n'
'- KC4USA-KC4USZ: US Navy in Antartica\n'
'- KG4AA-KG4ZZ: US Navy in Guantanamo Bay\n'
'- KL9KAA-KL9KHZ: US military in Korea\n'
'- KC6AA-KC6ZZ: Former US (Eastern and Western Caroline Islands), '
'now Federated States of Micronesia (V6) and Republic of Palau (T8)\n'
'- KX6AA-KX6ZZ: Former US (Marshall Islands), '
'now Republic of the Marshall Islands (V73)\n'
'- Any suffix SOS or QRA-QUZ\n'
'- Any 2x3 with X as the first suffix letter\n'
'- Any 2x3 with AF, KF, NF, or WF prefix and suffix EMA\n'
'- Any 2x3 with AA-AL, NA-NZ, WC, WK, WM, WR, or WT prefix\n'
'- Any 2x1, 2x2, or 2x3 with KP, NP, WP prefix and 0, 6, 7, 8, 9 number\n'
'- Any 1x1 callsign'))])
# format: country: (title, description, text)
options = {'us': (us_calls_title, us_calls_desc, us_calls)}