Changed all categories to enums

- Accidentally fixed capitalisation of help command categories

Fixes #383
This commit is contained in:
0x5c 2021-03-28 02:38:36 -04:00
parent c569fdb422
commit f6d69f7498
No known key found for this signature in database
GPG Key ID: A57F71C3176B9581
17 changed files with 74 additions and 63 deletions

View File

@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Main name and aliases of `?bandplan`. - Main name and aliases of `?bandplan`.
### Fixed ### Fixed
- Lack of input sanitisation in `?xkcd`. - Lack of input sanitisation in `?xkcd`.
- Incorrect capitalisation of the categories in the `?help` command.
## [2.6.0] - 2021-03-18 ## [2.6.0] - 2021-03-18

View File

@ -9,6 +9,7 @@ the GNU General Public License, version 2.
import collections import collections
import enum
import json import json
import re import re
import traceback import traceback
@ -26,7 +27,7 @@ from discord import Emoji, Reaction, PartialEmoji
import data.options as opt import data.options as opt
__all__ = ["colours", "cat", "emojis", "paths", "ImageMetadata", "ImagesGroup", __all__ = ["colours", "BoltCats", "Cats", "emojis", "paths", "ImageMetadata", "ImagesGroup",
"embed_factory", "error_embed_factory", "add_react", "check_if_owner"] "embed_factory", "error_embed_factory", "add_react", "check_if_owner"]
@ -39,16 +40,21 @@ colours = SimpleNamespace(
timeout=0xF26522, timeout=0xF26522,
) )
class BoltCats(enum.Enum):
ADMIN = "Bot Control"
INFO = "Bot Information"
# meow # meow
cat = SimpleNamespace( class Cats(enum.Enum):
lookup="Information Lookup", LOOKUP = "Information Lookup"
fun="Fun", FUN = "Fun"
maps="Mapping", MAPS = "Mapping"
ref="Reference", REF = "Reference"
study="Exam Study", STUDY = "Exam Study"
weather="Land and Space Weather", WEATHER = "Land and Space Weather"
admin="Bot Control",
)
emojis = SimpleNamespace( emojis = SimpleNamespace(
check_mark="", check_mark="",

View File

@ -29,13 +29,13 @@ class AE7QCog(commands.Cog):
self.bot = bot self.bot = bot
self.session = aiohttp.ClientSession(connector=bot.qrm.connector) self.session = aiohttp.ClientSession(connector=bot.qrm.connector)
@commands.group(name="ae7q", aliases=["ae"], case_insensitive=True, category=cmn.cat.lookup) @commands.group(name="ae7q", aliases=["ae"], case_insensitive=True, category=cmn.Cats.LOOKUP)
async def _ae7q_lookup(self, ctx: commands.Context): async def _ae7q_lookup(self, ctx: commands.Context):
"""Looks up a callsign, FRN, or Licensee ID on [ae7q.com](http://ae7q.com/).""" """Looks up a callsign, FRN, or Licensee ID on [ae7q.com](http://ae7q.com/)."""
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
await ctx.send_help(ctx.command) await ctx.send_help(ctx.command)
@_ae7q_lookup.command(name="call", aliases=["c"], category=cmn.cat.lookup) @_ae7q_lookup.command(name="call", aliases=["c"], category=cmn.Cats.LOOKUP)
async def _ae7q_call(self, ctx: commands.Context, callsign: str): async def _ae7q_call(self, ctx: commands.Context, callsign: str):
"""Looks up the history of a callsign on [ae7q.com](http://ae7q.com/).""" """Looks up the history of a callsign on [ae7q.com](http://ae7q.com/)."""
with ctx.typing(): with ctx.typing():
@ -109,7 +109,7 @@ class AE7QCog(commands.Cog):
await ctx.send(embed=embed) await ctx.send(embed=embed)
@_ae7q_lookup.command(name="trustee", aliases=["t"], category=cmn.cat.lookup) @_ae7q_lookup.command(name="trustee", aliases=["t"], category=cmn.Cats.LOOKUP)
async def _ae7q_trustee(self, ctx: commands.Context, callsign: str): async def _ae7q_trustee(self, ctx: commands.Context, callsign: str):
"""Looks up the licenses for which a licensee is trustee on [ae7q.com](http://ae7q.com/).""" """Looks up the licenses for which a licensee is trustee on [ae7q.com](http://ae7q.com/)."""
with ctx.typing(): with ctx.typing():
@ -184,7 +184,7 @@ class AE7QCog(commands.Cog):
await ctx.send(embed=embed) await ctx.send(embed=embed)
@_ae7q_lookup.command(name="applications", aliases=["a"], category=cmn.cat.lookup) @_ae7q_lookup.command(name="applications", aliases=["a"], category=cmn.Cats.LOOKUP)
async def _ae7q_applications(self, ctx: commands.Context, callsign: str): async def _ae7q_applications(self, ctx: commands.Context, callsign: str):
"""Looks up the application history for a callsign on [ae7q.com](http://ae7q.com/).""" """Looks up the application history for a callsign on [ae7q.com](http://ae7q.com/)."""
""" """
@ -262,7 +262,7 @@ class AE7QCog(commands.Cog):
raise NotImplementedError("Application history lookup not yet supported. " raise NotImplementedError("Application history lookup not yet supported. "
"Check back in a later version of the bot.") "Check back in a later version of the bot.")
@_ae7q_lookup.command(name="frn", aliases=["f"], category=cmn.cat.lookup) @_ae7q_lookup.command(name="frn", aliases=["f"], category=cmn.Cats.LOOKUP)
async def _ae7q_frn(self, ctx: commands.Context, frn: str): async def _ae7q_frn(self, ctx: commands.Context, frn: str):
"""Looks up the history of an FRN on [ae7q.com](http://ae7q.com/).""" """Looks up the history of an FRN on [ae7q.com](http://ae7q.com/)."""
""" """
@ -337,7 +337,7 @@ class AE7QCog(commands.Cog):
await ctx.send(embed=embed) await ctx.send(embed=embed)
@_ae7q_lookup.command(name="licensee", aliases=["l"], category=cmn.cat.lookup) @_ae7q_lookup.command(name="licensee", aliases=["l"], category=cmn.Cats.LOOKUP)
async def _ae7q_licensee(self, ctx: commands.Context, licensee_id: str): async def _ae7q_licensee(self, ctx: commands.Context, licensee_id: str):
"""Looks up the history of a licensee ID on [ae7q.com](http://ae7q.com/).""" """Looks up the history of a licensee ID on [ae7q.com](http://ae7q.com/)."""
with ctx.typing(): with ctx.typing():

View File

@ -23,7 +23,11 @@ from data import options as opt
class QrmHelpCommand(commands.HelpCommand): class QrmHelpCommand(commands.HelpCommand):
def __init__(self): def __init__(self):
super().__init__(command_attrs={"help": "Shows help about qrm or a command", "aliases": ["h"]}) super().__init__(command_attrs={
"help": "Shows help about qrm or a command",
"aliases": ["h"],
# TODO "category": cmn.BoltCats.INFO
})
self.verify_checks = True self.verify_checks = True
self.context: commands.Context self.context: commands.Context
@ -73,7 +77,7 @@ class QrmHelpCommand(commands.HelpCommand):
continue continue
names = sorted([cmd.name for cmd in cmds]) names = sorted([cmd.name for cmd in cmds])
if cat is not None: if cat is not None:
embed.add_field(name=cat.title(), value=", ".join(names), inline=False) embed.add_field(name=cat.value, value=", ".join(names), inline=False)
else: else:
embed.add_field(name="Other", value=", ".join(names), inline=False) embed.add_field(name="Other", value=", ".join(names), inline=False)
await self.context.send(embed=embed) await self.context.send(embed=embed)
@ -136,7 +140,7 @@ class BaseCog(commands.Cog):
self.bot_invite = (f"https://discordapp.com/oauth2/authorize?client_id={self.bot.user.id}" self.bot_invite = (f"https://discordapp.com/oauth2/authorize?client_id={self.bot.user.id}"
f"&scope=bot&permissions={opt.invite_perms}") f"&scope=bot&permissions={opt.invite_perms}")
@commands.command(name="info", aliases=["about"]) @commands.command(name="info", aliases=["about"]) # TODO , category=cmn.BoltCats.INFO)
async def _info(self, ctx: commands.Context): async def _info(self, ctx: commands.Context):
"""Shows info about qrm.""" """Shows info about qrm."""
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
@ -154,7 +158,7 @@ class BaseCog(commands.Cog):
embed.set_thumbnail(url=str(self.bot.user.avatar_url)) embed.set_thumbnail(url=str(self.bot.user.avatar_url))
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="ping", aliases=["beep"]) @commands.command(name="ping", aliases=["beep"]) # TODO , category=cmn.BoltCats.INFO)
async def _ping(self, ctx: commands.Context): async def _ping(self, ctx: commands.Context):
"""Shows the current latency to the discord endpoint.""" """Shows the current latency to the discord endpoint."""
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
@ -167,7 +171,7 @@ class BaseCog(commands.Cog):
embed.description = f"Current ping is {self.bot.latency*1000:.1f} ms" embed.description = f"Current ping is {self.bot.latency*1000:.1f} ms"
await ctx.send(content, embed=embed) await ctx.send(content, embed=embed)
@commands.command(name="changelog", aliases=["clog"]) @commands.command(name="changelog", aliases=["clog"]) # TODO , category=cmn.BoltCats.INFO)
async def _changelog(self, ctx: commands.Context, version: str = "latest"): async def _changelog(self, ctx: commands.Context, version: str = "latest"):
"""Shows what has changed in a bot version. Defaults to the latest version.""" """Shows what has changed in a bot version. Defaults to the latest version."""
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
@ -203,7 +207,7 @@ class BaseCog(commands.Cog):
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="issue") @commands.command(name="issue") # TODO , category=cmn.BoltCats.INFO)
async def _issue(self, ctx: commands.Context): async def _issue(self, ctx: commands.Context):
"""Shows how to create a bug report or feature request about the bot.""" """Shows how to create a bug report or feature request about the bot."""
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
@ -215,7 +219,7 @@ class BaseCog(commands.Cog):
[miaowware/qrm-resources](https://github.com/miaowware/qrm-resources/issues).""" [miaowware/qrm-resources](https://github.com/miaowware/qrm-resources/issues)."""
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="donate", aliases=["tip"]) @commands.command(name="donate", aliases=["tip"]) # TODO , category=cmn.BoltCats.INFO)
async def _donate(self, ctx: commands.Context): async def _donate(self, ctx: commands.Context):
"""Shows ways to help support development of the bot via donations.""" """Shows ways to help support development of the bot via donations."""
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
@ -226,7 +230,7 @@ class BaseCog(commands.Cog):
embed.add_field(name=title, value=url, inline=False) embed.add_field(name=title, value=url, inline=False)
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="invite", enabled=opt.enable_invite_cmd) @commands.command(name="invite", enabled=opt.enable_invite_cmd) # TODO , category=cmn.BoltCats.INFO)
async def _invite(self, ctx: commands.Context): async def _invite(self, ctx: commands.Context):
"""Generates a link to invite the bot to a server.""" """Generates a link to invite the bot to a server."""
if not (await self.bot.application_info()).bot_public: if not (await self.bot.application_info()).bot_public:
@ -236,7 +240,7 @@ class BaseCog(commands.Cog):
embed.description = self.bot_invite embed.description = self.bot_invite
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="echo", aliases=["e"], category=cmn.cat.admin) @commands.command(name="echo", aliases=["e"], category=cmn.BoltCats.ADMIN)
@commands.check(cmn.check_if_owner) @commands.check(cmn.check_if_owner)
async def _echo(self, ctx: commands.Context, async def _echo(self, ctx: commands.Context,
channel: Union[cmn.GlobalChannelConverter, commands.UserConverter], *, msg: str): channel: Union[cmn.GlobalChannelConverter, commands.UserConverter], *, msg: str):

