mirror of
https://github.com/miaowware/qrm2.git
synced 2026-06-02 22:14:53 -04:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2eb183ff08 | |||
| 0cb6ccd285 | |||
| f55738a8a2 | |||
| abf79b844e | |||
| c3f002a9df | |||
| ff40f0caca | |||
| c0ad8d1108 | |||
| ce62c93d03 | |||
| c5c065bd47 | |||
| 8f8b7f87de | |||
| 144b288f09 | |||
| dc1efa7b0c | |||
| 38ba8d9d0c |
@@ -75,13 +75,8 @@ body:
|
|||||||
label: Logs
|
label: Logs
|
||||||
description: If you have a log associated with the bug (tracebacks, etc), paste it directly here.
|
description: If you have a log associated with the bug (tracebacks, etc), paste it directly here.
|
||||||
render: none
|
render: none
|
||||||
# - id: context
|
- id: context
|
||||||
# type: textarea
|
type: textarea
|
||||||
# attributes:
|
|
||||||
# label: Additional context, screenshots, etc
|
|
||||||
# description: Add any other relevant context about the problem here.
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
attributes:
|
||||||
value: |
|
label: Additional context, screenshots, etc
|
||||||
## Additional context, screenshots, etc
|
description: Add any other relevant context about the problem here.
|
||||||
Add any other relevant context about the problem here.
|
|
||||||
|
|||||||
+15
-1
@@ -7,6 +7,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
|
||||||
|
## [2.7.2] - 2021-04-12
|
||||||
|
### Fixed
|
||||||
|
- Issue where `?help` might not work for all people.
|
||||||
|
|
||||||
|
|
||||||
|
## [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
|
## [2.7.0] - 2021-04-03
|
||||||
### Added
|
### Added
|
||||||
- `?tex` command to render a LaTeX expression.
|
- `?tex` command to render a LaTeX expression.
|
||||||
@@ -186,7 +198,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
## 1.0.0 - 2019-07-31 [YANKED]
|
## 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.2...HEAD
|
||||||
|
[2.7.2]: https://github.com/miaowware/qrm2/releases/tag/v2.7.2
|
||||||
|
[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.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.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
|
[2.5.1]: https://github.com/miaowware/qrm2/releases/tag/v2.5.1
|
||||||
|
|||||||
@@ -42,8 +42,9 @@ colours = SimpleNamespace(
|
|||||||
|
|
||||||
|
|
||||||
class BoltCats(enum.Enum):
|
class BoltCats(enum.Enum):
|
||||||
ADMIN = "Bot Control"
|
OTHER = "Other"
|
||||||
INFO = "Bot Information"
|
INFO = "Bot Information"
|
||||||
|
ADMIN = "Bot Control"
|
||||||
|
|
||||||
|
|
||||||
# meow
|
# meow
|
||||||
|
|||||||
+45
-3
@@ -10,11 +10,12 @@ the GNU General Public License, version 2.
|
|||||||
|
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
from typing import Union
|
from typing import Union, Iterable
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import discord.ext.commands as commands
|
import discord.ext.commands as commands
|
||||||
|
from discord.ext.commands import Command, CommandError
|
||||||
|
|
||||||
import info
|
import info
|
||||||
import common as cmn
|
import common as cmn
|
||||||
@@ -31,12 +32,53 @@ class QrmHelpCommand(commands.HelpCommand):
|
|||||||
self.verify_checks = True
|
self.verify_checks = True
|
||||||
self.context: commands.Context
|
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:
|
||||||
|
if cat in bolt_cmds:
|
||||||
|
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):
|
async def get_bot_mapping(self):
|
||||||
bot = self.context.bot
|
bot = self.context.bot
|
||||||
mapping = {}
|
mapping = {}
|
||||||
|
|
||||||
for cmd in await self.filter_commands(bot.commands, sort=True):
|
for cmd in await self.filter_commands(bot.commands):
|
||||||
cat = cmd.__original_kwargs__.get("category", None)
|
cat = cmd.__original_kwargs__.get("category", cmn.BoltCats.OTHER)
|
||||||
if cat in mapping:
|
if cat in mapping:
|
||||||
mapping[cat].append(cmd)
|
mapping[cat].append(cmd)
|
||||||
else:
|
else:
|
||||||
|
|||||||
+6
-2
@@ -78,7 +78,7 @@ class QRZCog(commands.Cog):
|
|||||||
embed.set_thumbnail(url=data.image.url)
|
embed.set_thumbnail(url=data.image.url)
|
||||||
|
|
||||||
for title, val in qrz_process_info(data).items():
|
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)
|
embed.add_field(name=title, value=val, inline=True)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@@ -99,7 +99,11 @@ def qrz_process_info(data: qrztools.QrzCallsignData) -> Dict:
|
|||||||
|
|
||||||
if data.address != qrztools.Address():
|
if data.address != qrztools.Address():
|
||||||
state = ", " + data.address.state + " " if data.address.state else ""
|
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:
|
else:
|
||||||
address = None
|
address = None
|
||||||
|
|
||||||
|
|||||||
+9
-2
@@ -28,7 +28,10 @@ class TexCog(commands.Cog):
|
|||||||
|
|
||||||
@commands.command(name="tex", aliases=["latex"], category=cmn.Cats.UTILS)
|
@commands.command(name="tex", aliases=["latex"], category=cmn.Cats.UTILS)
|
||||||
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.
|
||||||
|
|
||||||
|
In paragraph mode by default. To render math, add `$` around math expressions.
|
||||||
|
"""
|
||||||
payload = {
|
payload = {
|
||||||
"format": "png",
|
"format": "png",
|
||||||
"code": self.template.replace("#CONTENT#", expr),
|
"code": self.template.replace("#CONTENT#", expr),
|
||||||
@@ -45,7 +48,11 @@ class TexCog(commands.Cog):
|
|||||||
if render_result["status"] != "success":
|
if render_result["status"] != "success":
|
||||||
embed = cmn.embed_factory(ctx)
|
embed = cmn.embed_factory(ctx)
|
||||||
embed.title = "LaTeX Rendering Failed!"
|
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
|
embed.colour = cmn.colours.bad
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
return
|
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 \
|
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)."""
|
in [miaowware/qrm-resources](https://github.com/miaowware/qrm-resources)."""
|
||||||
release = "2.7.0"
|
release = "2.7.2"
|
||||||
bot_server = "https://discord.gg/Ntbg3J4"
|
bot_server = "https://discord.gg/Ntbg3J4"
|
||||||
|
|||||||
Reference in New Issue
Block a user