mirror of
https://github.com/miaowware/qrm2.git
synced 2024-11-29 11:18:51 -05:00
Merge pull request #335 from miaowware/glts
Fixed ?greyline caching (set date url param)
This commit is contained in:
commit
31a4fca70e
@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- Moved great circle distance and bearing calculation from `?ungrid` to `?griddistance`.
|
- Moved great circle distance and bearing calculation from `?ungrid` to `?griddistance`.
|
||||||
- `?ungrid` to `?latlong`.
|
- `?ungrid` to `?latlong`.
|
||||||
- Renamed `?cond` to `?solar`.
|
- Renamed `?cond` to `?solar`.
|
||||||
|
### Fixed
|
||||||
|
- Weird image caching situation for `?greyline` on Discord's side.
|
||||||
### Deprecated
|
### Deprecated
|
||||||
- `?ungrid`.
|
- `?ungrid`.
|
||||||
- Deprecated old `?solar` aliases (`?cond`, etc).
|
- Deprecated old `?solar` aliases (`?cond`, etc).
|
||||||
|
@ -9,6 +9,7 @@ the GNU General Public License, version 2.
|
|||||||
|
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import discord.ext.commands as commands
|
import discord.ext.commands as commands
|
||||||
@ -17,7 +18,7 @@ import common as cmn
|
|||||||
|
|
||||||
|
|
||||||
class ImageCog(commands.Cog):
|
class ImageCog(commands.Cog):
|
||||||
gl_url = "https://www.fourmilab.ch/cgi-bin/uncgi/Earth?img=ETOPO1_day-m.evif&dynimg=y&opt=-p"
|
gl_baseurl = "https://www.fourmilab.ch/cgi-bin/uncgi/Earth?img=ETOPO1_day-m.evif&dynimg=y&opt=-p"
|
||||||
|
|
||||||
def __init__(self, bot: commands.Bot):
|
def __init__(self, bot: commands.Bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
@ -85,9 +86,8 @@ class ImageCog(commands.Cog):
|
|||||||
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
|
||||||
# Generate a nonce to force discord to recache this
|
date_params = f"&date=1&utc={datetime.utcnow():%Y-%m-%d+%H:%M:%S}"
|
||||||
cachenonce = (ctx.message.id >> 22) // 1000 // 600 # nonce will stay the same for ~10min
|
embed.set_image(url=self.gl_baseurl + date_params)
|
||||||
embed.set_image(url=self.gl_url + f"&cachenonce={cachenonce}")
|
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user