View File

@ -67,7 +67,7 @@ class DbConvCog(commands.Cog):
def __init__(self, bot: commands.Bot): def __init__(self, bot: commands.Bot):
self.bot = bot self.bot = bot
@commands.command(name="dbconv", aliases=["dbc"], category=cmn.cat.ref) @commands.command(name="dbconv", aliases=["dbc"], category=cmn.Cats.REF)
async def _db_conv(self, ctx: commands.Context, async def _db_conv(self, ctx: commands.Context,
value: Optional[float] = None, value: Optional[float] = None,
unit_from: Optional[UnitConverter] = None, unit_from: Optional[UnitConverter] = None,

View File

@ -26,22 +26,22 @@ class FunCog(commands.Cog):
with open(cmn.paths.resources / "words.1.txt") as words_file: with open(cmn.paths.resources / "words.1.txt") as words_file:
self.words = words_file.read().lower().splitlines() self.words = words_file.read().lower().splitlines()
@commands.command(name="xkcd", aliases=["x"], category=cmn.cat.fun) @commands.command(name="xkcd", aliases=["x"], category=cmn.Cats.FUN)
async def _xkcd(self, ctx: commands.Context, number: int): async def _xkcd(self, ctx: commands.Context, number: int):
"""Looks up an xkcd comic by number.""" """Looks up an xkcd comic by number."""
await ctx.send("http://xkcd.com/" + str(number)) await ctx.send("http://xkcd.com/" + str(number))
@commands.command(name="tar", category=cmn.cat.fun) @commands.command(name="tar", category=cmn.Cats.FUN)
async def _tar(self, ctx: commands.Context): async def _tar(self, ctx: commands.Context):
"""Returns xkcd: tar.""" """Returns xkcd: tar."""
await ctx.send("http://xkcd.com/1168") await ctx.send("http://xkcd.com/1168")
@commands.command(name="standards", category=cmn.cat.fun) @commands.command(name="standards", category=cmn.Cats.FUN)
async def _standards(self, ctx: commands.Context): async def _standards(self, ctx: commands.Context):
"""Returns xkcd: Standards.""" """Returns xkcd: Standards."""
await ctx.send("http://xkcd.com/927") await ctx.send("http://xkcd.com/927")
@commands.command(name="worksplit", aliases=["split", "ft8"], category=cmn.cat.fun) @commands.command(name="worksplit", aliases=["split", "ft8"], category=cmn.Cats.FUN)
async def _worksplit(self, ctx: commands.Context): async def _worksplit(self, ctx: commands.Context):
"""Posts "Work split you lids".""" """Posts "Work split you lids"."""
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
@ -49,12 +49,12 @@ class FunCog(commands.Cog):
embed.set_image(url=opt.resources_url + self.imgs["worksplit"]) embed.set_image(url=opt.resources_url + self.imgs["worksplit"])
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="xd", hidden=True, category=cmn.cat.fun) @commands.command(name="xd", hidden=True, category=cmn.Cats.FUN)
async def _xd(self, ctx: commands.Context): async def _xd(self, ctx: commands.Context):
"""ecks dee""" """ecks dee"""
await ctx.send("ECKS DEE :smirk:") await ctx.send("ECKS DEE :smirk:")
@commands.command(name="funetics", aliases=["fun"], category=cmn.cat.fun) @commands.command(name="funetics", aliases=["fun"], category=cmn.Cats.FUN)
async def _funetics_lookup(self, ctx: commands.Context, *, msg: str): async def _funetics_lookup(self, ctx: commands.Context, *, msg: str):
"""Generates fun/wacky phonetics for a word or phrase.""" """Generates fun/wacky phonetics for a word or phrase."""
result = "" result = ""

View File

@ -19,7 +19,7 @@ class GridCog(commands.Cog):
def __init__(self, bot: commands.Bot): def __init__(self, bot: commands.Bot):
self.bot = bot self.bot = bot
@commands.command(name="grid", category=cmn.cat.maps) @commands.command(name="grid", category=cmn.Cats.MAPS)
async def _grid_sq_lookup(self, ctx: commands.Context, lat: float, lon: float): async def _grid_sq_lookup(self, ctx: commands.Context, lat: float, lon: float):
("""Calculates the grid square for latitude and longitude coordinates.""" ("""Calculates the grid square for latitude and longitude coordinates."""
"""\n\nCoordinates should be in decimal format, with negative being latitude South and longitude West.""" """\n\nCoordinates should be in decimal format, with negative being latitude South and longitude West."""
@ -33,7 +33,7 @@ class GridCog(commands.Cog):
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="latlong", aliases=["latlon", "loc", "ungrid"], category=cmn.cat.maps) @commands.command(name="latlong", aliases=["latlon", "loc", "ungrid"], category=cmn.Cats.MAPS)
async def _location_lookup(self, ctx: commands.Context, grid: str): async def _location_lookup(self, ctx: commands.Context, grid: str):
("""Calculates the latitude and longitude for the center of a grid locator.""" ("""Calculates the latitude and longitude for the center of a grid locator."""
"""\n\nTo calculate the grid locator from a latitude and longitude, use `grid`""" """\n\nTo calculate the grid locator from a latitude and longitude, use `grid`"""
@ -49,7 +49,7 @@ class GridCog(commands.Cog):
"latlong` to see other names for this command.*")) "latlong` to see other names for this command.*"))
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="griddistance", aliases=["griddist", "distance", "dist"], category=cmn.cat.maps) @commands.command(name="griddistance", aliases=["griddist", "distance", "dist"], category=cmn.Cats.MAPS)
async def _dist_lookup(self, ctx: commands.Context, grid1: str, grid2: str): async def _dist_lookup(self, ctx: commands.Context, grid1: str, grid2: str):
"""Calculates the great circle distance and azimuthal bearing between two grid locators.""" """Calculates the great circle distance and azimuthal bearing between two grid locators."""
g1 = gridtools.Grid(grid1) g1 = gridtools.Grid(grid1)

