diff --git a/CHANGELOG.md b/CHANGELOG.md index dd861d2..90942fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### 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 +- 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. +- Fixed network error in `?greyline`. ## [2.4.1] - 2020-10-06 diff --git a/exts/base.py b/exts/base.py index 789bece..970373b 100644 --- a/exts/base.py +++ b/exts/base.py @@ -108,7 +108,6 @@ class BaseCog(commands.Cog): embed = cmn.embed_factory(ctx) embed.title = "About qrm" embed.description = info.description - embed.add_field(name="Authors", value=", ".join(info.authors)) embed.add_field(name="License", value=info.license) embed.add_field(name="Version", value=f"v{info.release}") diff --git a/exts/fun.py b/exts/fun.py index 93ef379..856b617 100644 --- a/exts/fun.py +++ b/exts/fun.py @@ -19,7 +19,7 @@ import common as cmn class FunCog(commands.Cog): def __init__(self, bot: commands.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() @commands.command(name="xkcd", aliases=["x"], category=cmn.cat.fun) diff --git a/exts/image.py b/exts/image.py index b6262f9..ee270d6 100644 --- a/exts/image.py +++ b/exts/image.py @@ -8,8 +8,6 @@ the GNU General Public License, version 2. """ -import io - import aiohttp import discord @@ -85,16 +83,11 @@ class ImageCog(commands.Cog): @commands.command(name="grayline", aliases=["greyline", "grey", "gray", "gl"], category=cmn.cat.maps) async def _grayline(self, ctx: commands.Context): """Gets a map of the current greyline, where HF propagation is the best.""" - async with ctx.typing(): - embed = cmn.embed_factory(ctx) - embed.title = "Current Greyline Conditions" - embed.colour = cmn.colours.good - async with self.session.get(self.gl_url) as resp: - 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")) + embed = cmn.embed_factory(ctx) + embed.title = "Current Greyline Conditions" + embed.colour = cmn.colours.good + embed.set_image(url=self.gl_url) + await ctx.send(embed=embed) def setup(bot: commands.Bot): diff --git a/exts/lookup.py b/exts/lookup.py index e1c585f..ee1b18e 100644 --- a/exts/lookup.py +++ b/exts/lookup.py @@ -9,6 +9,7 @@ the GNU General Public License, version 2. import threading +from pathlib import Path from ctyparser import BigCty @@ -17,11 +18,14 @@ from discord.ext import commands, tasks import common as cmn +cty_path = Path("./data/cty.json") + + class LookupCog(commands.Cog): def __init__(self, bot): self.bot = bot try: - self.cty = BigCty("./data/cty.json") + self.cty = BigCty(cty_path) except OSError: self.cty = BigCty() @@ -67,7 +71,7 @@ class LookupCog(commands.Cog): @tasks.loop(hours=24) 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() diff --git a/exts/weather.py b/exts/weather.py index 2587428..27dfdf6 100644 --- a/exts/weather.py +++ b/exts/weather.py @@ -8,12 +8,10 @@ the GNU General Public License, version 2. """ -import io import re import aiohttp -import discord import discord.ext.commands as commands import common as cmn @@ -29,16 +27,11 @@ class WeatherCog(commands.Cog): @commands.command(name="bandconditions", aliases=["cond", "condx", "conditions"], category=cmn.cat.weather) async def _band_conditions(self, ctx: commands.Context): """Gets a solar conditions report.""" - async with ctx.typing(): - embed = cmn.embed_factory(ctx) - embed.title = "Current Solar Conditions" - embed.colour = cmn.colours.good - async with self.session.get("http://www.hamqsl.com/solarsun.php") as resp: - 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")) + embed = cmn.embed_factory(ctx) + embed.title = "Current Solar Conditions" + embed.colour = cmn.colours.good + embed.set_image(url="http://www.hamqsl.com/solarsun.php") + await ctx.send(embed=embed) @commands.group(name="weather", aliases=["wttr"], case_insensitive=True, category=cmn.cat.weather) 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): """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.""" - async with ctx.typing(): - try: - units_arg = re.search(self.wttr_units_regex, location).group(1) - except AttributeError: - units_arg = "" - if units_arg.lower() == "f": - units = "u" - elif units_arg.lower() == "c": - units = "m" - else: - units = "" + try: + units_arg = re.search(self.wttr_units_regex, location).group(1) + except AttributeError: + units_arg = "" + if units_arg.lower() == "f": + units = "u" + elif units_arg.lower() == "c": + units = "m" + else: + units = "" - loc = self.wttr_units_regex.sub("", location).strip() + loc = self.wttr_units_regex.sub("", location).strip() - embed = cmn.embed_factory(ctx) - embed.title = f"Weather Forecast for {loc}" - embed.description = "Data from [wttr.in](http://wttr.in/)." - embed.colour = cmn.colours.good + embed = cmn.embed_factory(ctx) + embed.title = f"Weather Forecast for {loc}" + embed.description = "Data from [wttr.in](http://wttr.in/)." + embed.colour = cmn.colours.good - loc = loc.replace(" ", "+") - async with self.session.get(f"http://wttr.in/{loc}_{units}pnFQ.png") as resp: - if resp.status != 200: - 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")) + loc = loc.replace(" ", "+") + embed.set_image(url=f"http://wttr.in/{loc}_{units}pnFQ.png") + await ctx.send(embed=embed) @_weather_conditions.command(name="now", aliases=["n"], category=cmn.cat.weather) async def _weather_conditions_now(self, ctx: commands.Context, *, location: str): """Gets current local weather conditions from [wttr.in](http://wttr.in/). See help of the `weather` command for possible location types and options.""" - async with ctx.typing(): - try: - units_arg = re.search(self.wttr_units_regex, location).group(1) - except AttributeError: - units_arg = "" - if units_arg.lower() == "f": - units = "u" - elif units_arg.lower() == "c": - units = "m" - else: - units = "" + try: + units_arg = re.search(self.wttr_units_regex, location).group(1) + except AttributeError: + units_arg = "" + if units_arg.lower() == "f": + units = "u" + elif units_arg.lower() == "c": + units = "m" + else: + units = "" - loc = self.wttr_units_regex.sub("", location).strip() + loc = self.wttr_units_regex.sub("", location).strip() - embed = cmn.embed_factory(ctx) - embed.title = f"Current Weather for {loc}" - embed.description = "Data from [wttr.in](http://wttr.in/)." - embed.colour = cmn.colours.good + embed = cmn.embed_factory(ctx) + embed.title = f"Current Weather for {loc}" + embed.description = "Data from [wttr.in](http://wttr.in/)." + embed.colour = cmn.colours.good - loc = loc.replace(" ", "+") - async with self.session.get(f"http://wttr.in/{loc}_0{units}pnFQ.png") as resp: - if resp.status != 200: - 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")) + loc = loc.replace(" ", "+") + embed.set_image(url=f"http://wttr.in/{loc}_0{units}pnFQ.png") + await ctx.send(embed=embed) def setup(bot: commands.Bot): diff --git a/main.py b/main.py index 3aa95ca..548d9c5 100644 --- a/main.py +++ b/main.py @@ -45,20 +45,18 @@ loop = asyncio.get_event_loop() connector = loop.run_until_complete(conn.new_connector()) # Defining the intents -intents = discord.Intents.default() -# We don't need those -intents.bans = False -intents.emojis = False -intents.integrations = False -intents.webhooks = False -intents.invites = False -intents.voice_states = False -intents.typing = False +intents = discord.Intents.none() +intents.guilds = True +intents.guild_messages = True +intents.dm_messages = True + +member_cache = discord.MemberCacheFlags.from_intents(intents) bot = commands.Bot(command_prefix=opt.prefix, case_insensitive=True, description=info.description, help_command=commands.MinimalHelpCommand(), intents=intents, + member_cache=member_cache, loop=loop, connector=connector) diff --git a/resources/img/bandcharts/jp.png b/resources/img/bandcharts/jp.png new file mode 100644 index 0000000..f087e5c Binary files /dev/null and b/resources/img/bandcharts/jp.png differ diff --git a/resources/img/bandcharts/meta.json b/resources/img/bandcharts/meta.json index 110beb9..a7c94c4 100644 --- a/resources/img/bandcharts/meta.json +++ b/resources/img/bandcharts/meta.json @@ -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)", "๐Ÿ‡จ๐Ÿ‡ฆ"], "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)", "๐Ÿ‡ฒ๐Ÿ‡ฝ"], - "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)", "๐Ÿ‡บ๐Ÿ‡ธ"], "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)", "๐Ÿ‡ฎ๐Ÿ‡น"],