Merge branch 'master' into moar-bandcharts

This commit is contained in:
classabbyamp 2020-10-31 20:28:18 -04:00 committed by GitHub
commit 0bfa0c6e41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 65 additions and 85 deletions

View File

@ -6,9 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased] ## [Unreleased]
### Added ### Added
- Italian (`it_hf`, `it_vhf`, `it_shf`) and Australian (`au`) band charts. - Italian (`it_hf`, `it_vhf`, `it_shf`), Japanese (`jp`) and Australian (`au`) band charts.
### Fixed ### Fixed
- Details to the Netherlands bandplan command to accurately represent VERNON (Netherlands ARRL equivalent organisation).
- eQSL, paper QSL, and Logbook of the World status in `?qrz` sometimes being shown incorrectly. - eQSL, paper QSL, and Logbook of the World status in `?qrz` sometimes being shown incorrectly.
- Fixed network error in `?greyline`.
## [2.4.1] - 2020-10-06 ## [2.4.1] - 2020-10-06

View File

@ -108,7 +108,6 @@ class BaseCog(commands.Cog):
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
embed.title = "About qrm" embed.title = "About qrm"
embed.description = info.description embed.description = info.description
embed.add_field(name="Authors", value=", ".join(info.authors)) embed.add_field(name="Authors", value=", ".join(info.authors))
embed.add_field(name="License", value=info.license) embed.add_field(name="License", value=info.license)
embed.add_field(name="Version", value=f"v{info.release}") embed.add_field(name="Version", value=f"v{info.release}")

View File

@ -19,7 +19,7 @@ import common as cmn
class FunCog(commands.Cog): class FunCog(commands.Cog):
def __init__(self, bot: commands.Bot): def __init__(self, bot: commands.Bot):
self.bot = bot self.bot = bot
with open("resources/words") as words_file: with open(cmn.paths.resources / "words") 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.cat.fun)

View File