View File

@ -28,7 +28,7 @@ class HamCog(commands.Cog):
with open(cmn.paths.resources / "qcodes.1.json") as file: with open(cmn.paths.resources / "qcodes.1.json") as file:
self.qcodes: dict = json.load(file) self.qcodes: dict = json.load(file)
@commands.command(name="qcode", aliases=["q"], category=cmn.cat.ref) @commands.command(name="qcode", aliases=["q"], category=cmn.Cats.REF)
async def _qcode_lookup(self, ctx: commands.Context, qcode: str): async def _qcode_lookup(self, ctx: commands.Context, qcode: str):
"""Looks up the meaning of a Q Code.""" """Looks up the meaning of a Q Code."""
qcode = qcode.upper() qcode = qcode.upper()
@ -42,7 +42,7 @@ class HamCog(commands.Cog):
embed.colour = cmn.colours.bad embed.colour = cmn.colours.bad
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="phonetics", aliases=["ph", "phoneticize", "phoneticise", "phone"], category=cmn.cat.ref) @commands.command(name="phonetics", aliases=["ph", "phoneticize", "phoneticise", "phone"], category=cmn.Cats.REF)
async def _phonetics_lookup(self, ctx: commands.Context, *, msg: str): async def _phonetics_lookup(self, ctx: commands.Context, *, msg: str):
"""Returns NATO phonetics for a word or phrase.""" """Returns NATO phonetics for a word or phrase."""
result = "" result = ""
@ -58,7 +58,7 @@ class HamCog(commands.Cog):
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="utc", aliases=["z"], category=cmn.cat.ref) @commands.command(name="utc", aliases=["z"], category=cmn.Cats.REF)
async def _utc_lookup(self, ctx: commands.Context): async def _utc_lookup(self, ctx: commands.Context):
"""Returns the current time in UTC.""" """Returns the current time in UTC."""
now = datetime.utcnow() now = datetime.utcnow()
@ -69,7 +69,7 @@ class HamCog(commands.Cog):
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="prefixes", aliases=["vanity", "pfx", "vanities", "prefix"], category=cmn.cat.ref) @commands.command(name="prefixes", aliases=["vanity", "pfx", "vanities", "prefix"], category=cmn.Cats.REF)
async def _vanity_prefixes(self, ctx: commands.Context, country: str = ""): async def _vanity_prefixes(self, ctx: commands.Context, country: str = ""):
"""Lists valid callsign prefixes for different countries.""" """Lists valid callsign prefixes for different countries."""
country = country.lower() country = country.lower()
@ -93,7 +93,7 @@ class HamCog(commands.Cog):
embed.add_field(name=name, value=val, inline=False) embed.add_field(name=name, value=val, inline=False)
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="contests", aliases=["cc", "tests"], category=cmn.cat.ref) @commands.command(name="contests", aliases=["cc", "tests"], category=cmn.Cats.REF)
async def _contests(self, ctx: commands.Context): async def _contests(self, ctx: commands.Context):
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
embed.title = "Contest Calendar" embed.title = "Contest Calendar"
@ -102,7 +102,7 @@ class HamCog(commands.Cog):
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="phoneticweight", aliases=["pw"], category=cmn.cat.ref) @commands.command(name="phoneticweight", aliases=["pw"], category=cmn.Cats.REF)
async def _weight(self, ctx: commands.Context, *, msg: str): async def _weight(self, ctx: commands.Context, *, msg: str):
"""Calculates the phonetic weight of a callsign or message.""" """Calculates the phonetic weight of a callsign or message."""
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)

