mirror of
https://github.com/miaowware/qrm2.git
synced 2025-06-30 07:15:16 -04:00
Merge pull request #297 from miaowware/no-dl
Switch to sending an URL instead of fetching images
This commit is contained in:
commit
77a5af73bc
@ -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
|
||||||
async with self.session.get(self.gl_url) as resp:
|
embed.set_image(url=self.gl_url)
|
||||||
if resp.status != 200:
|
await ctx.send(embed=embed)
|
||||||
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):
|
||||||
|
@ -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
|
||||||
async with self.session.get("http://www.hamqsl.com/solarsun.php") as resp:
|
embed.set_image(url="http://www.hamqsl.com/solarsun.php")
|
||||||
if resp.status != 200:
|
await ctx.send(embed=embed)
|
||||||
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,7 +54,6 @@ 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:
|
||||||
@ -81,18 +73,13 @@ class WeatherCog(commands.Cog):
|
|||||||
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:
|
||||||
@ -112,12 +99,8 @@ class WeatherCog(commands.Cog):
|
|||||||
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):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user