mirror of
https://github.com/miaowware/qrm2.git
synced 2026-06-02 05:54:40 -04:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c3f002a9df | |||
| ff40f0caca | |||
| c0ad8d1108 | |||
| ce62c93d03 | |||
| c5c065bd47 | |||
| 8f8b7f87de | |||
| 144b288f09 | |||
| dc1efa7b0c | |||
| 38ba8d9d0c |
@@ -75,13 +75,8 @@ body:
|
||||
label: Logs
|
||||
description: If you have a log associated with the bug (tracebacks, etc), paste it directly here.
|
||||
render: none
|
||||
# - id: context
|
||||
# type: textarea
|
||||
# attributes:
|
||||
# label: Additional context, screenshots, etc
|
||||
# description: Add any other relevant context about the problem here.
|
||||
- type: markdown
|
||||
- id: context
|
||||
type: textarea
|
||||
attributes:
|
||||
value: |
|
||||
## Additional context, screenshots, etc
|
||||
Add any other relevant context about the problem here.
|
||||
label: Additional context, screenshots, etc
|
||||
description: Add any other relevant context about the problem here.
|
||||
|
||||
+9
-1
@@ -7,6 +7,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
## [Unreleased]
|
||||
|
||||
|
||||
## [2.7.1] - 2021-04-12
|
||||
### Added
|
||||
- Helpful LaTeX hints for rendering errors in `?tex`.
|
||||
### Fixed
|
||||
- Bug where `?call` would crash if the found profile only had empty address fields.
|
||||
|
||||
|
||||
## [2.7.0] - 2021-04-03
|
||||
### Added
|
||||
- `?tex` command to render a LaTeX expression.
|
||||
@@ -186,7 +193,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
## 1.0.0 - 2019-07-31 [YANKED]
|
||||
|
||||
|
||||
[Unreleased]: https://github.com/miaowware/qrm2/compare/v2.7.0...HEAD
|
||||
[Unreleased]: https://github.com/miaowware/qrm2/compare/v2.7.1...HEAD
|
||||
[2.7.1]: https://github.com/miaowware/qrm2/releases/tag/v2.7.1
|
||||
[2.7.0]: https://github.com/miaowware/qrm2/releases/tag/v2.7.0
|
||||
[2.6.0]: https://github.com/miaowware/qrm2/releases/tag/v2.6.0
|
||||
[2.5.1]: https://github.com/miaowware/qrm2/releases/tag/v2.5.1
|
||||
|
||||
@@ -42,8 +42,9 @@ colours = SimpleNamespace(
|
||||
|
||||
|
||||
class BoltCats(enum.Enum):
|
||||
ADMIN = "Bot Control"
|
||||
OTHER = "Other"
|
||||
INFO = "Bot Information"
|
||||
ADMIN = "Bot Control"
|
||||
|
||||
|
||||
# meow
|
||||
|
||||
+44
-3
@@ -10,11 +10,12 @@ the GNU General Public License, version 2.
|
||||
|
||||
import random
|
||||
import re
|
||||
from typing import Union
|
||||
from typing import Union, Iterable
|
||||
import pathlib
|
||||
|
||||
import discord
|
||||
import discord.ext.commands as commands
|
||||
from discord.ext.commands import Command, CommandError
|
||||
|
||||
import info
|
||||
import common as cmn
|
||||
@@ -31,12 +32,52 @@ class QrmHelpCommand(commands.HelpCommand):
|
||||
self.verify_checks = True
|
||||
self.context: commands.Context
|
||||
|
||||
async def filter_commands(self, commands: Iterable[Command]) -> list[Command]:
|
||||
def sort_by_cat(cmds):
|
||||
ret = []
|
||||
bolt_cmds = {}
|
||||
for c in cmds:
|
||||
cat = c.__original_kwargs__.get("category", cmn.BoltCats.OTHER)
|
||||
if isinstance(cat, cmn.BoltCats):
|
||||
if cat in bolt_cmds:
|
||||
bolt_cmds[cat].append(c)
|
||||
else:
|
||||
bolt_cmds[cat] = [c]
|
||||
cmds.remove(c)
|
||||
else:
|
||||
ret.append(c)
|
||||
|
||||
ret.sort(key=lambda c: c.__original_kwargs__["category"].name)
|
||||
|
||||
for cat in cmn.BoltCats:
|
||||
ret += sorted(bolt_cmds[cat], key=lambda c: c.name)
|
||||
|
||||
return ret
|
||||
|
||||
iterator = commands if self.show_hidden else filter(lambda c: not c.hidden, commands)
|
||||
|
||||
if not self.verify_checks:
|
||||
return sort_by_cat(iterator)
|
||||
|
||||
async def predicate(cmd):
|
||||
try:
|
||||
return await cmd.can_run(self.context)
|
||||
except CommandError:
|
||||
return False
|
||||
|
||||
cmds = []
|
||||
for cmd in iterator:
|
||||
if await predicate(cmd):
|
||||
cmds.append(cmd)
|
||||
|
||||
return sort_by_cat(cmds)
|
||||
|
||||
async def get_bot_mapping(self):
|
||||
bot = self.context.bot
|
||||
mapping = {}
|
||||
|
||||
for cmd in await self.filter_commands(bot.commands, sort=True):
|
||||
cat = cmd.__original_kwargs__.get("category", None)
|
||||
for cmd in await self.filter_commands(bot.commands):
|
||||
cat = cmd.__original_kwargs__.get("category", cmn.BoltCats.OTHER)
|
||||
if cat in mapping:
|
||||
mapping[cat].append(cmd)
|
||||
else:
|
||||
|
||||
+6
-2
@@ -78,7 +78,7 @@ class QRZCog(commands.Cog):
|
||||
embed.set_thumbnail(url=data.image.url)
|
||||
|
||||
for title, val in qrz_process_info(data).items():
|
||||
if val is not None:
|
||||
if val:
|
||||
embed.add_field(name=title, value=val, inline=True)
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
@@ -99,7 +99,11 @@ def qrz_process_info(data: qrztools.QrzCallsignData) -> Dict:
|
||||
|
||||
if data.address != qrztools.Address():
|
||||
state = ", " + data.address.state + " " if data.address.state else ""
|
||||
address = "\n".join([data.address.attn, data.address.line1, data.address.line2 + state, data.address.zip])
|
||||
address = "\n".join(
|
||||
[x for x
|
||||
in [data.address.attn, data.address.line1, data.address.line2 + state, data.address.zip]
|
||||
if x]
|
||||
)
|
||||
else:
|
||||
address = None
|
||||
|
||||
|
||||
+9
-2
@@ -28,7 +28,10 @@ class TexCog(commands.Cog):
|
||||
|
||||
@commands.command(name="tex", aliases=["latex"], category=cmn.Cats.UTILS)
|
||||
async def tex(self, ctx: commands.Context, *, expr: str):
|
||||
"""Renders a LaTeX expression."""
|
||||
"""Renders a LaTeX expression.
|
||||
|
||||
In paragraph mode by default. To render math, add `$` around math expressions.
|
||||
"""
|
||||
payload = {
|
||||
"format": "png",
|
||||
"code": self.template.replace("#CONTENT#", expr),
|
||||
@@ -45,7 +48,11 @@ class TexCog(commands.Cog):
|
||||
if render_result["status"] != "success":
|
||||
embed = cmn.embed_factory(ctx)
|
||||
embed.title = "LaTeX Rendering Failed!"
|
||||
embed.description = render_result.get("description", "Unknown error")
|
||||
embed.description = ("Here are some common reasons:\n"
|
||||
"• Did you forget to use math mode? Surround math expressions with `$`,"
|
||||
" like `$x^3$`.\n"
|
||||
"• Are you using a command from a package? It might not be available.\n"
|
||||
"• Are you including the document headers? We already did that for you.")
|
||||
embed.colour = cmn.colours.bad
|
||||
await ctx.send(embed=embed)
|
||||
return
|
||||
|
||||
@@ -15,5 +15,5 @@ contributing = """Check out the [source on GitHub](https://github.com/miaowware/
|
||||
|
||||
All issues and requests related to resources (including maps, band charts, data) should be added \
|
||||
in [miaowware/qrm-resources](https://github.com/miaowware/qrm-resources)."""
|
||||
release = "2.7.0"
|
||||
release = "2.7.1"
|
||||
bot_server = "https://discord.gg/Ntbg3J4"
|
||||
|
||||
Reference in New Issue
Block a user