View File

@ -27,17 +27,17 @@ class ImageCog(commands.Cog):
self.maps = cmn.ImagesGroup(cmn.paths.resources / "maps.1.json") self.maps = cmn.ImagesGroup(cmn.paths.resources / "maps.1.json")
self.session = aiohttp.ClientSession(connector=bot.qrm.connector) self.session = aiohttp.ClientSession(connector=bot.qrm.connector)
@commands.command(name="bandchart", aliases=["bandplan", "plan", "bands"], category=cmn.cat.ref) @commands.command(name="bandchart", aliases=["bandplan", "plan", "bands"], category=cmn.Cats.REF)
async def _bandcharts(self, ctx: commands.Context, chart_id: str = ""): async def _bandcharts(self, ctx: commands.Context, chart_id: str = ""):
"""Gets the frequency allocations chart for a given country.""" """Gets the frequency allocations chart for a given country."""
await ctx.send(embed=create_embed(ctx, "Bandchart", self.bandcharts, chart_id)) await ctx.send(embed=create_embed(ctx, "Bandchart", self.bandcharts, chart_id))
@commands.command(name="map", category=cmn.cat.maps) @commands.command(name="map", category=cmn.Cats.MAPS)
async def _map(self, ctx: commands.Context, map_id: str = ""): async def _map(self, ctx: commands.Context, map_id: str = ""):
"""Posts a ham-relevant map.""" """Posts a ham-relevant map."""
await ctx.send(embed=create_embed(ctx, "Map", self.maps, map_id)) await ctx.send(embed=create_embed(ctx, "Map", self.maps, map_id))
@commands.command(name="grayline", aliases=["greyline", "grey", "gray", "gl"], category=cmn.cat.maps) @commands.command(name="grayline", aliases=["greyline", "grey", "gray", "gl"], category=cmn.Cats.MAPS)
async def _grayline(self, ctx: commands.Context): async def _grayline(self, ctx: commands.Context):
"""Gets a map of the current greyline, where HF propagation is the best.""" """Gets a map of the current greyline, where HF propagation is the best."""
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)