@ -8,8 +8,6 @@ the GNU General Public License, version 2.
""" """
import io
import aiohttp import aiohttp
import discord import discord
@ -85,16 +83,11 @@ class ImageCog(commands.Cog):
@commands.command(name="grayline", aliases=["greyline", "grey", "gray", "gl"], category=cmn.cat.maps) @commands.command(name="grayline", aliases=["greyline", "grey", "gray", "gl"], category=cmn.cat.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."""
async with ctx.typing(): embed = cmn.embed_factory(ctx)
embed = cmn.embed_factory(ctx) embed.title = "Current Greyline Conditions"
embed.title = "Current Greyline Conditions" embed.colour = cmn.colours.good
embed.colour = cmn.colours.good embed.set_image(url=self.gl_url)
async with self.session.get(self.gl_url) as resp: await ctx.send(embed=embed)
if resp.status != 200:
raise cmn.BotHTTPError(resp)
data = io.BytesIO(await resp.read())
embed.set_image(url="attachment://greyline.jpg")
await ctx.send(embed=embed, file=discord.File(data, "greyline.jpg"))
def setup(bot: commands.Bot): def setup(bot: commands.Bot):

View File

@ -9,6 +9,7 @@ the GNU General Public License, version 2.
import threading import threading
from pathlib import Path
from ctyparser import BigCty from ctyparser import BigCty
@ -17,11 +18,14 @@ from discord.ext import commands, tasks
import common as cmn import common as cmn
cty_path = Path("./data/cty.json")
class LookupCog(commands.Cog): class LookupCog(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
try: try:
self.cty = BigCty("./data/cty.json") self.cty = BigCty(cty_path)
except OSError: except OSError:
self.cty = BigCty() self.cty = BigCty()
@ -67,7 +71,7 @@ class LookupCog(commands.Cog):
@tasks.loop(hours=24) @tasks.loop(hours=24)
async def _update_cty(self): async def _update_cty(self):
update = threading.Thread(target=run_update, args=(self.cty, "./data/cty.json")) update = threading.Thread(target=run_update, args=(self.cty, cty_path))
update.start() update.start()

View File

@ -8,12 +8,10 @@ the GNU General Public License, version 2.
""" """
import io
import re import re
import aiohttp import aiohttp
import discord
import discord.ext.commands as commands import discord.ext.commands as commands
import common as cmn import common as cmn
@ -29,16 +27,11 @@ class WeatherCog(commands.Cog):
@commands.command(name="bandconditions", aliases=["cond", "condx", "conditions"], category=cmn.cat.weather) @commands.command(name="bandconditions", aliases=["cond", "condx", "conditions"], category=cmn.cat.weather)
async def _band_conditions(self, ctx: commands.Context): async def _band_conditions(self, ctx: commands.Context):
"""Gets a solar conditions report.""" """Gets a solar conditions report."""
async with ctx.typing(): embed = cmn.embed_factory(ctx)
embed = cmn.embed_factory(ctx) embed.title = "Current Solar Conditions"
embed.title = "Current Solar Conditions" embed.colour = cmn.colours.good
embed.colour = cmn.colours.good embed.set_image(url="http://www.hamqsl.com/solarsun.php")
async with self.session.get("http://www.hamqsl.com/solarsun.php") as resp: await ctx.send(embed=embed)
if resp.status != 200:
raise cmn.BotHTTPError(resp)
data = io.BytesIO(await resp.read())
embed.set_image(url="attachment://condx.png")
await ctx.send(embed=embed, file=discord.File(data, "condx.png"))
@commands.group(name="weather", aliases=["wttr"], case_insensitive=True, category=cmn.cat.weather) @commands.group(name="weather", aliases=["wttr"], case_insensitive=True, category=cmn.cat.weather)
async def _weather_conditions(self, ctx: commands.Context): async def _weather_conditions(self, ctx: commands.Context):
@ -61,63 +54,53 @@ class WeatherCog(commands.Cog):
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."""
async with ctx.typing(): try:
try: units_arg = re.search(self.wttr_units_regex, location).group(1)
units_arg = re.search(self.wttr_units_regex, location).group(1) except AttributeError:
except AttributeError: units_arg = ""
units_arg = "" if units_arg.lower() == "f":
if units_arg.lower() == "f": units = "u"
units = "u" elif units_arg.lower() == "c":
elif units_arg.lower() == "c": units = "m"
units = "m" else:
else: units = ""
units = ""
loc = self.wttr_units_regex.sub("", location).strip() loc = self.wttr_units_regex.sub("", location).strip()
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
embed.title = f"Weather Forecast for {loc}" embed.title = f"Weather Forecast for {loc}"
embed.description = "Data from [wttr.in](http://wttr.in/)." embed.description = "Data from [wttr.in](http://wttr.in/)."
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
loc = loc.replace(" ", "+") loc = loc.replace(" ", "+")
async with self.session.get(f"http://wttr.in/{loc}_{units}pnFQ.png") as resp: embed.set_image(url=f"http://wttr.in/{loc}_{units}pnFQ.png")
if resp.status != 200: await ctx.send(embed=embed)
raise cmn.BotHTTPError(resp)
data = io.BytesIO(await resp.read())
embed.set_image(url="attachment://wttr_forecast.png")
await ctx.send(embed=embed, file=discord.File(data, "wttr_forecast.png"))
@_weather_conditions.command(name="now", aliases=["n"], category=cmn.cat.weather) @_weather_conditions.command(name="now", aliases=["n"], category=cmn.cat.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."""
async with ctx.typing(): try:
try: units_arg = re.search(self.wttr_units_regex, location).group(1)
units_arg = re.search(self.wttr_units_regex, location).group(1) except AttributeError:
except AttributeError: units_arg = ""
units_arg = "" if units_arg.lower() == "f":
if units_arg.lower() == "f": units = "u"
units = "u" elif units_arg.lower() == "c":
elif units_arg.lower() == "c": units = "m"
units = "m" else:
else: units = ""
units = ""
loc = self.wttr_units_regex.sub("", location).strip() loc = self.wttr_units_regex.sub("", location).strip()
embed = cmn.embed_factory(ctx) embed = cmn.embed_factory(ctx)
embed.title = f"Current Weather for {loc}" embed.title = f"Current Weather for {loc}"
embed.description = "Data from [wttr.in](http://wttr.in/)." embed.description = "Data from [wttr.in](http://wttr.in/)."
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
loc = loc.replace(" ", "+") loc = loc.replace(" ", "+")
async with self.session.get(f"http://wttr.in/{loc}_0{units}pnFQ.png") as resp: embed.set_image(url=f"http://wttr.in/{loc}_0{units}pnFQ.png")
if resp.status != 200: await ctx.send(embed=embed)
raise cmn.BotHTTPError(resp)
data = io.BytesIO(await resp.read())
embed.set_image(url="attachment://wttr_now.png")
await ctx.send(embed=embed, file=discord.File(data, "wttr_now.png"))
def setup(bot: commands.Bot): def setup(bot: commands.Bot):

16
main.py
View File

@ -45,20 +45,18 @@ loop = asyncio.get_event_loop()
connector = loop.run_until_complete(conn.new_connector()) connector = loop.run_until_complete(conn.new_connector())
# Defining the intents # Defining the intents
intents = discord.Intents.default() intents = discord.Intents.none()
# We don't need those intents.guilds = True
intents.bans = False intents.guild_messages = True
intents.emojis = False intents.dm_messages = True
intents.integrations = False
intents.webhooks = False member_cache = discord.MemberCacheFlags.from_intents(intents)
intents.invites = False
intents.voice_states = False
intents.typing = False
bot = commands.Bot(command_prefix=opt.prefix, bot = commands.Bot(command_prefix=opt.prefix,
case_insensitive=True, case_insensitive=True,
description=info.description, help_command=commands.MinimalHelpCommand(), description=info.description, help_command=commands.MinimalHelpCommand(),
intents=intents, intents=intents,
member_cache=member_cache,
loop=loop, loop=loop,
connector=connector) connector=connector)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

@ -2,7 +2,8 @@
"ca": ["ca.png", "Canada", "Amateur radio bands in Canada", "**This bandplan is incomplete**; some bands, like 630m, are simply not present. It also does not cover any band above 30MHz.", "[RAC 0-30MHz Band Plan](https://www.rac.ca/wp-content/uploads/files/pdf/RAC%20Bandplan%20December%201%202015.pdf)", "🇨🇦"], "ca": ["ca.png", "Canada", "Amateur radio bands in Canada", "**This bandplan is incomplete**; some bands, like 630m, are simply not present. It also does not cover any band above 30MHz.", "[RAC 0-30MHz Band Plan](https://www.rac.ca/wp-content/uploads/files/pdf/RAC%20Bandplan%20December%201%202015.pdf)", "🇨🇦"],
"cn": ["cn.png", "China", "Amateur radio bands in China", "", "Created by KN8U and NY7H", "🇨🇳"], "cn": ["cn.png", "China", "Amateur radio bands in China", "", "Created by KN8U and NY7H", "🇨🇳"],
"mx": ["mx.png", "Mexico", "Radio allocations in Mexico", "Full radio allocations chart for all services. No information specific to amateur radio is shown.", "Secretaría de Comunicaciones y Transportes (SCT) / Instituto Federal de Telecomunicaciones (IFT)", "🇲🇽"], "mx": ["mx.png", "Mexico", "Radio allocations in Mexico", "Full radio allocations chart for all services. No information specific to amateur radio is shown.", "Secretaría de Comunicaciones y Transportes (SCT) / Instituto Federal de Telecomunicaciones (IFT)", "🇲🇽"],
"nl": ["nl.png", "Netherlands", "Amateur radio bands in the Netherlands", "", "", "🇳🇱"], "jp": ["jp.png", "Japan", "Amateur radio bands in Japan", "Pending checks against the latest update from the 総務省 (MIC) of Japan, March 2020", "[JARL Amateur-Use Bandplans](https://jarl.org/Japanese/A_Shiryo/A-3_Band_Plan/bandplan20150105.pdf)", "🇯🇵"],
"nl": ["nl.png", "Netherlands", "Amateur radio bands in the Netherlands", "*This version of this bandplan is no longer hosted on VERNON's website and it's accuracy cannot be guaranteed.*", "[VERNON Global Band Plan van de Telecom Agency, Ministerie van Economische Zaken en Klimaat](https://www.veron.nl/downloads/brochures/)", "🇳🇱"],
"us": ["us.png", "USA", "Amateur radio bands in the USA", "", "*[ARRL Frequency Chart](https://www.arrl.org/shop/ARRL-Frequency-Chart-11-17/)* [[PDF]](http://www.arrl.org/files/file/Regulatory/Band%20Chart/Band%20Chart%20-%2011X17%20Color.pdf)", "🇺🇸"], "us": ["us.png", "USA", "Amateur radio bands in the USA", "", "*[ARRL Frequency Chart](https://www.arrl.org/shop/ARRL-Frequency-Chart-11-17/)* [[PDF]](http://www.arrl.org/files/file/Regulatory/Band%20Chart/Band%20Chart%20-%2011X17%20Color.pdf)", "🇺🇸"],
"au": ["au.png", "Australia", "Amateur radio bands in Australia", "", "[Radio Amateur Society of Australia](https://vkradioamateurs.org/its-my-frequency-and-ill-cry-if-i-want-to/) [[PDF]](https://vkradioamateurs.org/wp-content/uploads/2018/05/VK-Band-Plan-Quick-Reference-1.pdf)", "🇦🇺"], "au": ["au.png", "Australia", "Amateur radio bands in Australia", "", "[Radio Amateur Society of Australia](https://vkradioamateurs.org/its-my-frequency-and-ill-cry-if-i-want-to/) [[PDF]](https://vkradioamateurs.org/wp-content/uploads/2018/05/VK-Band-Plan-Quick-Reference-1.pdf)", "🇦🇺"],
"it_hf": ["it_hf.png", "Italy (HF)", "HF amateur radio bands in Italy", "", "[Associazione Radioamatori Italiani](https://www.arimi.it/download/bandplan/) [[PDF]](http://www.arimi.it/wp-content/Plan/BP%20HF%202013%2032.pdf)", "🇮🇹"], "it_hf": ["it_hf.png", "Italy (HF)", "HF amateur radio bands in Italy", "", "[Associazione Radioamatori Italiani](https://www.arimi.it/download/bandplan/) [[PDF]](http://www.arimi.it/wp-content/Plan/BP%20HF%202013%2032.pdf)", "🇮🇹"],