Merge branch 'master' into qrztools-integration

This commit is contained in:
Abigail G 2021-03-16 22:15:49 -04:00
commit 3134c41191
No known key found for this signature in database
GPG Key ID: 6BE0755918A4C7F5
3 changed files with 56 additions and 5 deletions

View File

@ -10,6 +10,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Commands to show METAR (`?metar`) and TAF (`?taf`) (aeronautical weather conditions).
- The ability to select an element of a pool in `?hamstudy`.
- The ability to answer ❓ to a HamStudy question to get the answer.
- The list of available prefixes to `?help` when there is more than one.
- `?donate` command to show ways to support qrm's development.
- `?invite` command to invite qrm to your server.
- Configuration options to disable showing the `?invite` and set default invite permissions (enabled by default).
- Configuration option to show QRZ nickname in place of first name (enabled by default).
### Changed
@ -21,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Library used for QRZ lookups.
### Fixed
- Weird image caching situation for `?greyline` on Discord's side.
- The help command was not using the prefix it was invoked with.
### Deprecated
- `?ungrid`.
- Deprecated old `?solar` aliases (`?cond`, etc).

View File

@ -18,14 +18,14 @@ import discord.ext.commands as commands
import info
import common as cmn
import data.options as opt
from data import options as opt
class QrmHelpCommand(commands.HelpCommand):
def __init__(self):
super().__init__(command_attrs={"help": "Shows help about qrm or a command", "aliases": ["h"]})
self.verify_checks = True
self.context: commands.Context
async def get_bot_mapping(self):
bot = self.context.bot
@ -47,9 +47,9 @@ class QrmHelpCommand(commands.HelpCommand):
if parent:
fmt = f"{parent} {fmt}"
alias = fmt
return f"{opt.display_prefix}{alias} {command.signature}\n *Aliases:* {aliases}"
return f"{self.context.prefix}{alias} {command.signature}\n *Aliases:* {aliases}"
alias = command.name if not parent else f"{parent} {command.name}"
return f"{opt.display_prefix}{alias} {command.signature}"
return f"{self.context.prefix}{alias} {command.signature}"
async def send_error_message(self, error):
embed = cmn.embed_factory(self.context)
@ -61,8 +61,11 @@ class QrmHelpCommand(commands.HelpCommand):
async def send_bot_help(self, mapping):
embed = cmn.embed_factory(self.context)
embed.title = "qrm Help"
embed.description = (f"For command-specific help and usage, use `{opt.display_prefix}help [command name]`."
embed.description = (f"For command-specific help and usage, use `{self.context.prefix}help [command name]`."
" Many commands have shorter aliases.")
if isinstance(self.context.bot.command_prefix, list):
embed.description += (" All of the following prefixes work with the bot: `"
+ "`, `".join(self.context.bot.command_prefix) + "`.")
mapping = await mapping
for cat, cmds in mapping.items():
@ -118,6 +121,20 @@ class BaseCog(commands.Cog):
self.commit = bf.readline().strip()[:7]
else:
self.commit = ""
self.donation_links = {
"Ko-Fi": "https://ko-fi.com/miaowware",
"LiberaPay": "https://liberapay.com/miaowware",
}
self.bot_invite = None
if self.bot.user:
self.bot_invite = (f"https://discordapp.com/oauth2/authorize?client_id={self.bot.user.id}"
f"&scope=bot&permissions={opt.invite_perms}")
@commands.Cog.listener()
async def on_ready(self):
if not self.bot_invite:
self.bot_invite = (f"https://discordapp.com/oauth2/authorize?client_id={self.bot.user.id}"
f"&scope=bot&permissions={opt.invite_perms}")
@commands.command(name="info", aliases=["about"])
async def _info(self, ctx: commands.Context):
@ -130,6 +147,10 @@ class BaseCog(commands.Cog):
embed.add_field(name="Version", value=f"v{info.release} {'(`' + self.commit + '`)' if self.commit else ''}")
embed.add_field(name="Contributing", value=info.contributing, inline=False)
embed.add_field(name="Official Server", value=info.bot_server, inline=False)
embed.add_field(name="Donate", value="\n".join(f"{k}: {v}" for k, v in self.donation_links.items()),
inline=False)
if opt.enable_invite_cmd:
embed.add_field(name="Invite qrm to Your Server", value=self.bot_invite, inline=False)
embed.set_thumbnail(url=str(self.bot.user.avatar_url))
await ctx.send(embed=embed)
@ -194,6 +215,25 @@ class BaseCog(commands.Cog):
[miaowware/qrm-resources](https://github.com/miaowware/qrm-resources/issues)."""
await ctx.send(embed=embed)
@commands.command(name="donate")
async def _donate(self, ctx: commands.Context):
"""Shows ways to help support development of the bot via donations."""
embed = cmn.embed_factory(ctx)
embed.title = "Help Support qrm's Development!"
embed.description = ("Donations are always appreciated, and help with server and infrastructure costs."
"\nThank you for your support!")
for title, url in self.donation_links.items():
embed.add_field(name=title, value=url, inline=False)
await ctx.send(embed=embed)
@commands.command(name="invite", enabled=opt.enable_invite_cmd)
async def _invite(self, ctx: commands.Context):
"""Generates a link to invite the bot to a server."""
embed = cmn.embed_factory(ctx)
embed.title = "Invite qrm to Your Server!"
embed.description = self.bot_invite
await ctx.send(embed=embed)
@commands.command(name="echo", aliases=["e"], category=cmn.cat.admin)
@commands.check(cmn.check_if_owner)
async def _echo(self, ctx: commands.Context,

View File

@ -50,6 +50,13 @@ exts = [
# if False: use QRZ's default name format
qrz_only_nickname = True
# enable a command that provides a link to add the bot to a server
enable_invite_cmd = True
# the default permissions for the bot, to be included in the invite link for ?invite
# this probably does not need to be changed
invite_perms = 67488832
# Either "time", "random", or "fixed" (first item in statuses)
status_mode = "fixed"