View File

@ -30,7 +30,7 @@ class LookupCog(commands.Cog):
self.cty = BigCty() self.cty = BigCty()
# TODO: See #107 # TODO: See #107
# @commands.command(name="sat", category=cmn.cat.lookup) # @commands.command(name="sat", category=cmn.Cats.Lookup)
# async def _sat_lookup(self, ctx: commands.Context, sat_name: str, grid1: str, grid2: str = None): # async def _sat_lookup(self, ctx: commands.Context, sat_name: str, grid1: str, grid2: str = None):
# """Links to info about satellite passes on satmatch.com.""" # """Links to info about satellite passes on satmatch.com."""
# now = datetime.utcnow().strftime("%Y-%m-%d%%20%H:%M") # now = datetime.utcnow().strftime("%Y-%m-%d%%20%H:%M")
@ -41,7 +41,7 @@ class LookupCog(commands.Cog):
# await ctx.send(f"http://www.satmatch.com/satellite/{sat_name}/obs1/{grid1}" # await ctx.send(f"http://www.satmatch.com/satellite/{sat_name}/obs1/{grid1}"
# f"/obs2/{grid2}?search_start_time={now}&duration_hrs=24") # f"/obs2/{grid2}?search_start_time={now}&duration_hrs=24")
@commands.command(name="dxcc", aliases=["dx"], category=cmn.cat.lookup) @commands.command(name="dxcc", aliases=["dx"], category=cmn.Cats.LOOKUP)
async def _dxcc_lookup(self, ctx: commands.Context, query: str): async def _dxcc_lookup(self, ctx: commands.Context, query: str):
"""Gets DXCC info about a callsign prefix.""" """Gets DXCC info about a callsign prefix."""
query = query.upper() query = query.upper()

