Merge pull request #335 from miaowware/glts

Fixed ?greyline caching (set date url param)
This commit is contained in:
0x5c 2021-01-18 01:12:12 -05:00 committed by GitHub
commit 31a4fca70e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -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).

View File

@ -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)