View File

@ -23,7 +23,7 @@ class MorseCog(commands.Cog):
self.morse: dict[str, str] = d["morse"] self.morse: dict[str, str] = d["morse"]
self.ascii: dict[str, int] = d["ascii"] self.ascii: dict[str, int] = d["ascii"]
@commands.command(name="morse", aliases=["cw"], category=cmn.cat.ref) @commands.command(name="morse", aliases=["cw"], category=cmn.Cats.REF)
async def _morse(self, ctx: commands.Context, *, msg: str): async def _morse(self, ctx: commands.Context, *, msg: str):
"""Converts ASCII to international morse code.""" """Converts ASCII to international morse code."""
result = "" result = ""
@ -39,7 +39,7 @@ class MorseCog(commands.Cog):
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="unmorse", aliases=["demorse", "uncw", "decw"], category=cmn.cat.ref) @commands.command(name="unmorse", aliases=["demorse", "uncw", "decw"], category=cmn.Cats.REF)
async def _unmorse(self, ctx: commands.Context, *, msg: str): async def _unmorse(self, ctx: commands.Context, *, msg: str):
"""Converts international morse code to ASCII.""" """Converts international morse code to ASCII."""
result = "" result = ""
@ -59,7 +59,7 @@ class MorseCog(commands.Cog):
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="cwweight", aliases=["weight", "cww"], category=cmn.cat.ref) @commands.command(name="cwweight", aliases=["weight", "cww"], category=cmn.Cats.REF)
async def _weight(self, ctx: commands.Context, *, msg: str): async def _weight(self, ctx: commands.Context, *, msg: str):
"""Calculates the CW weight of a callsign or message.""" """Calculates the CW weight of a callsign or message."""
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)

View File

@ -27,7 +27,7 @@ class PropagationCog(commands.Cog):
self.bot = bot self.bot = bot
self.session = aiohttp.ClientSession(connector=bot.qrm.connector) self.session = aiohttp.ClientSession(connector=bot.qrm.connector)
@commands.command(name="mufmap", aliases=["muf"], category=cmn.cat.weather) @commands.command(name="mufmap", aliases=["muf"], category=cmn.Cats.WEATHER)
async def mufmap(self, ctx: commands.Context): async def mufmap(self, ctx: commands.Context):
"""Shows a world map of the Maximum Usable Frequency (MUF).""" """Shows a world map of the Maximum Usable Frequency (MUF)."""
async with ctx.typing(): async with ctx.typing():
@ -41,7 +41,7 @@ class PropagationCog(commands.Cog):
embed.set_image(url="attachment://muf_map.png") embed.set_image(url="attachment://muf_map.png")
await ctx.send(file=file, embed=embed) await ctx.send(file=file, embed=embed)
@commands.command(name="fof2map", aliases=["fof2", "critfreq"], category=cmn.cat.weather) @commands.command(name="fof2map", aliases=["fof2", "critfreq"], category=cmn.Cats.WEATHER)
async def fof2map(self, ctx: commands.Context): async def fof2map(self, ctx: commands.Context):
"""Shows a world map of the Critical Frequency (foF2).""" """Shows a world map of the Critical Frequency (foF2)."""
async with ctx.typing(): async with ctx.typing():

View File

@ -40,7 +40,7 @@ class QRZCog(commands.Cog):
except AttributeError: except AttributeError:
pass pass
@commands.command(name="call", aliases=["qrz"], category=cmn.cat.lookup) @commands.command(name="call", aliases=["qrz"], category=cmn.Cats.LOOKUP)
async def _qrz_lookup(self, ctx: commands.Context, callsign: str, *flags): async def _qrz_lookup(self, ctx: commands.Context, callsign: str, *flags):
"""Looks up a callsign on [QRZ.com](https://www.qrz.com/). Add `--link` to only link the QRZ page.""" """Looks up a callsign on [QRZ.com](https://www.qrz.com/). Add `--link` to only link the QRZ page."""
flags = [f.lower() for f in flags] flags = [f.lower() for f in flags]

View File

@ -31,7 +31,7 @@ class StudyCog(commands.Cog):
self.source = "Data courtesy of [HamStudy.org](https://hamstudy.org/)" self.source = "Data courtesy of [HamStudy.org](https://hamstudy.org/)"
self.session = aiohttp.ClientSession(connector=bot.qrm.connector) self.session = aiohttp.ClientSession(connector=bot.qrm.connector)
@commands.command(name="hamstudy", aliases=["rq", "randomquestion", "randomq"], category=cmn.cat.study) @commands.command(name="hamstudy", aliases=["rq", "randomquestion", "randomq"], category=cmn.Cats.STUDY)
async def _random_question(self, ctx: commands.Context, country: str = "", level: str = "", element: str = ""): async def _random_question(self, ctx: commands.Context, country: str = "", level: str = "", element: str = ""):
"""Gets a random question from [HamStudy's](https://hamstudy.org) question pools.""" """Gets a random question from [HamStudy's](https://hamstudy.org) question pools."""
with ctx.typing(): with ctx.typing():

View File

@ -26,7 +26,7 @@ class TexCog(commands.Cog):
with open(cmn.paths.resources / "template.1.tex") as latex_template: with open(cmn.paths.resources / "template.1.tex") as latex_template:
self.template = latex_template.read() self.template = latex_template.read()
@commands.command(name="tex", aliases=["latex"], category=cmn.cat.fun) @commands.command(name="tex", aliases=["latex"], category=cmn.Cats.FUN)
async def tex(self, ctx: commands.Context, *, expr: str): async def tex(self, ctx: commands.Context, *, expr: str):
"""Renders a LaTeX expression.""" """Renders a LaTeX expression."""
payload = { payload = {

View File

@ -27,7 +27,7 @@ class WeatherCog(commands.Cog):
self.session = aiohttp.ClientSession(connector=bot.qrm.connector) self.session = aiohttp.ClientSession(connector=bot.qrm.connector)
@commands.command(name="solarweather", aliases=["solar", "bandconditions", "cond", "condx", "conditions"], @commands.command(name="solarweather", aliases=["solar", "bandconditions", "cond", "condx", "conditions"],
category=cmn.cat.weather) category=cmn.Cats.WEATHER)
async def solarweather(self, ctx: commands.Context): async def solarweather(self, ctx: commands.Context):
"""Gets a solar weather report.""" """Gets a solar weather report."""
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
@ -40,7 +40,7 @@ class WeatherCog(commands.Cog):
embed.set_image(url="http://www.hamqsl.com/solarsun.php") embed.set_image(url="http://www.hamqsl.com/solarsun.php")
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.group(name="weather", aliases=["wttr"], case_insensitive=True, category=cmn.cat.weather) @commands.group(name="weather", aliases=["wttr"], case_insensitive=True, category=cmn.Cats.WEATHER)
async def _weather_conditions(self, ctx: commands.Context): async def _weather_conditions(self, ctx: commands.Context):
"""Gets local weather conditions from [wttr.in](http://wttr.in/). """Gets local weather conditions from [wttr.in](http://wttr.in/).
@ -57,7 +57,7 @@ class WeatherCog(commands.Cog):
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
await ctx.send_help(ctx.command) await ctx.send_help(ctx.command)
@_weather_conditions.command(name="forecast", aliases=["fc", "future"], category=cmn.cat.weather) @_weather_conditions.command(name="forecast", aliases=["fc", "future"], category=cmn.Cats.WEATHER)
async def _weather_conditions_forecast(self, ctx: commands.Context, *, location: str): async def _weather_conditions_forecast(self, ctx: commands.Context, *, location: str):
"""Gets local weather forecast for the next three days from [wttr.in](http://wttr.in/). """Gets local weather forecast for the next three days from [wttr.in](http://wttr.in/).
See help of the `weather` command for possible location types and options.""" See help of the `weather` command for possible location types and options."""
@ -83,7 +83,7 @@ class WeatherCog(commands.Cog):
embed.set_image(url=f"http://wttr.in/{loc}_{units}pnFQ.png") embed.set_image(url=f"http://wttr.in/{loc}_{units}pnFQ.png")
await ctx.send(embed=embed) await ctx.send(embed=embed)
@_weather_conditions.command(name="now", aliases=["n"], category=cmn.cat.weather) @_weather_conditions.command(name="now", aliases=["n"], category=cmn.Cats.WEATHER)
async def _weather_conditions_now(self, ctx: commands.Context, *, location: str): async def _weather_conditions_now(self, ctx: commands.Context, *, location: str):
"""Gets current local weather conditions from [wttr.in](http://wttr.in/). """Gets current local weather conditions from [wttr.in](http://wttr.in/).
See help of the `weather` command for possible location types and options.""" See help of the `weather` command for possible location types and options."""
@ -109,7 +109,7 @@ class WeatherCog(commands.Cog):
embed.set_image(url=f"http://wttr.in/{loc}_0{units}pnFQ.png") embed.set_image(url=f"http://wttr.in/{loc}_0{units}pnFQ.png")
await ctx.send(embed=embed) await ctx.send(embed=embed)
@commands.command(name="metar", category=cmn.cat.weather) @commands.command(name="metar", category=cmn.Cats.WEATHER)
async def metar(self, ctx: commands.Context, airport: str, hours: int = 0): async def metar(self, ctx: commands.Context, airport: str, hours: int = 0):
"""Gets current raw METAR (Meteorological Terminal Aviation Routine Weather Report) for an airport. \ """Gets current raw METAR (Meteorological Terminal Aviation Routine Weather Report) for an airport. \
Optionally, a number of hours can be given to show a number of hours of historical METAR data. Optionally, a number of hours can be given to show a number of hours of historical METAR data.
@ -118,7 +118,7 @@ class WeatherCog(commands.Cog):
[ICAO code](https://en.wikipedia.org/wiki/List_of_airports_by_IATA_and_ICAO_code).""" [ICAO code](https://en.wikipedia.org/wiki/List_of_airports_by_IATA_and_ICAO_code)."""
await ctx.send(embed=await self.gen_metar_taf_embed(ctx, airport, hours, False)) await ctx.send(embed=await self.gen_metar_taf_embed(ctx, airport, hours, False))
@commands.command(name="taf", category=cmn.cat.weather) @commands.command(name="taf", category=cmn.Cats.WEATHER)
async def taf(self, ctx: commands.Context, airport: str): async def taf(self, ctx: commands.Context, airport: str):
"""Gets forecasted raw TAF (Terminal Aerodrome Forecast) data for an airport. Includes the latest METAR data. """Gets forecasted raw TAF (Terminal Aerodrome Forecast) data for an airport. Includes the latest METAR data.

View File

@ -74,7 +74,7 @@ bot.qrm.debug_mode = debug_mode
# --- Commands --- # --- Commands ---
@bot.command(name="restart", aliases=["rs"], category=cmn.cat.admin) @bot.command(name="restart", aliases=["rs"], category=cmn.BoltCats.ADMIN)
@commands.check(cmn.check_if_owner) @commands.check(cmn.check_if_owner)
async def _restart_bot(ctx: commands.Context): async def _restart_bot(ctx: commands.Context):
"""Restarts the bot.""" """Restarts the bot."""
@ -85,7 +85,7 @@ async def _restart_bot(ctx: commands.Context):
await bot.logout() await bot.logout()
@bot.command(name="shutdown", aliases=["shut"], category=cmn.cat.admin) @bot.command(name="shutdown", aliases=["shut"], category=cmn.BoltCats.ADMIN)
@commands.check(cmn.check_if_owner) @commands.check(cmn.check_if_owner)
async def _shutdown_bot(ctx: commands.Context): async def _shutdown_bot(ctx: commands.Context):
"""Shuts down the bot.""" """Shuts down the bot."""
@ -96,7 +96,7 @@ async def _shutdown_bot(ctx: commands.Context):
await bot.logout() await bot.logout()
@bot.group(name="extctl", aliases=["ex"], case_insensitive=True, category=cmn.cat.admin) @bot.group(name="extctl", aliases=["ex"], case_insensitive=True, category=cmn.BoltCats.ADMIN)
@commands.check(cmn.check_if_owner) @commands.check(cmn.check_if_owner)
async def _extctl(ctx: commands.Context): async def _extctl(ctx: commands.Context):
"""Extension control commands. """Extension control commands.